Relaying Mail with ColdFusion

ColdFusion Mail


ColdFusion has the ability to deliver email messages locally or externally from a mail server. The tag to accomplish this is <cfmail> which is easy to utilize and implement within your web applications.

Using CFMAIL with Default SMTP

This method will allow you to send through the servers default SMTP server. You’ll need to make sure and leave out the server, username, and password attributes when using this method as shown below:

<cfmail
  from="#from#"
  to="#to#"
  subject="Sample CF e-mail">

This is the body of a test email.

</cfmail>

SmarterMail SMTP Authentication for VPSs

For security reasons, it is the best practice to use SMTP Authentication for all scripts, either with SmarterMail on the VPS or an External SMTP Server, this is to prevent unauthorized emails being sent from the VPS. If SMTP Authentication Bypass is needed, and cannot be avoided, the Bypass can be set up through the security settings in SmarterMail.

Using CFMAIL with External SMTP

This second method will allow you to send through an external SMTP server such as mail.example.com. It requires specifying the server, port, useSSL, username, and password attributes as shown below:

<cfmail
  server="mail.example.com"
  port="587"
  useSSL="false"
  username="[email protected]"
  password="mySecretPassword!"
  from="#from#"
  to="#to#"
  subject="Sample CF e-mail">

This is the body of a test email.

</cfmail>

If you’re having trouble utilizing <cfmail> in your application please feel free to contact our support team and we’ll be happy to help.