cfmailparam

Attaches a file or adds a header to an e-mail message. Can only
be used in the cfmail tag. You can use more than one
cfmailparam tag within a cfmail tag.

  <cfmailparam>

 cfmailparam();

Attribute Reference

file string

Attaches file to a message. Mutually exclusive with name
attribute. The file is MIME encoded before sending.

type string

The MIME media type of the part. Can be a can be valid MIME
media type
Values:
  • text/plain
  • text/html
  • html
  • plain
  • text

name string

Name of header. Case-insensitive. Mutually exclusive with
file attribute.
The values listed are from rfc2822
Values:
  • Message-Context
  • Apparently-To
  • Approved-By
  • Fax
  • Telefax
  • For-Approval
  • For-Comment
  • For-Handling
  • Mail-System-Version
  • Mailer
  • Originating-Client
  • X-Mailer
  • X-Newsreader
  • X-MimeOLE
  • User-Agent
  • Originator-Info
  • Phone
  • X-Envelope-From
  • Envelope-To
  • X-Envelope-To
  • X-Face
  • X-RCPT-TO
  • X-Sender
  • X-X-Sender
  • Posted-To
  • X-Admin
  • Errors-To
  • Return-Receipt-To
  • Read-Receipt-To
  • X-Confirm-reading-to
  • Return-Receipt-Requested
  • Register-Mail-Reply-Requested-By
  • Abuse-Reports-To
  • X-Complaints-To
  • X-Report-Abuse-To
  • Content-Alias
  • Delivered-To
  • X-Loop
  • Translated-By
  • Translation-Of
  • X-UIDL
  • X-URI
  • X-URL
  • X-IMAP
  • X-OriginalArrivalTime
  • Precedence
  • X-MSMail-Priority
  • X-Priority
  • Content-Length
  • Content-Conversion
  • Content-Class
  • Content-SGML-Entity
  • X-MIME-Autoconverted
  • List-Digest
  • Mailing-List
  • X-Mailing-List
  • List-Software
  • List-URL
  • X-Listserver
  • X-List-Host
  • Fcc
  • Speech-Act
  • Status
  • X-No-Archive

value string

Value of the header.

contentID string

The Identifier for the attached file. This ID should
be globally unique and is used to identify the file in
an IMG or other tag in the mail body that references
the file content.

disposition string
Default: attachment

How the attached file is to be handled. Can be one
of the following:
- attachment: present the file as an attachment
- inline: display the file contents in the message
Values:
  • attachment
  • inline

content string

Lets you send the contents of a
ColdFusion variable as an attachment

remove boolean

Tells ColdFusion to remove any attachments after successful mail delivery.

filename string

CF 2016+ Lucee 5.1.0.17+ The file name of the attachment as seen by the recipient.

Examples
Sample code using the cfmailparam tag

The SMTP server details are provided through the Administrator. This example attaches a file. Use the full path of the file.

<cfmail to="recipient@example.com" from="sender@example.com" subject="Example email">
  <cfmailparam file="/#attachment#">
  Your Email Message!!
</cfmail>

The SMTP server details are provided through the Administrator. This example attaches a file. Use the full path of the file. Set the MIME type of the file by using the optional type parameter.

<cfmail to="recipient@example.com" from="sender@example.com" subject="Example email">
  <cfmailparam file="/#attachment#" type="text/plain">
  Your Email Message!!
</cfmail>

The SMTP server details are provided through the Administrator. This example sets an optional X-Header. Check with your email server or service provider to find out what headers are supported.

<cfmail to="recipient@example.com" from="sender@example.com" subject="Example email">
  <cfmailparam name="X-Priority" value="#priority#">
  Your Email Message!!
</cfmail>

The SMTP server details are provided through the Administrator. This example attaches a file using cfscript. Use the full path of the file.

cfmail(
 to="recipient@example.com",
 from="sender@example.com",
 subject="Example email"
 ) {
 cfmailparam( file="/#attachment#" )
 writeOutput( "Your Email Message!!") 
 };

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub