For the complete experience, please enable JavaScript in your browser. Thank you!

  • Creative Cloud
  • Photoshop
  • Illustrator
  • InDesign
  • Premiere Pro
  • After Effects
  • Lightroom
  • See all
  • See plans for: businesses photographers students
  • Document Cloud
  • Acrobat DC
  • eSign
  • Stock
  • Elements
  • Marketing Cloud
  • Analytics
  • Audience Manager
  • Campaign
  • Experience Manager
  • Media Optimizer
  • Target
  • See all
  • Acrobat Reader DC
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player
  • All products
  • Creative Cloud
  • Individuals
  • Photographers
  • Students and Teachers
  • Business
  • Schools and Universities
  • Marketing Cloud
  • Document Cloud
  • Stock
  • Elements
  • All products
  • Get Support
    Find answers quickly. Contact us if you need to.
    Start now >
  • Learn the apps
    Get started or learn new ways to work.
    Learn now >
  • Ask the community
    Post questions and get answers from experts.
    Start now >
    • About Us
    • Careers At Adobe
    • Investor Relations
    • Privacy  |  Security
    • Corporate Responsibility
    • Customer Showcase
    • Events
    • Contact Us
News
    • 3/22/2016
      Adobe Summit 2016: Are You An Experience Business?
    • 3/22/2016
      Adobe Announces Cross-Device Co-op to Enable People-Based Marketing
    • 3/22/2016
      Adobe and comScore Advance Digital TV and Ad Measurement
    • 3/22/2016
      Adobe Marketing Cloud Redefines TV Experience
CFML Reference / 

mail

Adobe Community Help


Applies to

  • ColdFusion

Contact support

 
By clicking Submit, you accept the Adobe Terms of Use.
 

Description

Used to sends an e-mail message, that optionally contains query output, using an SMTP server.

Syntax

Mode

Syntax

Creating the service

new mail() or createObject("component", "mail")

Initializing the attributes

Any one of the following:

  • mailService=new mail(_attribute-value_pair_)
  • mailService.setAttributes(_attribute-value_pair_)
  • mailService.set_AttributeName_(attribute_value)
  • mailService.send(attribute-value_pair)

Executing the service action

mailService.send(_attribute-value_pair_)

Properties

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);

See also

cfmail, Function summary

History

ColdFusion 9: Added this function.

Methods

  • 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

     

Usage

This function corresponds to the tag cfmail. For usage details, see the Usage section for cfmail.

Example

<h3>Sending mail in cfscript</h3>
<cfscript>
/* create mailer service */
mailerService = new mail();
if(IsDefined("form.mailto"))
{
if(form.mailto is not "" AND form.mailfrom is not "" AND form.Subject is not ""
and form.attachment is not "")
{
savecontent variable="mailBody"{
WriteOutput("This message was sent by an automatic mailer built with cfmail:
= = = = = = = = = = = = = = = = = = = = = = = = = = =" & "<br><br>" & form.body);
}
/* set mail attributes using implicit setters provided */
mailerService.setTo(form.mailto);
mailerService.setFrom(form.mailFrom);
mailerService.setSubject(form.subject);
mailerService.setType("html");
/* add mailparams */
mailerService.addParam(file=expandpath(form.attachment),type="text/plain",remove
=false);
/* send mail using send(). Attribute values specified in an end action like "send" will not persist after the action is performed */
mailerService.send(body=mailBody);
writeoutput("<h3>Thank you</h3>" & "<p>Thank you, " & mailfrom & "<br>" & "Your message, " & subject & ", has been sent to " & mailto & "</p>");
}
}
</cfscript>
<p>
<form action = "mail1.cfm" method="POST">
<table>
<tr>
<td>TO</td>
<td><input type = "Text" name = "MailTo"></td>
</tr>
<tr>
<td>FROM</td>
<td><input type = "Text" name = "MailFrom"></td>
</tr>
<tr>
<td>SUBJECT</td>
<td><input type = "Text" name = "Subject"></td>
</tr>
<tr>
<td>ATTACHMENT</td>
<td><input type = "file" name = "attachment"></td>
</tr>
</table>
<hr>
MESSAGE BODY:
<br>
<textarea name ="body" cols="40" rows="5" wrap="virtual"></textarea>
<!--- Establish required fields. --->
<input type = "hidden" name = "MailTo_required" value = "You must enter a recipient">
<input type = "hidden" name = "MailFrom_required" value = "You must enter a sender">
<input type = "hidden" name = "Subject_required" value = "You must enter a subject">
<input type = "hidden" name = "Body_required" value = "You must enter some text">
<input type = "hidden" name = "attachment_required" value = "You must select a file">
<p><input type = "Submit" name = ""></p>
</p>
</form>

 

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy

Choose your region United States (Change)   Products   Downloads   Learn & Support   Company
Choose your region Close

Americas

Europe, Middle East and Africa

Asia Pacific

  • Brasil
  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Cyprus - English
  • Česká republika
  • Danmark
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Greece - English
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • Malta - English
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • Southeast Asia (Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam) - English
  • 台灣

Commonwealth of Independent States

  • Includes Armenia, Azerbaijan, Belarus, Georgia, Moldova, Kazakhstan, Kyrgyzstan, Tajikistan, Turkmenistan, Ukraine, Uzbekistan

Copyright © 2016 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy | Cookies

AdChoices