Sending Emails

edit

Sending Emails

Send emails using <cfmail>. Mail server configuration options:

Tags

<cfmail subject="Your Order" from="whatever@lucee.org" to="whatever@gmail.com">
  Hi there,
  This mail is sent to confirm that we have received your order.
</cfmail>

Script

mail subject="Your Order" from="whatever@lucee.org" to="whatever@gmail.com" {
  writeOutput('Hi there,');
  writeOutput('This mail is sent to confirm that we have received your order.');
};

Addressing

You can pass in a list of email addresses, either bare or with titles, use quotes if the title contains a special character

  • lucee1@example.com
  • "Server, Lucee" <lucee2@example.com>
  • Lucee Server <lucee3@example.com>
<cfmail subject="hello world" 
  to='lucee1@example.com,"Server, Lucee"<lucee2@example.com>,Lucee Server<lucee3@example.com>'.....>
Hello Possums
</cfmail>

Spooling

By default Lucee spools mails and sends them out via a background thread, for better performance.

If you need to send the mail immediately, or need catch any SMTP errors, use async="false" which will send the email immediately and throw an errors encountered which will otherwise be caught and logged to the remoteclient.log

mail subject="Your Order" from="whatever@lucee.org" to="whatever@gmail.com" async="false" {
  writeOutput('Hi there,');
  writeOutput('This mail is sent to confirm that we have received your order.');
};

See also