View comments | RSS feed

Sending e-mail messages

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.

To configure ColdFusion for e-mail:

  1. In the ColdFusion Administrator, select Server Settings > Mail Server.
  2. In the Mail Server box, enter the name or IP address of your SMTP mail server.
  3. (Optional) Change the Server Port and Connection Timeout default settings.
  4. Select the Verify Mail Server Connection check box to make sure ColdFusion can access your mail server.
  5. (Optional) Change the Server Port and Connection Timeout default settings.
  6. Click Submit Changes.

    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.

Sending SMTP e-mail with cfmail

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:
Attribute
Description
subject
The subject of the message.
from
The e-mail address of the sender.
to
The e-mail address of the recipient. Use a comma-delimited list to specify multiple recipients.
cc
(Optional) The e-mail address of a carbon copy recipient. The recipient's address is visible to other recipients. Use a comma-delimited list to specify multiple cc recipients.
bcc
(Optional) The e-mail address of a blind carbon copy recipient. The recipient's address is not visible to other recipients. Use a comma-delimited list to specify multiple bcc recipients.
SpoolEnable
(Optional) When SpoolEnable="yes", saves a copy of the message until the sending operation is complete.

To send a simple e-mail message:

  1. Create a ColdFusion page with the following content:
    <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>
    
  2. Save the file as send_mail.cfm in the myapps directory under your web_root directory.
  3. Open your browser and enter the following URL:

    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".

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6

Comments are no longer accepted for ColdFusion MX. ColdFusion 8 is the current version.

Comments


aquarius.west said on Mar 7, 2004 at 10:59 PM :
In CF 4.5 we could place the recipient name as well as their email address in the To attribute of CFMAIL as follows: to="#email# (#name#)"

The result would be that the recipients name --instead of their email address-- appears in the To when the email arrives.

Has the syntax changed in CF 5.0? It's not working anymore (email is not sent).
jrunrandy said on Mar 10, 2004 at 6:57 AM :
* Change between CF 4.5 and CF 5 *

In ColdFusion 4.5 and CF 5 (Enterprise), you could place the recipient name as well as their
email address in the To attribute of CFMAIL as follows: to="#email# (#name#)"

The result would be that the recipients name --instead of their email address-- appears in the To when the email arrives.

This functionality is not available in CF MX.
No screen name said on Aug 10, 2004 at 3:33 AM :
Dear Sir / Madame,

I am Bonda, from Cambodia. In this section on the sending e-mail from Cold Fusion, i worked the follow by the instruction and configured the smtp mail server successfull and then Run the script after running finish sending was completely and sucessfull, but in mail box of receiver did not any mail to receive. after this i am always try and try but have no corected.

Please you give me any idea to solved this problem.

Thanks.

This Script here.

<html><head> <title>Sending a simple e-mail</title></head>
<body>
<h1>Sample e-mail</h1>
<cfmail
from="bonda_huy@yahoo.co.uk"
to="neospacecity@yahoo.co.uk"
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>
Amal Bukhari Saleh said on Sep 19, 2004 at 5:02 AM :
In the ColdFusion Administrator mail settings, I put my Yahoo! email account and password in the format user:password@server.com. I have tried using the changing the server.com part with yahoo.com and smtp.mail.yahoo.com but both approach failed when I want to send emails. Any comments on what should I do?

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/email3.htm