In ColdFusion (2018 release), script functions implemented as CFCs are deprecated in ColdFusion.
Used to sends an e-mail message, that optionally contains query output, using an SMTP server.
Mode |
Syntax |
|---|---|
Creating the service |
new mail() or createObject("component", "mail") |
Initializing the attributes |
Any one of the following:
|
Executing the service action |
mailService.send(_attribute-value_pair_) |
from |
to |
subject |
bcc |
cc |
charset |
debug |
failto |
group |
groupcasesensitive |
mailerid |
maxrows |
mimeattach |
password |
port |
priority |
query |
replyto |
server |
spoolenable |
startrow |
timeout |
type |
username |
useSSL |
useTLS |
wraptext |
remove |
body |
|
|
|
All attributes supported by the tag cfmail can be used as attribute-value pairs. For example,
<cfmail from="#form.mailFrom#"> |
can be used as
mailerService.setFrom(form.mailFrom); |
ColdFusion 9: Added this function.
addParam
Description |
Used to add cfmailparam tags. For example, to attach a file or add a header to an e-mail message. |
Syntax |
mailService.addParam(attribute-value pair) |
Returns |
Nothing |
Arguments |
All attributes supported by the cfmailparam tag can be used as attribute-value pairs. |
addPart
Description |
Used to add cfmailpart tags. For example, one part of a multipart e-mail message. |
Syntax |
mailService.addPart(attribute-value pair) |
Returns |
Nothing |
Arguments |
All attributes supported by the cfmailpart tag can be used as attribute-value pairs. |
send
Description |
Used to invoke the mail service to send an e-mail message. |
Returns |
Nothing |
Syntax |
mailService.send(attribute-value pair) |
Arguments |
All attributes supported by the cfmail tag. |
setAttributes
Description |
Sets attributes for the mail function. |
Returns |
Nothing |
Syntax |
mailService.setAttributes (attribute-value pair) |
Arguments |
All attributes supported by the cfmail tag. |
getAttributes
Description |
Gets attributes that were set for the mail function. |
Returns |
Returns a struct with all or some of the attribute values. |
Syntax |
mailService.get_Attributes_ (attributelist) |
Arguments |
A comma-separated list of attributes. If no list is specified, all defined attributes are returned. |
clearAttributes
Description |
Removes all attributes added for the mail function. |
Returns |
Nothing |
Syntax |
mailService.clearAttributes(attribute_list) |
Arguments |
A comma-separated list of attributes. |
clearParams
Description |
Removes cfmailparam tags that were added using the addParam method. |
Returns |
Nothing |
Syntax |
mailService.clearParams() |
Arguments |
None |
clearParts
Description |
Removes cfmailpart tags that were added using the addPart method. |
Returns |
Nothing |
Syntax |
mailService.clearProcResults() |
Arguments |
None |
clear
Description |
Removes all attributes, cfmailparam tags, and cfmailpart tags that were added using the methods addParam and addPart. |
Returns |
Nothing |
Syntax |
mailService.clear() |
Arguments |
None |
This function corresponds to the tag cfmail. For usage details, see the Usage section for cfmail.
<h3>Sending mail in cfscript</h3> |
Sign in to your account