User Guide

298 Chapter 2: ColdFusion Tags
Note: The cfmail tag does not make copies of attachments when spooling mail to disk. If you use the
cfmail tag to send a message with an attachment with spooling enabled and you use the cffile tag
to delete the attachment file, ColdFusion might not send the mail because the mailing process might
execute after the file was is deleted. (When this happens, the mail log includes a FileNotFound
exception and the e-mail is not sent.) You can prevent this problem by setting
SpoolEnable="No" in
the attribute or disabling spooling in the ColdFusion MX Administrator. Disabling spooling causes the
e-mail to be delivered immediately.
Mail addressing
Mail addresses can have any of the following forms:
Specifying mail servers
The server attribute can specify one or more mail servers.
Note: If you specify multiple mail servers in ColdFusion MX Standard, the cfmail tag uses only the
first server in the specification. ColdFusion logs a warning message to the mail log file and ignores the
additional servers.
For each server, you can optionally specify a username, password, and port. These values override
the corresponding attributes, if any. The
server attribute has the following format:
[user:password@]server[:port],[user:password@]server[:port],....
For example, the following line specifies one server, mail.myco.com that uses the default port and
no user or password, and a second server with a user, password, and specific port:
server=mail.myco.com,mail_admin:adm2qzf@mail2.myco.com:24
When you specify multiple mail servers in ColdFusion Enterprise, ColdFusion tries the available
servers in the order they are listed until it connects to a server. ColdFusion does not try to connect
to a server that was unavailable in the last 60 seconds.
Example
<h3>cfmail Example</h3>
<!--- Delete the surrounding comments to use this example.
<cfif IsDefined("form.mailto")>
<cfif form.mailto is not ""
AND form.mailfrom is not ""
AND form.Subject is not "">
<cfmail to = "#form.mailto#"
from = "#form.mailFrom#"
subject = "#form.subject#">
Format Example
user@server rsmith@company.com
<user@server> <rsmith@company.com>
DisplayName <user@server> Rob Smith <rsmith@company.com>
"DisplayName" <user@server> "Rob Smith" <rsmith@company.com>
user@server (DisplayName) rsmith@company.com (Rob Smith)