ColdFusion Muse

CFMAIL and SMTP Authentication

Mark Kruger October 14, 2005 11:26 AM Coldfusion Tips and Techniques Comments (3)

It's pretty common these days for mail servers to require SMTP authentication. The problem is that the CFMAIL tag has no place for a username and password when sending mail. Not to worry, you can use the "username:password@mydomain.com" syntax in the "server" attribute of the tag to authenticate. For Example:

<Cfmail server="buffy:catsRcool@mail.buffyscats.com"
         from="info@buffycats.com"
            to="bobbiejoe@hotmail.com"
                  subject="Your cat is on the way">

Thank you for buy from Buffy's Cat.
Your cat will be shipped within 24 hours.
Remember to keep refrigerated until use.

</CFMAIL>

You can also use the same server syntax in the mail server text box in CF admin. If your server doesn't use SMTP but uses "POP before SMTP" you can solve that problem by hitting a mailbox first with CFPOP then sending your mail. Dan Vega has a great explanation of that technique.

  • Share:

3 Comments


Leave this field empty

Write a comment

If you subscribe, any new posts to this thread will be sent to your email address.

  • dan's Gravatar
    Posted By
    dan | 10/14/05 9:46 AM
    Good explanation of smtp authentication, thanks for the link back. I always enjoy shameless plugs..haha. I think between the two posts it is a great article waiting to happen. I will wait to see if I get anymore feedback and recompile a full article.
  • Andrea Veggiani's Gravatar
    Posted By
    Andrea Veggiani | 10/14/05 5:25 PM
    CFMX 6.1 introduced the attributes username and password for SMTP authentication.
  • Mark's Gravatar
    Posted By
    Mark | 10/14/05 9:33 PM
    Andrea - really? I guess they never made it into my tag updater. The old way still appears to work. Thanks for the update!