Sends an e-mail message that optionally contains query output, using an SMTP server.
You can specify this tag's attributes in an
ColdFusion 11: Added the attributes, encrypt, recipientcert, and encryptionalgorithm.
ColdFusion 8.0.1: Added the attribute
ColdFusion 8: Added
ColdFusion MX 7:
cfmailtag no longer lets you send multipart mail by embedding the entire MIME-encoded message in the tag body. Use the
cfmailtag renders non-proportional fonts proportionately. This is a behavior change from ColdFusion 5. ColdFusion MX 7 uses UTF-8 and sends this in the mail header (Content-Type: text/plain; charset=UTF-8). ColdFusion 5 uses ISO-8859-1 (Latin 1). To avoid this behavior, add the
charset="ISO-8859-1"attribute to restore the default ColdFusion 5 encoding. Alternatively, you can change the encoding on the Mail page in the ColdFusion Administrator.
ColdFusion MX 6.1:
- Added the following attributes:
- Added support for multiple mail servers in the
- Added several configuration options to the ColdFusion Administrator Mail Settings page.
ColdFusion MX: Added the
SpoolEnableattribute.ColdFusion 9: Added support for digitally signing the mail. The following are the relevant attributes that are newly added:
Addresses to which to copy the message, without listing them in the message header. To specify multiple addresses, separate the addresses with commas.
Addresses to which to copy the message. To specify multiple addresses, separate the address with commas.
Character encoding selected in ColdFusion Administrator Mail page;
Character encoding of the mail message, including the headers. The following list includes commonly used values:
Address to which mailing systems must send delivery failure notifications. Sets the mail envelope reverse-path value.
E-mail message sender:
Message recipient e-mail addresses:
Message subject. Can be dynamically generated. For example, to send messages that give customers status updates:
Query column to use when you group sets of records to send as a message. For example, to send a set of billing statements to a customer, group on "
Boolean. Whether to consider case when using the group attribute. To group on case-sensitive records, set this attribute to Yes.
Alias of the key with which the certificate and private key are stored in the keystore. If it is not specified, the first entry in the keystore is chosen as the alias.
Password for your private key. If not specified, the keystorepassword is used.
The location of the keystore file, for example, C:\OpenSSL\bin\keystore.jks.
The password of the keystore. This is stored in ColdFusion configuration files.
ColdFusion Application Server
Mailer ID to be passed in X-Mailer SMTP header, which identifies the mailer application.
Maximum number of messages to send when looping over a query.
Path of the on-disk or in-memory file to attach to message. Attached file is MIME-encoded. ColdFusion attempts to determine the MIME type of the file; use the
A password to send to SMTP servers that require authentication. Requires a
TCP/IP port on which SMTP server listens for requests (normally 25). A value here overrides the Administrator.
The message priority level. Can be one of the following values:
Addresses to which the recipient is directed to send replies.
SMTP server address, or (Enterprise edition only) a comma-delimited list of server addresses, to use for sending messages. At least one server must be specified here or in the ColdFusion Administrator. A value here overrides the Administrator. A value that includes a port specification overrides the
Digitally signs the mail. If set to true, all messages that you send will have digital signature.
Whether to spool mail or always send it Immediately. Overrides the ColdFusion Administrator Spool mail messages to disk for delivery setting.
Row in a query to start from.
Number of seconds to wait before timing out connection to SMTP server. A value here overrides the Administrator.
MIME type of the message. Can be a valid MIME media type or one of the following:
A user name to send to SMTP servers that require authentication. Requires a
Whether to use Secure Sockets Layer.
Whether to use Transport Level Security.
Do not wrap text
The maximum line length, in characters of the mail text. If a line has more than the specified number of characters, replaces the last white space character, such as a tab or space, preceding the specified position with a line break. If there are no white space characters, inserts a line break at the specified position. A common value for this attribute is 72.
If the Email should be encrypted.
The path to the public key certificate of the recipient.
The encryption algorithm to use.
The valid algorithms are:
The encryption support is provided through S/MIME.
Sends a mail message to the specified address. Mail messages can include attachments. The tag body can include CFML code to generate mail output. The
and cfmailpart tags can only be used in the
cfmail tag body. Mail messages can be single or multipart. If you send a multi-part mail message, all message content must be in
cfmailpart tags; ColdFusion ignores multipart message text that is not in
If you set
type="text", sometimes whitespace might be compressed in the messages that you send. To resolve this, in the ColdFusion Administrator, go to Server Settings > Settings and then deselect the option Enable Whitespace Management.
Mail addresses can have any of the following forms:
Rob Smith <firstname.lastname@example.org>
"Rob Smith" <email@example.com>
firstname.lastname@example.org (Rob Smith)
Specifying mail servers
server attribute can specify one or more mail servers.
If you specify multiple mail servers in ColdFusion Standard, the
For each server, you can optionally specify a user name, password, and port. These values override the corresponding attributes, if any. The
server attribute has the following format:
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:
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.
To add digital signature to your mail, specify the attributes
sign, keystore, keystorepassword, keyalias, and
keypassword as provided in the following example:
To add digital signature to all the mails you send, instead of adding the attributes to the tag, specify the settings in the Server Settings > Settings page of the ColdFusion Administrator.
If you do not specify the attributes in the tag, the Administrator settings are applied. Also, in the tag, if you set
sign = "true" and do not specify the attributes
keystore, keystorepassword, keyalias, and
keypassword, then the values for these attributes specified using ColdFusion Administrator are applied.
In ColdFusion 11, you can encrypt your mails using the following procedure:
- Get the certificate of the user for whom you wanted to send the mail (.p7c format).
- Specify the path to the generated certificate for the recipientcert attribute. For instance:
<cfmail ... encrypt="true" ENCRYPTIONALGORITHM = "DES_EDE3_CBC" recipientcert="#path#cert.p7c" >
- Configure the mail server from your ColdFusion Administrator.
- Download the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files from the Oracle website for the JRE version that ColdFusion is configured with (if you are using an encryption algorithm whose key size is greater than 128).
- Send the mail. See the following example.