User Guide

Table Of Contents
976 Chapter 39: Sending and Receiving E-Mail
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” on page 974.
The cfmail tag has many options that let you customize your mail or control how it is sent. Later
sections in the chapter describe how to use some of these attributes. For a description of all
attributes, including options to wrap mail text at a specified column, specify the mail character
encoding, and specify the mail server, user name, and password, see the
cfmail description in
CFML Reference.
Sending HTML format e-mail
If you know all the mail recipients use mail applications that are capable of reading and
interpreting HTML code in a mail message, you can use the
cfmail tag to send an HTML
message. The
cfmail tag type="HTML" attribute informs the receiving e-mail client that the
message contains embedded HTML tags that must be processed. For an example that sends
HTML mail, see “Including images in a message” on page 982.