cfmail

Description

Sends e-mail messages by an SMTP server.

Category

Internet Protocol tags

Syntax


<cfmail to = "recipient"

  from = "sender"

  cc = "copy_to"

  Bcc = "blind_copy_to"

  subject = "msg_subject"

  type = "msg_type"

  maxRows = "max_msgs"

  MIMEAttach = "path"

  query = "query_name"

  group = "query_column"

  groupCaseSensitive = "Yes" or "No"

  startRow = "query_row"

  server = "servername"

  port = "port_ID"

  mailerID = "headerid"

  timeout = "seconds"> 

See also

cfftp, cfhttp, cfldap, cfmailparam, cfpop

Attributes

Attribute
Description
to
Required. The name of the e-mail message recipient(s). This can be either a static address (to = "support@macromedia.com"), a variable that contains an address (to = "#Form.Email#"), or the name of a query column that contains address information (to = "#EMail#"). In the latter case, an e-mail message is sent for each row returned by the query.
from
Required. The sender of the e-mail message. This attribute may be either static (from = "support@macromedia.com") or dynamic (from = "#GetUser.EMailAddress#").
cc
Optional. Indicates addresses to copy the e-mail message to; "cc" stands for "carbon copy."
bcc
Optional. Indicates addresses to copy the e-mail message to, without listing them in the message header. "bcc" stands for "blind carbon copy."
subject
Required. The subject of the mail message. This field may be driven dynamically on a message-by-message basis. For example, to do a mailing that updates customers on the status of their orders, you might use a subject attribute like subject = "Status for Order Number #Order_ID#".
type
Optional. Specifies extended type attributes for the message. Currently, the only valid value for this attribute is "HTML". Specifying type = "HTML" informs the receiving e-mail client that the message has embedded HTML tags to be processed. This is only useful when sending messages to mail clients that support HTML.
maxRows
Optional. Specifies the maximum number of e-mail messages to send.
MIMEAttach
Optional. Specifies the path of the file to be attached to the e-mail message. An attached file is MIME-encoded.
query
Optional. 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.
group
Optional. 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.
groupCaseSensitive
Optional. Boolean indicating whether to group with regard to case or not. The default value is YES; 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.
startRow
Optional. Specifies the row in the query to start from.
server
Required. The address of the SMTP server to use for sending messages. If no server is specified, the server name specified in the ColdFusion Administrator is used.
port
The TCP/IP port on which the SMTP server listens for requests. This is normally 25.
mailerID
Optional. Specifies a mailer ID to be passed in the X-Mailer SMTP header, which identifies the mailer application. The default is ColdFusion Application Server.
timeout
Optional. The number of seconds to wait before timing out the connection to the SMTP server.

Example

<!--- This view-only example shows the use of cfmail --->

<html>

<head>

<title>cfmail Example</title>

</head>

<body bgcolor = silver>

<H3>cfmail Example</H3>

<P>This view-only example shows the use of cfmail. If your CFAS mail 

settings are configured successfully and the comments are removed,

you will be able to use this code to send simple e-mail.

<!--- 

<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#">

      This message was sent by an

      automatic mailer built with cfmail:

      = = = = = = = = = = = = = = = = = = = = = = = = = = =

      = = = = = = = = = = = = = = = = = = = = = = = = = = =

      #form.body#

  </cfmail>  

  <H3>Thank you</H3>

  <P>Thank you, <cfoutput>#mailfrom#: your message, #subject#, has

  been sent to #mailto#</cfoutput>.

  </cfif>  

</cfif>

<P>

<form action = "cfmail.cfm" method = "POST">

<PRE>

TO:     <input type = "Text" name = "MailTo">

FROM:    <input type = "Text" name = "MailFrom">

SUBJECT:  <input type = "Text" name = "Subject">

<hr>

MESSAGE BODY:

<TEXTAREA name = "Body" COLS = "40" ROWS = "5" WRAP = "VIRTUAL"></TEXTAREA>

</PRE>

<!--- establish required fields --->

<input type = "hidden" name = "MailTo_required" value = "You must enter

a recipient for this message">

<input type = "hidden" name = "MailFrom_required" value = "You must

enter a sender for this message">

<input type = "hidden" name = "Subject_required" value = "You must enter

a subject for this message">

<input type = "hidden" name = "Body_required" value = "You must enter

some text for this message">

<P><input type = "Submit" name = "">

</form> --->

...



Banner.Novgorod.Ru