Avg. Rating 5.0

Problem

You want to use ColdFusion to send an email using gmail's smtp server.

Solution

Use the cfmail tag and specify the useSSL, server, and port attributes to match gmail's requirements.

Detailed explanation

ColdFusion 8 added support for SSL SMTP connections to the CFMAIL tag. GMail's smtp servers require a secure connection. You can use the following code to send an email through gmail:

<cfmail server="smtp.gmail.com"
    username="username@gmail.com"
    password="secret"
    port="465"
    useSSL="true"
    to="recipient@example.com"
    from="username@gmail.com"
    subject="Gmail Test">

Email Message.

</cfmail>

Note that you can also setup the default SMTP server in ColdFusion Administrator to use GMail's SMTP server as well, use the same settings specified in the above code to accomplish this.


+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes