<cfmail>
Sends e-mail messages by an SMTP server.
This tag must have a body.
This tag is also supported within <cfscript>
<cfmail
from=object
to=object
cc=object
bcc=object
replyTo=object
failTo=object
subject=string
type=string
maxRows=number
mimeAttach=string
listener=any
query=string
group=string
groupCaseSensitive=boolean
startRow=number
server=string
port=number
mailerID=string
timeout=number
username=string
password=string
wrapText=number
charset=string
async=boolean
useTls=boolean
priority=String
useSsl=boolean
proxyServer=string
proxyPort=number
proxyUser=string
proxyPassword=string
remove=boolean
sendTime=datetime
debug=boolean
><!--- body ---></cfmail>
| Attribute | Description |
|---|---|
from
object, required
|
edit
The sender of the e-mail message. |
to
object, required
|
edit
The name of the e-mail message recipient. |
cc
object, optional
|
edit
Indicates addresses to copy the e-mail message to; "cc" stands for "carbon copy." |
bcc
object, optional
|
edit
Indicates addresses to copy the e-mail message to, without listing them in the message header. "bcc" stands for "blind carbon copy." |
replyTo
object, optional
|
edit
Address(es) to which the recipient is directed to send replies. |
failTo
object, optional
|
edit
Address to which mailing systems should send delivery failure notifications. Sets the mail envelope Return-Path value. |
subject
string, required
|
edit
The subject of the mail message. This field may be driven dynamically on a message-by-message basis |
type
string, optional
|
edit
Specifies extended type attributes for the message.
|
mimeAttach
string, optional
|
edit
Specifies the path of the file to be attached to the e-mail message. An attached file is MIME-encoded. |
listener
any, optional
|
edit
Listener for the mail. the listener can have 2 (optional) functions, "before" and "after" that get triggered before and after sending the mail. The functions get all data about the mail. Listener is only used when This attribute overwrites any mail listener defined in the The "before" function can also modify some data, by returning a struct containing the following keys:
the listener can be a component looking like this: component {
function before( lastExecution, nextExecution, created, id, type, detail,
tries, remainingTries, closed, caller, advanced ){}
function after( lastExecution, nextExecution, created, id, type, detail, tries,
remainingTries, closed, caller, advanced, passed, exception ){}
}
a struct looking like this:
|
groupCaseSensitive
boolean, optional
|
edit
Boolean indicating whether to group with regard to case or not. The default value is NO; case is considered while grouping. If the query attribute specifies a query object that was generated by a case-insensitive SQL query, set the groupCaseSensitive attribute to NO to keep the recordset intact. |
server
string, optional
|
edit
The address of the SMTP server to use for sending messages. If no server is specified, the server name specified in the Lucee Administrator is used. |
port
number, optional
|
edit
The TCP/IP port on which the SMTP server listens for requests. This is normally 25. |
mailerID
string, optional
|
edit
Specifies a mailer ID to be passed in the X-Mailer SMTP header, which identifies the mailer application. |
timeout
number, optional
|
edit
The number of seconds to wait before timing out the connection to the SMTP server. |
username
string, optional
|
edit
A user name to send to SMTP servers that require authentication. Requires a password attribute. |
password
string, optional
|
edit
A password to send to SMTP servers that require authentication. Requires a username attribute. |
wrapText
number, optional
|
edit
Specifies 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. |
charset
string, optional
|
edit
Character encoding of the mail message |
async
boolean, optional
|
edit
if set to true, the mail is sent asynchronously by the Lucee Task manager (with multiple tries), if set to false the mail is sent in the same thread that executes the request, which is useful for troubleshooting because you get an error message if there is one. This setting overrides the setting with the same name in the Lucee Administrator. This attribute replaces the old "spoolenable" attribute which is still supported as an alias. Alias: spoolenable |
useTls
boolean, optional
|
edit
Whether to use Transport Level Security. Alias: tls, starttls |
priority
String, optional
|
edit
The message priority level. Can be one of the following values:
|
useSsl
boolean, optional
|
edit
Whether to use Secure Sockets Layer. Alias: ssl, secure |
proxyServer
string, optional
|
edit
Host name or IP address of a proxy server. |
proxyPort
number, optional
|
edit
The port number on the proxy server from which the object is requested. Default is 80. When used with resolveURL, the URLs of retrieved documents that specify a port number are automatically resolved to preserve links in the retrieved document. |
proxyUser
string, optional
|
edit
When required by a proxy server, a valid username. |
proxyPassword
string, optional
|
edit
When required by a proxy server, a valid password. |
remove
boolean, optional
|
edit
remove all attachments from filesystem after the mail is successfully sent |
sendTime
datetime, optional
|
edit
Set a future date time to send an email in the future via the spooler. |
debug
boolean, optional
|
edit
Whether to enable detailed logging to console. |
Unimplemented Attribute(s)
| Attribute | Description |
|---|---|
maxRows
number,
optional
|
edit
Specifies the maximum number of e-mail messages to send. * unimplemented * |
query
string,
optional
|
edit
The name of the cfquery from which to draw data for message(s) to send. Specify this attribute to send more than one mail message, or to send the results of a query within a message. * unimplemented * |
group
string,
optional
|
edit
Specifies the query column to use when you group sets of records together to send as an e-mail message. For example, if you send a set of billing statements to customers, you might group on "Customer_ID." The group attribute, which is case sensitive, eliminates adjacent duplicates when the data is sorted by the specified field. See the Usage section for exceptions. * unimplemented * |
startRow
number,
optional
|
edit
Specifies the row in the query to start from. * unimplemented * |
Examples
editSimple example for cfmail
<cftry>
<cfmail from="aaa@bb.com" to="test01@mail.com" subject="sample" cc="test02@gmail.com" server="example.mail.com">
Test Email
</cfmail>
<cfcatch>
<cfdump var="#cfcatch.message#">
</cfcatch>
</cftry>
Related System Properties / Environment Variables
- LUCEE_MAIL_USE_7BIT_TRANSFER_ENCODING_FOR_HTML_PARTS - Enabled by default in Lucee 7
Type: boolean, Default: true - LUCEE_SSL_CHECKSERVERIDENTITY - A boolean value. If enabled, checks the identity of the SSL certificate with SMTP
Type: boolean, Default: true - LUCEE_USE_LUCEE_SSL_TRUSTSTORE - Specifies the file location of the trust store that contains trusted Certificate Authorities (CAs) for SSL/TLS connections in Java applications. Lucee 6 uses the JVM trust store by default
Type: string