Chapter 13: Sending and Receiving Email
207
Sending SMTP mail with CFMAIL
The CFMAIL tag provides support for sending SMTP email 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. You can use
all the attributes and commands that you use with CFOUTPUT with CFMAIL as well.
To send a simple email message:
1.
Create a new file in Studio.
2.
Modify the file so that it appears as follows:
<HTML>
<HEAD>
<TITLE>Sending a simple email</TITLE>
</HEAD>
<BODY>
<H1>Sample email</H1>
<CFMAIL
FROM="[email protected]"
TO="#URL.email#"
SUBJECT="Sample email"
>
This is a sample email to show basic email capability.
</CFMAIL>
The email was sent.
</BODY>
</HTML>
3.
Save the file as
sendmail.cfm
in
myapps
under the Web root directory.
4.
Open your browser and enter the URL that contains the file. Replace
with you email address
.
For example,
http://localhost/myapps/[email protected]
The template sends the email to you, through your SMTP server.
Samples uses of CFMAIL
An application page with the CFMAIL tag dynamically generates email messages based
on the tag’s settings. Some of the things you can accomplish with CFMAIL are:
•
Send a mail message whose recipient and contents are determined by data the
user enters in an HTML form.
•
Use a query to send a mail message to a database-driven list of recipients.
Summary of Contents for COLDFUSION 4.5-DEVELOPING WEB
Page 1: ...Allaire Corporation Developing Web Applications with ColdFusion ColdFusion 4 5...
Page 14: ...xiv Developing Web Applications with ColdFusion...
Page 26: ...xxvi Developing Web Applications with ColdFusion...
Page 34: ...8 Developing Web Applications with ColdFusion...
Page 70: ...44 Developing Web Applications with ColdFusion...
Page 84: ...58 Developing Web Applications with ColdFusion...
Page 114: ...88 Developing Web Applications with ColdFusion...
Page 148: ...122 Developing Web Applications with ColdFusion...
Page 174: ...148 Developing Web Applications with ColdFusion...
Page 208: ...182 Developing Web Applications with ColdFusion...
Page 244: ...218 Developing Web Applications with ColdFusion...
Page 274: ...248 Developing Web Applications with ColdFusion...
Page 288: ...262 Developing Web Applications with ColdFusion...
Page 300: ...274 Developing Web Applications with ColdFusion...
Page 350: ...324 Developing Web Applications with ColdFusion...
Page 362: ...336 Developing Web Applications with ColdFusion...