Before you configure ColdFusion to send e-mail messages, you must have access to an SMTP e-mail server. Also, before you run application pages that refer to the e-mail server, you can configure the ColdFusion Administrator to use the SMTP server. If you later need to override the SMTP server information, you can specify a new mail server in the server attribute of the cfmail tag.
ColdFusion saves the settings. The page displays a message indicating success or failure for connecting to the server.
For more information on the Administrator's mail settings, see Administering ColdFusion MX.
The cfmail tag provides support for sending SMTP e-mail from within ColdFusion applications. The cfmail tag is similar to the cfoutput tag, except that cfmail outputs the generated text as SMTP mail messages rather than to a page. The cfmail tag supports all the attributes and commands that you use with cfoutput, including query. The following table describes important cfmail tag attributes:
<html> <head> <title>Sending a simple e-mail</title> </head> <body> <h1>Sample e-mail</h1> <cfmail from="Sender@Company.com" to="#URL.email#" subject="Sample e-mail from ColdFusion MX"> This is a sample e-mail message to show basic e-mail capability. </cfmail> The e-mail was sent. </body> </html>
http://localhost:8500/myapps/send_mail.cfm?email=myname@mycompany.com
(Replace myname@mycompany.com with your e-mail address.)
The page sends the e-mail message to you, through your SMTP server.
Note: If you do not receive an e-mail message, check whether you have configured ColdFusion to work with your SMTP server; for more information, see "Sending e-mail messages".