View Full Version : Gmail SMTP for cfmail

March 30th, 2010, 06:47 PM
With CF 8 and above it is possible to configure cfmail tags in your site to use Gmail's SMTP server. First we will need to define an attribute set to use with our cfmail tag.

<cfset mailAttributes =
username="[email protected]",
from="[email protected]",
to="[email protected]",
subject="Cfmail example"
} />

In the above code, you will change the "username" and "from" values to your full Gmail address. The "password" should be the password for the Gmail account you specified. Be sure to change the "to" and "subject" values according to your needs.

Now we need to implement the cfmail tag, using our attributeCollection and enabling SSL:

<cfmail port="465" useSSL="true" attributeCollection="#mailAttributes#">
port 465, SSL enabled

Now you have a working code snippet that will send email using your Gmail account. For more information, please see this post (http://jamiekrug.com/blog/index.cfm/2009/2/13/cfmail-using-Gmail-SMTP) on Jamie Krug's blog.