- CFML Reference User Guide
- ColdFusion functions
- ColdFusion functions by category
- Functions a-b
- Abs
- ACos
- AddSOAPRequestHeader
- AddSOAPResponseHeader
- AjaxLink
- AjaxOnLoad
- ApplicationStop
- ArrayAppend
- ArrayAvg
- ArrayClear
- ArrayContains
- ArrayContainsNoCase
- ArrayDelete
- ArrayDeleteAt
- ArrayDeleteNoCase
- ArrayEach
- ArrayFilter
- ArrayFind
- ArrayFindAll
- ArrayFindAllNoCase
- ArrayFindNoCase
- ArrayInsertAt
- ArrayIsDefined
- ArrayIsEmpty
- ArrayLen
- ArrayMap
- ArrayMax
- ArrayMin
- ArrayNew
- ArrayPrepend
- ArrayReduce
- ArrayResize
- ArraySet
- ArraySetMetadata
- ArraySlice
- ArraySort
- ArraySum
- ArraySwap
- ArrayToList
- Asc
- ASin
- Atn
- AuthenticatedContext
- AuthenticatedUser
- BinaryDecode
- BinaryEncode
- BitAnd
- BitMaskClear
- BitMaskRead
- BitMaskSet
- BitNot
- BitOr
- BitSHLN
- BitSHRN
- BitXor
- BooleanFormat
- Abs
- Functions-c-d
- CacheGet
- CacheGetAllIds
- CacheGetMetadata
- CacheGetProperties
- CacheGetSession
- CacheIdExists
- CachePut
- CacheRegionExists
- CacheRegionNew
- CacheRegionRemove
- CacheRemove
- CacheRemoveAll
- CacheSetProperties
- CallStackDump
- CallStackGet
- CanDeSerialize
- Canonicalize
- CanSerialize
- Ceiling
- CharsetDecode
- CharsetEncode
- Chr
- CJustify
- Compare
- CompareNoCase
- Cos
- CreateDate
- CreateDateTime
- CreateObject
- CreateObject: .NET object
- CreateObject: COM object
- CreateObject: component object
- CreateObject: CORBA object
- CreateObject: Java or EJB object
- CreateObject: web service object
- CreateODBCDate
- CreateODBCDateTime
- CreateODBCTime
- CreateSignedJWT
- CreateEncryptedJWT
- CreateTime
- CreateTimeSpan
- CreateUUID
- CSRFGenerateToken
- CSRFVerifyToken
- CSVRead
- CSVWrite
- CSVProcess
- DateAdd
- DateCompare
- DateConvert
- DateDiff
- DateFormat
- DatePart
- DateTimeFormat
- Day
- DayOfWeek
- DayOfWeekAsString
- DayOfYear
- DaysInMonth
- DaysInYear
- DE
- DecimalFormat
- DecodeForHTML
- DecodeFromURL
- DecrementValue
- Decrypt
- DecryptBinary
- DeleteClientVariable
- Deserialize
- DeserializeJSON
- DeserializeXML
- DirectoryCopy
- DirectoryCreate
- DirectoryDelete
- DirectoryExists
- DirectoryList
- DirectoryRename
- DollarFormat
- DotNetToCFType
- Duplicate
- Functions-e-g
- EncodeForCSS
- EncodeForDN
- EncodeForHTML
- EncodeForHTMLAttribute
- EncodeForJavaScript
- EncodeForLDAP
- EncodeForURL
- EncodeForXML
- EncodeForXMLAttribute
- EncodeForXpath
- Encrypt
- EncryptBinary
- EntityDelete
- EntityLoad
- EntityLoadByExample
- EntityLoadByPK
- EntityMerge
- EntityNew
- EntityReload
- EntitySave
- EntityToQuery
- Evaluate
- Exp
- ExpandPath
- FileClose
- FileCopy
- FileDelete
- FileExists
- FileGetMimeType
- FileIsEOF
- FileMove
- FileOpen
- FileRead
- FileReadBinary
- FileReadLine
- FileSeek
- FileSetAccessMode
- FileSetAttribute
- FileSetLastModified
- FileSkipBytes
- FileUpload
- FileUploadAll
- FileWrite
- FileWriteLine
- Find
- FindNoCase
- FindOneOf
- FirstDayOfMonth
- Fix
- Floor
- FormatBaseN
- GeneratePBKDFKey
- GenerateSecretKey
- GetApplicationMetadata
- GetAuthUser
- GetBaseTagData
- GetBaseTagList
- GetBaseTemplatePath
- GetClientVariablesList
- GetComponentMetaData
- GetContextRoot
- GetCPUUsage
- GetCurrentTemplatePath
- GetCSPNonce
- GetDirectoryFromPath
- GetEncoding
- GetException
- GetFileFromPath
- GetFileInfo
- GetFreeSpace
- GetFunctionCalledName
- GetFunctionList
- GetGatewayHelper
- GetHttpRequestData
- GetHttpTimeString
- GetK2ServerDocCount
- GetK2ServerDocCountLimit
- GetLocale
- GetLocaleDisplayName
- GetLocalHostIP
- GetMetaData
- GetMetricData
- GetPageContext
- GetPropertyString
- GetPropertyFile
- GetPrinterInfo
- GetPrinterList
- GetProfileSections
- GetProfileString
- GetReadableImageFormats
- GetSafeHTML
- GetSAMLAuthRequest
- GetSAMLLogoutRequest
- Generate3DesKey
- GenerateSAMLSPMetadata
- GetSOAPRequest
- GetSOAPRequestHeader
- GetSOAPResponse
- GetSOAPResponseHeader
- GetSystemFreeMemory
- GetSystemTotalMemory
- GetTempDirectory
- GetTempFile
- GetTemplatePath
- GetTickCount
- GetTimeZoneInfo
- GetToken
- GetTotalSpace
- GetUserRoles
- GetVFSMetaData
- GetWriteableImageFormats
- Functions-h-im
- Hash
- HMac
- Hour
- HQLMethods
- HTMLCodeFormat
- HTMLEditFormat
- IIf
- ImageAddBorder
- ImageBlur
- ImageClearRect
- ImageCopy
- ImageCreateCaptcha
- ImageCrop
- ImageDrawArc
- ImageDrawBeveledRect
- ImageDrawCubicCurve
- ImageDrawLine
- ImageDrawLines
- ImageDrawOval
- ImageDrawPoint
- ImageDrawQuadraticCurve
- ImageDrawRect
- ImageDrawRoundRect
- ImageDrawText
- ImageFlip
- ImageGetBlob
- ImageGetBufferedImage
- ImageGetEXIFMetadata
- ImageGetEXIFTag
- ImageGetHeight
- ImageGetIPTCMetadata
- ImageGetIPTCTag
- ImageGetMetadata
- ImageGetWidth
- ImageGrayscale
- ImageInfo
- ImageMakeColorTransparent
- ImageMakeTranslucent
- ImageNegative
- ImageNew
- ImageOverlay
- ImagePaste
- ImageRead
- ImageReadBase64
- ImageResize
- ImageRotate
- ImageRotateDrawingAxis
- ImageScaleToFit
- ImageSetAntialiasing
- ImageSetBackgroundColor
- ImageSetDrawingColor
- ImageSetDrawingStroke
- ImageSetDrawingTransparency
- ImageSharpen
- ImageShear
- ImageShearDrawingAxis
- ImageTranslate
- ImageTranslateDrawingAxis
- ImageWrite
- ImageWriteBase64
- ImageXORDrawingMode
- Functions-in-k
- IncrementValue
- InputBaseN
- Insert
- Int
- InterruptThread
- InvalidateOauthAccesstoken
- Invoke
- InitSAMLAuthRequest
- InitSAMLLogoutRequest
- InvokeCFClientFunction
- IsArray
- IsAuthenticated
- IsAuthorized
- IsBinary
- IsBoolean
- IsClosure
- IsCustomFunction
- IsDate
- IsDateObject
- IsDDX
- IsDebugMode
- IsDefined
- IsImage
- IsImageFile
- IsInstanceOf
- IsIPv6
- IsJSON
- IsK2ServerABroker
- IsK2ServerDocCountExceeded
- IsK2ServerOnline
- IsLeapYear
- IsLocalHost
- IsNull
- IsNumeric
- IsNumericDate
- IsObject
- isOnline
- IsPDFArchive
- IsPDFFile
- IsPDFObject
- IsProtected
- IsQuery
- isSamlLogoutResponse
- isSafeHTML
- IsSimpleValue
- IsSOAPRequest
- IsSpreadsheetFile
- IsSpreadsheetObject
- IsStruct
- isThreadInterrupted
- IsUserInAnyRole
- IsUserInRole
- IsUserLoggedIn
- IsValid
- IsValidOauthAccesstoken
- IsWDDX
- IsXML
- IsXmlAttribute
- IsXmlDoc
- IsXmlElem
- IsXmlNode
- IsXmlRoot
- JavaCast
- JSStringFormat
- Functions-l
- LCase
- Left
- Len
- ListAppend
- ListChangeDelims
- ListContains
- ListContainsNoCase
- ListDeleteAt
- ListEach
- ListFilter
- ListFind
- ListFindNoCase
- ListFirst
- ListGetAt
- ListGetDuplicates
- ListInsertAt
- ListLast
- ListLen
- ListMap
- ListPrepend
- ListQualify
- ListReduce
- ListRemoveDuplicates
- ListRest
- ListSetAt
- ListSort
- ListToArray
- ListValueCount
- ListValueCountNoCase
- LJustify
- Location
- Log
- Log10
- LSCurrencyFormat
- LSDateFormat
- LSDateTimeFormat
- LSEuroCurrencyFormat
- LSIsCurrency
- LSIsDate
- LSIsNumeric
- LSNumberFormat
- LSParseCurrency
- LSParseDateTime
- LSParseEuroCurrency
- LSParseNumber
- LSTimeFormat
- LTrim
- Functions-m-r
- Max
- Mid
- Min
- Minute
- Month
- MonthAsString
- Now
- NumberFormat
- ObjectEquals
- ObjectLoad
- ObjectSave
- OnWSAuthenticate
- ORMClearSession
- ORMCloseAllSessions
- ORMCloseSession
- ORMEvictCollection
- ORMEvictEntity
- ORMEvictQueries
- ORMExecuteQuery
- ORMFlush
- ORMFlushall
- ORMGetSession
- ORMGetSessionFactory
- ORMIndex
- ORMIndexPurge
- ORMReload
- ORMSearch
- ORMSearchOffline
- ParagraphFormat
- ParameterExists
- ParseDateTime
- Pi
- PrecisionEvaluate
- ProcessSAMLResponse
- ProcessSAMLLogoutRequest
- Quarter
- PreserveSingleQuotes
- QueryAddColumn
- QueryAddRow
- QueryConvertForGrid
- QueryExecute
- QueryFilter
- QueryGetResult
- QueryGetRow
- QueryKeyExists
- QueryMap
- QueryNew
- QueryReduce
- QuerySetCell
- QuotedValueList
- QueryEach
- Rand
- Randomize
- RandRange
- ReEscape
- REFind
- REFindNoCase
- ReleaseComObject
- REMatch
- REMatchNoCase
- RemoveCachedQuery
- RemoveChars
- RepeatString
- Replace
- ReplaceList
- ReplaceNoCase
- REReplace
- REReplaceNoCase
- RestDeleteApplication
- RestSetResponse
- RestInitApplication
- Reverse
- Right
- RJustify
- Round
- RTrim
- Functions-s
- Second
- SendGatewayMessage
- SendSAMLLogoutResponse
- Serialize
- SerializeJSON
- SerializeXML
- SessionInvalidate
- SessionRotate
- SessionGetMetaData
- SessionInvalidate
- SessionRotate
- SetDay
- SetEncoding
- SetHour
- SetLocale
- SetMonth
- SetProfileString
- SetPropertyString
- SetVariable
- SetYear
- Sgn
- Sin
- Sleep
- SpanExcluding
- SpanIncluding
- SpreadsheetAddAutoFilter
- SpreadsheetAddColumn
- SpreadsheetAddFreezePane
- SpreadsheetAddImage
- SpreadsheetAddInfo
- SpreadsheetAddPageBreaks
- SpreadsheetAddRow
- SpreadsheetAddRows
- SpreadsheetAddSplitPane
- SpreadsheetCreateSheet
- SpreadsheetDeleteColumn
- SpreadsheetDeleteColumns
- SpreadsheetDeleteRow
- SpreadsheetDeleteRows
- SpreadsheetFormatCell
- SpreadsheetFormatColumn
- SpreadsheetFormatCellRange
- SpreadsheetFormatColumn
- SpreadsheetFormatColumns
- SpreadsheetFormatRow
- SpreadsheetFormatRows
- SpreadsheetGetCellComment
- SpreadsheetGetCellFormula
- SpreadsheetGetCellValue
- SpreadsheetGetColumnCount
- SpreadsheetInfo
- SpreadsheetMergeCells
- SpreadsheetNew
- SpreadsheetRead
- SpreadsheetReadBinary
- SpreadsheetRemoveSheet
- SpreadsheetSetActiveSheet
- SpreadsheetSetActiveSheetNumber
- SpreadsheetSetCellComment
- SpreadsheetSetCellFormula
- SpreadsheetSetCellValue
- SpreadsheetSetColumnWidth
- SpreadsheetSetFooter
- SpreadsheetSetHeader
- SpreadsheetSetRowHeight
- SpreadsheetShiftColumns
- SpreadsheetShiftRows
- SpreadsheetWrite
- StreamingSpreadsheetNew
- StreamingSpreadsheetCleanup
- StreamingSpreadsheetRead
- StreamingSpreadsheetProcess
- SpreadsheetSetFooterImage
- SpreadsheetSetHeaderImage
- SpreadsheetSetFittoPage
- SpreadsheetUngroupColumns
- SpreadsheetGroupColumns
- SpreadsheetUngroupRows
- SpreadsheetGroupRows
- SpreadsheetRemoveColumnBreak
- SpreadsheetSetColumnBreak
- SpreadsheetRemoveRowBreak
- SpreadsheetSetRowBreak
- SpreadsheetRemovePrintGridlines
- SpreadsheetAddPrintGridlines
- SpreadsheetGetColumnWidth
- SpreadsheetSetColumnHidden
- SpreadsheetSetRowHidden
- SpreadsheetisColumnHidden
- SpreadsheetisRowHidden
- SpreadsheetisStreamingXmlFormat
- SpreadsheetisXmlFormat
- SpreadsheetisBinaryFormat
- SpreadsheetRenameSheet
- SpreadsheetRemoveSheetNumber
- SpreadsheetGetLastRowNumber
- SpreadsheetGetPrintOrientation
- Sqr
- StripCR
- StructAppend
- StructClear
- StructCopy
- StructCount
- StructDelete
- StructEach
- StructFilter
- StructFind
- StructFindKey
- StructFindValue
- StructGet
- StructGetMetadata
- StructInsert
- StructIsEmpty
- StructKeyArray
- StructKeyExists
- StructKeyList
- StructMap
- StructNew
- StructReduce
- StructSetMetadata
- StructSort
- StructToSorted
- StructUpdate
- StructValueArray
- StoreSetMetadata
- StoreGetACL
- StoreGetMetadata
- StoreAddACL
- StoreSetACL
- Functions-t-z
- Tan
- ThreadJoin
- ThreadTerminate
- Throw
- TimeFormat
- ToBase64
- ToBinary
- ToScript
- ToString
- Trace
- Transactionandconcurrency
- TransactionCommit
- TransactionRollback
- TransactionSetSavePoint
- Trim
- UCase
- URLDecode
- URLEncodedFormat
- URLSessionFormat
- Val
- ValueList
- VerifyClient
- Week
- Wrap
- WriteDump
- WriteLog
- WriteOutput
- WSGetAllChannels
- WSGetSubscribers
- WSPublish
- WSSendMessage
- XmlChildPos
- XmlElemNew
- XmlFormat
- XmlGetNodeType
- XmlNew
- XmlParse
- XmlSearch
- XmlTransform
- XmlValidate
- Year
- YesNoFormat
- ColdFusion tags
- ColdFusion tag summary
- ColdFusion tags by category
- Application framework tags
- Communications tags
- Database manipulation tags
- Data output tags
- Debugging tags
- Exception handling tags
- Extensibility tags
- File management tags
- Flow-control tags
- Forms tags
- Internet Protocol tags
- Page processing tags
- Security tags
- Variable manipulation tags
- Other tags
- Tags a-b
- Tags c
- cfcache
- cfcalendar
- cfcase
- cfcatch
- cfchart
- cfchart tag in ColdFusion
- Get started with cfchart
- Customize a chart using cfchart
- Advanced cfchart customization options
- Create an area chart in ColdFusion
- Create line charts in ColdFusion
- Create bar charts in ColdFusion
- Create floating bar charts in ColdFusion
- Create histograms in ColdFusion
- Create pie charts in ColdFusion
- Create funnel charts in ColdFusion
- Create pyramid charts in ColdFusion
- Create curve charts in ColdFusion
- Create boxplots in ColdFusion
- Create donut charts in ColdFusion
- Create bubble charts in ColdFusion
- Create scatterplots in ColdFusion
- Create radar charts in ColdFusion
- Other chart types in ColdFusion (Cone, Cylinder, Piano, and Bullet)
- Advanced customization options in cfchart
- cfchartdata
- cfchartseries
- cfchartset
- cfclient
- cfclientsettings
- cfcol
- cfcollection
- cfcomponent
- cfcontent
- cfcontinue
- cfcookie
- Tags f
- cffeed
- cffile
- cffile action = "append"
- cffile action = "copy"
- cffile action = "delete"
- cffile action = "move"
- cffile action = "read"
- cffile action = "readBinary"
- cffile action = "rename"
- cffile action = "upload"
- cffile action = "uploadAll"
- cffile action = "write"
- cffileupload
- cffinally
- cfflush
- cfform
- cfformgroup
- cfformitem
- cfftp
- cfftp: Connection: file and directory operations
- cfftp: Opening and closing FTP server connections
- cfftp : Opening and closing secure FTP server connections
- cfftp action = "listDir"
- cffunction
- Tags g-h
- Tags i
- Tags j-l
- cfjava
- cflayout
- cflayoutarea
- cfldap
- cflocation
- cflock
- cflog
- cflogin
- cfloginuser
- cflogout
- cfloop
- cfloop : conditional loop
- cfloop : index loop
- cfloop : looping over a COM collection or structure
- cfloop : looping over a date or time range
- cfloop : looping over a list, a file, or an array
- cfloop : looping over a query
- Tags m-o
- cfmail
- cfmailparam
- cfmailpart
- cfmap
- cfmapitem
- cfmediaplayer
- cfmenu
- cfmenuitem
- cfmessagebox
- cfmodule
- cfNTauthenticate
- cfoauth
- cfobject
- cfobject: .NET object
- cfobject: COM object
- cfobject: component object
- cfobject: CORBA object
- cfobject: Java or EJB object
- cfobject: web service object
- cfobjectcache
- cfoutput
- Tags p-q
- Tags r-s
- Tags t
- Tags u-z
- CFML Reference
- Reserved words and variables
- Ajax JavaScript functions
- Ajax JavaScript functions
- Function summary Ajax
- ColdFusion.Ajax.submitForm
- ColdFusion.Autosuggest.getAutosuggestObject
- ColdFusion.Layout.enableSourceBind
- ColdFusion.MessageBox.getMessageBoxObject
- ColdFusion.ProgressBar.getProgressBarObject
- ColdFusion.MessageBox.isMessageBoxDefined
- JavaScriptFunctionsinColdFusion9Update1
- ColdFusion ActionScript functions
- ColdFusion mobile functions
- Application.cfc reference
- Script functions implemented as CFCs
- ColdFusion Flash Form style reference
- Styles valid for all controls
- Styles for cfform
- Styles for cfformgroup with horizontal or vertical type attributes
- Styles for box-style cfformgroup elements
- Styles for cfformgroup with accordion type attribute
- Styles for cfformgroup with tabnavigator type attribute
- Styles for cfformitem with hrule or vrule type attributes
- Styles for cfinput with radio, checkbox, button, image, or submit type attributes
- Styles for cftextarea tag and cfinput with text, password, or hidden type attributes
- Styles for cfselect with size attribute value of 1
- Styles for cfselect with size attribute value greater than 1
- Styles for cfcalendar tag and cfinput with dateField type attribute
- Styles for the cfgrid tag
- Styles for the cftree tag
- ColdFusion Flash Form Style Reference
- ColdFusion event gateway reference
- ColdFusion Event Gateway reference
- addEvent
- CFEvent
- CFEventclass
- Constructor
- Gateway development interfaces and classes
- getStatus
- setCFCPath
- setCFCMethod
- getOriginatorID
- getLogger
- getBuddyList
- getBuddyInfo
- IM gateway message sending commands
- IM Gateway GatewayHelper class methods
- onIncomingMessage
- onIMServerMessage
- onBuddyStatus
- onAddBuddyResponse
- onAddBuddyRequest
- IM Gateway CFC incoming message methods
- IM gateway methods and commands
- CFML CFEvent structure
- warn
- info
- setOriginatorID
- data command
- submit Multi command
- submit command
- setGatewayType
- setGatewayID
- setData
- setCFCListeners
- outgoingMessage
- getStatusTimeStamp
- numberOfMessagesReceived
- numberOfMessagesSent
- removeBuddy
- removeDeny
- removePermit
- setNickName
- setPermitMode
- setStatus
- SMS Gateway CFEvent structure and commands
- SMS Gateway incoming message CFEvent structure
- getStatusAsString
- getProtocolName
- getPermitMode
- getPermitList
- getNickName
- getName
- getDenyList
- getCustomAwayMessage
- getQueueSize
- getMaxQueueSize
- getHelper
- getGatewayType
- getGatewayServices
- getGatewayID_1
- getGatewayID
- getData
- getCFCTimeout
- setCFCTimeout
- getCFCPath
- getCFCMethod
- GatewayServices class
- Gateway interface
- GatewayHelper interface
- addPermit
- addDeny
- addBuddy
- error
- debug
- Logger class
- stop
- start
- CFML event gateway SendGatewayMessage data parameter
- restart
- fatal
- SMS gateway message sending commands
- ColdFusion C++ CFX Reference
- ColdFusion Java CFX reference
- WDDX JavaScript Objects
- Cloud services
- ColdFusion and GCP Storage
- ColdFusion and GCP Firestore
- ColdFusion and GCP PubSub
- ColdFusion and Amazon S3
- ColdFusion and DynamoDB
- ColdFusion and Amazon SQS
- ColdFusion and Amazon SNS
- ColdFusion and MongoDB
- ColdFusion and Azure Blob
- ColdFusion and Azure Service Bus
- Multi-cloud storage services
- Multi-cloud RDS databases
- ColdFusion and Azure Cosmos DB
Description
Sends an e-mail message that optionally contains query output, using an SMTP server.
Category
Syntax
<cfmail from = "e-mail address" to = "comma-delimited list" bcc = "comma-delimited list" cc = "comma-delimited list" charset = "character encoding" debug = "yes|no" failto = "e-mail address" group = "query column" groupcasesensitive = "yes|no" idnaversion="IDNA encoding" mailerid = "header id" maxrows = "integer" mimeattach = "path" password = "string" port = "integer" priority = "integer or string priority level" query = "query name" remove = "yes|no" replyto = "e-mail address" server = "SMTP server address" spoolenable = "yes|no" startrow = "query row number" subject = "string" timeout = "number of seconds" type = "mime type" username = "SMTP user ID" useSSL = "yes|no" useTLS = "yes|no" wraptext = "column number" sign = "true|false" keystore = "location of keystore" keystorepassword = "password of keystore" keyalias = "alias of key" keypassword = "password for private key" encrypt "true|false" recipientcert = <path to the public key cert> encryptionalgorithm = "DES_EDE3_CBC, RC2_CBC, AES128_CBC, AES192_CBC, AES256_CBC"> (Optional) Mail message body and/or cfmailparam tags </cfmail>
You can specify this tag's attributes in an attributeCollection attribute whose value is a structure. Specify the structure name in the attributeCollection attribute and use the tag's attribute names as structure keys.
See also
cfmailparam, cfmailpart, cfpop, cfftp, cfhttp, cfldap, Wrap; Using ColdFusion with mail servers in Sending and Receiving E-Mail in the Developing ColdFusion Applications
History
ColdFusion (2018 release): Added the attribute idnaversion.
ColdFusion 11: Added the attributes, encrypt, recipientcert , and encryptionalgorithm .
ColdFusion 8.0.1: Added the attribute Remove.
ColdFusion 8: Added priority, useSSL, and useTLS attributes.
ColdFusion MX 7:
- The cfmail tag no longer lets you send multipart mail by embedding the entire MIME-encoded message in the tag body. Use the cfmailpart tag, instead.
- The cfmail tag renders non-proportional fonts proportionately. This is a behavior change from ColdFusion 5. ColdFusion MX 7 uses UTF-8 and sends this in the mail header (Content-Type: text/plain; charset=UTF-8). ColdFusion 5 uses ISO-8859-1 (Latin 1). To avoid this behavior, add the charset= " ISO-8859-1" attribute to restore the default ColdFusion 5 encoding. Alternatively, you can change the encoding on the Mail page in the ColdFusion Administrator.
ColdFusion MX 6.1: - Added the following attributes: charset, failto , replyto , username, password and wraptext .
- Added support for multiple mail servers in the server attribute.
- Added several configuration options to the ColdFusion Administrator Mail Settings page.
ColdFusion MX: Added the SpoolEnable attribute.ColdFusion 9: Added support for digitally signing the mail. The following are the relevant attributes that are newly added: sign, keystore , keystorepassword , keyalias , keypassword and remove.
Attributes
Attribute |
Req/Opt |
Default |
Description |
|---|---|---|---|
bcc |
Optional |
|
Addresses to which to copy the message, without listing them in the message header. To specify multiple addresses, separate the addresses with commas. |
cc |
Optional |
|
Addresses to which to copy the message. To specify multiple addresses, separate the address with commas. |
charset |
Optional |
Character encoding selected in ColdFusion Administrator Mail page; utf-8 |
Character encoding of the mail message, including the headers. The following list includes commonly used values:
|
debug |
Optional |
no |
|
failto |
Optional |
|
Address to which mailing systems must send delivery failure notifications. Sets the mail envelope reverse-path value. |
from |
Required |
|
E-mail message sender:
|
to |
Required |
|
Message recipient e-mail addresses:
|
subject |
Required |
|
Message subject. Can be dynamically generated. For example, to send messages that give customers status updates: "Status of Order Number #Order_ID#". |
group |
Optional |
CurrentRow |
Query column to use when you group sets of records to send as a message. For example, to send a set of billing statements to a customer, group on "Customer_ID." Case-sensitive. Eliminates adjacent duplicates when data is sorted by the specified field. |
groupcasesensitive |
Optional |
No |
Boolean. Whether to consider case when using the group attribute. To group on case-sensitive records, set this attribute to Yes. |
| idnaversion | Optional | 2008 | Choose the IDNA encoding to be applied. If no IDNAversion attribute is specified, then the encoding specified in the JVM flag will be applied. If idnaversion is specified, then the respective encoding will be applied. |
keyalias |
Optional |
|
Alias of the key with which the certificate and private key are stored in the keystore. If it is not specified, the first entry in the keystore is chosen as the alias. |
keypassword |
Optional |
|
Password for your private key. If not specified, the keystorepassword is used. |
keystore |
Optional |
|
The location of the keystore file, for example, C:\OpenSSL\bin\keystore.jks. |
keystorepassword |
Optional |
|
The password of the keystore. This is stored in ColdFusion configuration files. |
mailerid |
Optional |
ColdFusion Application Server |
Mailer ID to be passed in X-Mailer SMTP header, which identifies the mailer application. |
maxrows |
Optional |
|
Maximum number of messages to send when looping over a query. |
mimeattach |
Optional |
|
Path of the on-disk or in-memory file to attach to message. Attached file is MIME-encoded. ColdFusion attempts to determine the MIME type of the file; use the cfmailparam tag to send an attachment and specify the MIME type. |
password |
Optional |
|
A password to send to SMTP servers that require authentication. Requires a username attribute. |
port |
Optional |
|
TCP/IP port on which SMTP server listens for requests (normally 25). A value here overrides the Administrator. |
priority |
Optional |
3 |
The message priority level. Can be one of the following values:
|
query |
Optional |
|
Name of cfquery from which to draw data for messages. Use this attribute to send more than one message, or to send query results within a message. |
remove |
Optional |
no |
If yes, ColdFusion removes attachment files (if any) after the mail is successfully delivered. |
replyto |
Optional |
|
Addresses to which the recipient is directed to send replies. |
server |
Optional |
|
SMTP server address, or (Enterprise edition only) a comma-delimited list of server addresses, to use for sending messages. At least one server must be specified here or in the ColdFusion Administrator. A value here overrides the Administrator. A value that includes a port specification overrides the port attribute. For details, see Usage. |
sign |
|
|
Digitally signs the mail. If set to true, all messages that you send will have digital signature. |
spoolenable |
Optional |
|
Whether to spool mail or always send it Immediately. Overrides the ColdFusion Administrator Spool mail messages to disk for delivery setting.
|
startrow |
Optional |
1 |
Row in a query to start from. |
timeout |
Optional |
|
Number of seconds to wait before timing out connection to SMTP server. A value here overrides the Administrator. |
type |
Optional |
text/plain |
MIME type of the message. Can be a valid MIME media type or one of the following:
|
username |
Optional |
|
A user name to send to SMTP servers that require authentication. Requires a password attribute. |
useSSL |
Optional |
|
Whether to use Secure Sockets Layer. |
useTLS |
Optional |
|
Whether to use Transport Level Security. |
wraptext |
Optional |
Do not wrap text |
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. |
| encrypt | Optional | false | If the Email should be encrypted. |
| recipientcert | Optional | false | The path to the public key certificate of the recipient. |
| encryptionalgorithm | Optional | The encryption algorithm to use. The valid algorithms are:
The encryption support is provided through S/MIME. |
Usage
Sends a mail message to the specified address. Mail messages can include attachments. The tag body can include CFML code to generate mail output. The cfmailparam and cfmailpart tags can only be used in the cfmail tag body. Mail messages can be single or multipart. If you send a multi-part mail message, all message content must be in cfmailpart tags; ColdFusion ignores multipart message text that is not in cfmailpart tags.
The cfmail tag does not make copies of attachments when spooling mail to disk. If you use the cfmail tag to send a message with an attachment with spooling enabled and you use the cffile tag to delete the attachment file, ColdFusion might not send the mail because the mailing process might execute after the file was deleted. (When this happens, the mail log includes a FileNotFound exception and the e-mail is not sent.) You can prevent this problem by setting SpoolEnable="No" in the attribute or disabling spooling in the ColdFusion Administrator. Disabling spooling causes the e-mail to be delivered immediately.
If you set type="text", sometimes whitespace might be compressed in the messages that you send. To resolve this, in the ColdFusion Administrator, go to Server Settings > Settings and then deselect the option Enable Whitespace Management.
Mail addressing
Mail addresses can have any of the following forms:
Format |
Example |
|---|---|
user (server)company.com |
|
<user@server> |
<rsmith@company.com> |
DisplayName <user@server> |
Rob Smith <rsmith@company.com> |
"DisplayName" <user@server> |
"Rob Smith" <rsmith@company.com> |
user@server (DisplayName) |
rsmith@company.com (Rob Smith) |
Specifying mail servers
The server attribute can specify one or more mail servers.
If you specify multiple mail servers in ColdFusion Standard, the cfmail tag uses only the first server in the specification. ColdFusion logs a warning message to the mail log file and ignores the additional servers.
For each server, you can optionally specify a user name, password, and port. These values override the corresponding attributes, if any. The server attribute has the following format:
[user:password@]server[:port],[user:password@]server[:port],....
For example, the following line specifies one server, mail.myco.com that uses the default port and no user or password, and a second server with a user, password, and specific port:
server=mail.myco.com,mail_admin:adm2qzf@mail2.myco.com:24
When you specify multiple mail servers in ColdFusion Enterprise, ColdFusion tries the available servers in the order they are listed until it connects to a server. ColdFusion does not try to connect to a server that was unavailable in the last 60 seconds.
Digital Signature
To add digital signature to your mail, specify the attributes sign, keystore, keystorepassword, keyalias, and keypassword as provided in the following example:
<cfmail from="Sender@Company.com" server="sendmail.myCo.com" sign="true" keystore="C:\OpenSSL\bin\hello.jks" keystorepassword="digital" to="Recepient@Company.com" keyalias="crypto" keypassword="signature" subject="Mail with Digital Signature">
To add digital signature to all the mails you send, instead of adding the attributes to the tag, specify the settings in the Server Settings > Settings page of the ColdFusion Administrator.
If you do not specify the attributes in the tag, the Administrator settings are applied. Also, in the tag, if you set sign = "true" and do not specify the attributes keystore, keystorepassword, keyalias, and keypassword, then the values for these attributes specified using ColdFusion Administrator are applied.
Example
<h3>cfmail Example</h3>
<!--- Delete the surrounding comments to use this example.
<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>.</p>
</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">
<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">
<p><input type = "Submit" name = ""></p>
</p>
</form>
In ColdFusion 11, you can encrypt your mails using the following procedure:
- Get the certificate of the user for whom you wanted to send the mail (.p7c format).
- Specify the path to the generated certificate for the recipientcert attribute. For instance:
<cfmail ... encrypt="true" ENCRYPTIONALGORITHM = "DES_EDE3_CBC" recipientcert="#path#cert.p7c" >
- Configure the mail server from your ColdFusion Administrator.
- Download the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files from the Oracle website for the JRE version that ColdFusion is configured with (if you are using an encryption algorithm whose key size is greater than 128).
- Send the mail. See the following example.
<cfset path = GetDirectoryFromPath(getCurrentTemplatePath())> <cfset algorithms = "DES_EDE3_CBC,RC2_CBC,AES128_CBC,AES192_CBC,AES256_CBC"> <cfloop index="algo" list="#algorithms#"> <cfmail to="joe@work.com" from="bob@work.com" subject="Sending a mail with the encryption algo : #algo#" sign ="false" encrypt="true" ENCRYPTIONALGORITHM = "#algo#" recipientcert="#path#cert.p7c" > This message is encrypted using the algorithm : #algo#. </cfmail> </cfloop>
Example using attribute idnaversion
<cfprocessingdirective pageencoding="utf-8">
<cfmail to="sample@example.com"
from="test@example.com"
username="username"
password="password"
server="localhost"
subject="hello"
debug="true"
idnaversion="2003">
Hello World !
</cfmail>
Real-world uses of the cfmail tag
Welcome mail- new user registration
Your web application has a user registration system where new users sign up with their email address and create an account. Upon successful registration, you need to send a professional welcome email that confirms their account creation, provides their username, includes helpful getting-started information, and encourages engagement with your platform.
Problem statement
- New users need immediate confirmation of registration
- Must send professional, branded welcome emails
- Include user-specific information (name, username, account details)
- Provide next steps and helpful resources
- Encourage user engagement from day one
- Track email delivery for user support
Solution
Use cfmail to send personalized HTML welcome emails.
<cfscript>
// Simulate new user registration (in production, this comes from form/database)
newUser = {
firstName: "John",
lastName: "Smith",
email: "john.smith@example.com",
username: "jsmith",
registrationDate: now(),
accountType: "Premium"
};
// Configuration
fromEmail = "welcome@mycompany.com";
fromName = "MyCompany Team";
companyName = "MyCompany";
websiteURL = "https://www.mycompany.com";
loginURL = "https://www.mycompany.com/login";
// Flag to control email sending (set to true to actually send)
sendEmail = isDefined("url.send") AND url.send EQ "true";
</cfscript>
<h2>📧 Welcome Email System</h2>
<!--- Display User Information --->
<div style="background: ##e3f2fd; border: 2px solid ##2196f3; padding: 20px; margin: 20px 0; border-radius: 5px;">
<h3 style="margin-top: 0;">New User Registration</h3>
<cfoutput>
<p><strong>Name:</strong> #newUser.firstName# #newUser.lastName#</p>
<p><strong>Email:</strong> #newUser.email#</p>
<p><strong>Username:</strong> #newUser.username#</p>
<p><strong>Account Type:</strong> #newUser.accountType#</p>
<p><strong>Registration Date:</strong> #dateTimeFormat(newUser.registrationDate, "yyyy-mm-dd HH:nn:ss")#</p>
</cfoutput>
</div>
<!--- Send Welcome Email --->
<cfif sendEmail>
<cftry>
<!--- Send HTML Welcome Email --->
<cfmail
to="#newUser.email#"
from="#fromEmail#"
subject="Welcome to #companyName#, #newUser.firstName#!"
type="html"
server="localhost"
port="25">
<!--- HTML Email Content --->
<html>
<head>
<style>
body { font-family: Arial, sans-serif; line-height: 1.6; color: ##333; }
.container { max-width: 600px; margin: 0 auto; }
.header { background: ##2196f3; color: white; padding: 30px; text-align: center; }
.content { padding: 30px; background: ##f9f9f9; }
.button { display: inline-block; padding: 15px 30px; background: ##4caf50; color: white; text-decoration: none; border-radius: 5px; margin: 20px 0; }
.info-box { background: ##e3f2fd; padding: 15px; border-left: 4px solid ##2196f3; margin: 20px 0; }
.footer { background: ##333; color: white; padding: 20px; text-align: center; font-size: 12px; }
</style>
</head>
<body>
<cfoutput>
<div class="container">
<!--- Header --->
<div class="header">
<h1 style="margin: 0;">Welcome to #companyName#!</h1>
<p style="margin: 10px 0 0 0;">We're excited to have you on board</p>
</div>
<!--- Content --->
<div class="content">
<h2>Hello #newUser.firstName#,</h2>
<p>Thank you for creating your #companyName# account! Your registration was successful and you're all set to get started.</p>
<!--- Account Details --->
<div class="info-box">
<h3 style="margin-top: 0;">Your Account Details</h3>
<p><strong>Username:</strong> #newUser.username#</p>
<p><strong>Email:</strong> #newUser.email#</p>
<p><strong>Account Type:</strong> #newUser.accountType#</p>
<p><strong>Registration Date:</strong> #dateFormat(newUser.registrationDate, "mmmm d, yyyy")#</p>
</div>
<!--- Getting Started --->
<h3>Getting Started</h3>
<p>Here are some things you can do right away:</p>
<ul>
<li>Complete your profile</li>
<li>Explore our features</li>
<li>Connect with other users</li>
<li>Check out our help center</li>
</ul>
<!--- Call to Action --->
<div style="text-align: center;">
<a href="#loginURL#" class="button">Log In to Your Account</a>
</div>
<!--- Support Info --->
<p>If you have any questions, our support team is here to help. Just reply to this email or visit our help center.</p>
<p>Best regards,<br>
<strong>The #companyName# Team</strong></p>
</div>
<!--- Footer --->
<div class="footer">
<p>© #year(now())# #companyName#. All rights reserved.</p>
<p>#websiteURL#</p>
<p>This email was sent to #newUser.email# because you registered for an account.</p>
</div>
</div>
</cfoutput>
</body>
</html>
</cfmail>
<!--- Success Message --->
<div style="background: ##e8f5e9; border: 2px solid ##4caf50; padding: 20px; margin: 20px 0; border-radius: 5px;">
<h3 style="color: green; margin-top: 0;">✓ Welcome Email Sent Successfully!</h3>
<cfoutput>
<p><strong>Recipient:</strong> #newUser.email#</p>
<p><strong>Subject:</strong> Welcome to #companyName#, #newUser.firstName#!</p>
<p><strong>Sent:</strong> #dateTimeFormat(now(), "yyyy-mm-dd HH:nn:ss")#</p>
</cfoutput>
</div>
<!--- Log email activity (in production, save to database) --->
<cflog
file="email_activity"
type="information"
text="Welcome email sent to #newUser.email# (User: #newUser.username#)">
<cfcatch type="any">
<!--- Error Handling --->
<div style="background: ##ffebee; border: 2px solid ##f44336; padding: 20px; margin: 20px 0; border-radius: 5px;">
<h3 style="color: red; margin-top: 0;">✗ Email Sending Failed</h3>
<p><strong>Error:</strong> #cfcatch.message#</p>
<p><strong>Detail:</strong> #cfcatch.detail#</p>
<p><strong>Type:</strong> #cfcatch.type#</p>
</div>
<!--- Log error --->
<cflog
file="email_errors"
type="error"
text="Failed to send welcome email to #newUser.email#: #cfcatch.message#">
</cfcatch>
</cftry>
<cfelse>
<!--- Email Preview --->
<div style="background: ##fff3e0; border: 2px solid ##ff9800; padding: 20px; margin: 20px 0; border-radius: 5px;">
<h3 style="margin-top: 0;">Email Preview Mode</h3>
<p>Email is ready to send but not sent yet. Click "Send Email" below to actually send.</p>
<p><a href="?send=true" style="padding: 12px 30px; background: ##4caf50; color: white; text-decoration: none; border-radius: 5px; display: inline-block; margin-top: 10px;">
Send Welcome Email
</a></p>
</div>
</cfif>
<!--- Email Content Preview --->
<h3>Email Content Preview</h3>
<div style="background: white; border: 2px solid ##ddd; padding: 20px; margin: 20px 0; border-radius: 5px;">
<!--- Header --->
<div style="background: ##2196f3; color: white; padding: 30px; text-align: center; border-radius: 5px 5px 0 0;">
<cfoutput>
<h1 style="margin: 0;">Welcome to #companyName#!</h1>
<p style="margin: 10px 0 0 0;">We're excited to have you on board</p>
</cfoutput>
</div>
<!--- Content --->
<div style="padding: 30px; background: ##f9f9f9;">
<cfoutput>
<h2>Hello #newUser.firstName#,</h2>
<p>Thank you for creating your #companyName# account! Your registration was successful and you're all set to get started.</p>
<div style="background: ##e3f2fd; padding: 15px; border-left: 4px solid ##2196f3; margin: 20px 0;">
<h3 style="margin-top: 0;">Your Account Details</h3>
<p><strong>Username:</strong> #newUser.username#</p>
<p><strong>Email:</strong> #newUser.email#</p>
<p><strong>Account Type:</strong> #newUser.accountType#</p>
</div>
<h3>Getting Started</h3>
<ul>
<li>Complete your profile</li>
<li>Explore our features</li>
<li>Connect with other users</li>
</ul>
<div style="text-align: center; margin: 30px 0;">
<a href="#loginURL#" style="display: inline-block; padding: 15px 30px; background: ##4caf50; color: white; text-decoration: none; border-radius: 5px;">
Log In to Your Account
</a>
</div>
<p>Best regards,<br>
<strong>The #companyName# Team</strong></p>
</cfoutput>
</div>
<!--- Footer --->
<div style="background: ##333; color: white; padding: 20px; text-align: center; font-size: 12px; border-radius: 0 0 5px 5px;">
<cfoutput>
<p>© #year(now())# #companyName#. All rights reserved.</p>
</cfoutput>
</div>
</div>
Password reset system
Your application needs a secure password reset mechanism where users can request a password reset via email. The system must generate a unique, time-limited token, send a secure reset link via email, and allow users to create a new password without compromising security.
Problem statement
- Users forget passwords and need secure reset mechanism
- Must prevent unauthorized password resets
- Generate unique, time-limited reset tokens
- Send secure reset links via email
- Token should expire after set time (e.g., 24 hours)
Solution
Use cfmail to send password reset emails with secure tokens.
<cfscript>
// Simulate password reset request
userEmail = "john.smith@example.com";
userName = "John Smith";
// Generate secure reset token (in production, use more secure method)
resetToken = createUUID();
tokenExpiration = dateAdd("h", 24, now()); // Token expires in 24 hours
// Configuration
fromEmail = "security@mycompany.com";
companyName = "MyCompany";
resetURL = "https://www.mycompany.com/reset-password?token=" & resetToken;
// In production: Store token in database with user ID and expiration
// INSERT INTO password_resets (user_email, token, expires_at, created_at)
sendEmail = isDefined("url.send") AND url.send EQ "true";
</cfscript>
<h2>🔐 Password Reset System</h2>
<div style="background: ##fff3e0; border: 2px solid ##ff9800; padding: 20px; margin: 20px 0; border-radius: 5px;">
<h3 style="margin-top: 0;">Password Reset Request</h3>
<cfoutput>
<p><strong>Email:</strong> #userEmail#</p>
<p><strong>User:</strong> #userName#</p>
<p><strong>Reset Token:</strong> <code style="background: white; padding: 5px;">#resetToken#</code></p>
<p><strong>Token Expires:</strong> #dateTimeFormat(tokenExpiration, "yyyy-mm-dd HH:nn:ss")#
(in #dateDiff("h", now(), tokenExpiration)# hours)</p>
</cfoutput>
</div>
<cfif sendEmail>
<cftry>
<!--- Send Password Reset Email --->
<cfmail
to="#userEmail#"
from="#fromEmail#"
subject="Password Reset Request - #companyName#"
type="html">
<html>
<head>
<style>
body { font-family: Arial, sans-serif; line-height: 1.6; color: ##333; }
.container { max-width: 600px; margin: 0 auto; background: ##f9f9f9; }
.header { background: ##ff9800; color: white; padding: 30px; text-align: center; }
.content { padding: 30px; background: white; }
.button { display: inline-block; padding: 15px 30px; background: ##4caf50; color: white; text-decoration: none; border-radius: 5px; margin: 20px 0; font-weight: bold; }
.warning { background: ##ffebee; border-left: 4px solid ##f44336; padding: 15px; margin: 20px 0; }
.info { background: ##e3f2fd; border-left: 4px solid ##2196f3; padding: 15px; margin: 20px 0; }
.footer { background: ##333; color: ##999; padding: 20px; text-align: center; font-size: 12px; }
</style>
</head>
<body>
<cfoutput>
<div class="container">
<div class="header">
<h1 style="margin: 0;">🔐 Password Reset Request</h1>
</div>
<div class="content">
<h2>Hello #userName#,</h2>
<p>We received a request to reset your password for your #companyName# account.</p>
<p>Click the button below to reset your password:</p>
<div style="text-align: center;">
<a href="#resetURL#" class="button">Reset Your Password</a>
</div>
<div class="info">
<p style="margin: 0;"><strong>ℹ️ Important Information:</strong></p>
<ul style="margin: 10px 0;">
<li>This link will expire in <strong>24 hours</strong></li>
<li>The link can only be used once</li>
<li>Your current password will remain active until you set a new one</li>
</ul>
</div>
<p>If the button doesn't work, copy and paste this link into your browser:</p>
<p style="background: ##f5f5f5; padding: 10px; word-break: break-all; font-size: 12px;">
#resetURL#
</p>
<div class="warning">
<p style="margin: 0;"><strong>⚠️ Security Warning:</strong></p>
<ul style="margin: 10px 0;">
<li>If you didn't request this reset, please ignore this email</li>
<li>Your password will not change unless you click the link</li>
<li>Never share this link with anyone</li>
<li>Contact support if you have concerns about your account security</li>
</ul>
</div>
<p>Best regards,<br>
<strong>#companyName# Security Team</strong></p>
</div>
<div class="footer">
<p>This is an automated security email from #companyName#.</p>
<p>Request Time: #dateTimeFormat(now(), "yyyy-mm-dd HH:nn:ss")# UTC</p>
</div>
</div>
</cfoutput>
</body>
</html>
</cfmail>
<div style="background: ##e8f5e9; border: 2px solid ##4caf50; padding: 20px; margin: 20px 0; border-radius: 5px;">
<h3 style="color: green; margin-top: 0;">✓ Password Reset Email Sent!</h3>
<cfoutput>
<p><strong>Sent to:</strong> #userEmail#</p>
<p><strong>Token:</strong> #resetToken#</p>
<p><strong>Expires:</strong> #dateTimeFormat(tokenExpiration, "yyyy-mm-dd HH:nn:ss")#</p>
</cfoutput>
</div>
<cflog file="password_resets" type="information"
text="Password reset email sent to #userEmail# - Token: #resetToken#">
<cfcatch type="any">
<div style="background: ##ffebee; border: 2px solid ##f44336; padding: 20px; margin: 20px 0; border-radius: 5px;">
<h3 style="color: red; margin-top: 0;">✗ Failed to Send Reset Email</h3>
<p><strong>Error:</strong> #cfcatch.message#</p>
</div>
<cflog file="email_errors" type="error"
text="Failed password reset email to #userEmail#: #cfcatch.message#">
</cfcatch>
</cftry>
<cfelse>
<p><a href="?send=true" style="padding: 12px 30px; background: ##ff9800; color: white; text-decoration: none; border-radius: 5px; display: inline-block;">
Send Password Reset Email
</a></p>
</cfif>
Order confirmation receipt
Your e-commerce platform processes customer orders and needs to send professional order confirmation emails immediately after purchase. The email must include complete order details, itemized list with prices, shipping information, payment summary, and order tracking capabilities.
Problem statement
- Customers need immediate order confirmation
- Must include all order details (items, quantities, prices)
- Show shipping address and estimated delivery
- Include payment information (last 4 digits)
- Provide order tracking number
- Support email receipts for accounting
Solution
Use cfmail with HTML formatting and cfmailparam for attachments to send detailed order confirmations with all purchase information formatted professionally.
<!---
Use Case 3: Order Confirmation Receipt
This demonstrates sending order confirmation emails with details
--->
<cfscript>
// Simulate order data
order = {
orderID: "ORD-2024-0001234",
orderDate: now(),
customerName: "John Smith",
customerEmail: "john.smith@example.com",
shippingAddress: "123 Main Street, Boston, MA 02101",
trackingNumber: "1Z999AA10123456784",
items: [
{name: "Wireless Mouse", quantity: 2, unitPrice: 29.99, total: 59.98},
{name: "USB-C Cable (6ft)", quantity: 3, unitPrice: 12.99, total: 38.97},
{name: "Laptop Stand", quantity: 1, unitPrice: 49.99, total: 49.99}
],
subtotal: 148.94,
tax: 11.92,
shipping: 8.99,
total: 169.85,
paymentMethod: "Visa ending in 4242"
};
sendEmail = isDefined("url.send") AND url.send EQ "true";
</cfscript>
<h2>📦 Order Confirmation System</h2>
<!--- Display Order Information --->
<div style="background: ##e3f2fd; border: 2px solid ##2196f3; padding: 20px; margin: 20px 0; border-radius: 5px;">
<h3 style="margin-top: 0;">Order Information</h3>
<cfoutput>
<p><strong>Order ID:</strong> #order.orderID#</p>
<p><strong>Customer:</strong> #order.customerName#</p>
<p><strong>Email:</strong> #order.customerEmail#</p>
<p><strong>Order Date:</strong> #dateTimeFormat(order.orderDate, "yyyy-mm-dd HH:nn:ss")#</p>
<p><strong>Total Amount:</strong> <span style="font-size: 24px; color: ##4caf50; font-weight: bold;">$#numberFormat(order.total, "0.00")#</span></p>
</cfoutput>
</div>
<!--- Order Items Table --->
<h3>Order Items</h3>
<table style="width: 100%; border-collapse: collapse; margin: 20px 0; background: white;">
<thead>
<tr style="background: ##2196f3; color: white;">
<th style="padding: 12px; text-align: left;">Item</th>
<th style="padding: 12px; text-align: center;">Quantity</th>
<th style="padding: 12px; text-align: right;">Unit Price</th>
<th style="padding: 12px; text-align: right;">Total</th>
</tr>
</thead>
<tbody>
<cfloop array="#order.items#" index="item">
<cfoutput>
<tr>
<td style="padding: 10px; border: 1px solid ##ddd;">#item.name#</td>
<td style="padding: 10px; border: 1px solid ##ddd; text-align: center;">#item.quantity#</td>
<td style="padding: 10px; border: 1px solid ##ddd; text-align: right;">$#numberFormat(item.unitPrice, "0.00")#</td>
<td style="padding: 10px; border: 1px solid ##ddd; text-align: right; font-weight: bold;">$#numberFormat(item.total, "0.00")#</td>
</tr>
</cfoutput>
</cfloop>
</tbody>
<tfoot>
<cfoutput>
<tr>
<td colspan="3" style="padding: 10px; border: 1px solid ##ddd; text-align: right;"><strong>Subtotal:</strong></td>
<td style="padding: 10px; border: 1px solid ##ddd; text-align: right;">$#numberFormat(order.subtotal, "0.00")#</td>
</tr>
<tr>
<td colspan="3" style="padding: 10px; border: 1px solid ##ddd; text-align: right;"><strong>Tax:</strong></td>
<td style="padding: 10px; border: 1px solid ##ddd; text-align: right;">$#numberFormat(order.tax, "0.00")#</td>
</tr>
<tr>
<td colspan="3" style="padding: 10px; border: 1px solid ##ddd; text-align: right;"><strong>Shipping:</strong></td>
<td style="padding: 10px; border: 1px solid ##ddd; text-align: right;">$#numberFormat(order.shipping, "0.00")#</td>
</tr>
<tr style="background: ##f5f5f5;">
<td colspan="3" style="padding: 15px; border: 1px solid ##ddd; text-align: right; font-size: 18px;"><strong>TOTAL:</strong></td>
<td style="padding: 15px; border: 1px solid ##ddd; text-align: right; font-size: 18px; color: ##4caf50; font-weight: bold;">$#numberFormat(order.total, "0.00")#</td>
</tr>
</cfoutput>
</tfoot>
</table>
<!--- Shipping Information --->
<div style="background: white; border: 1px solid ##ddd; padding: 20px; margin: 20px 0; border-radius: 5px;">
<h3 style="margin-top: 0;">Shipping & Payment</h3>
<cfoutput>
<p><strong>Shipping Address:</strong><br>#order.shippingAddress#</p>
<p><strong>Tracking Number:</strong> #order.trackingNumber#</p>
<p><strong>Payment Method:</strong> #order.paymentMethod#</p>
</cfoutput>
</div>
<cfif sendEmail>
<cftry>
<cfmail
to="#order.customerEmail#"
from="orders@mycompany.com"
subject="Order Confirmation - #order.orderID#"
type="html">
<html>
<body style="font-family: Arial; margin: 0; padding: 20px; background: ##f5f5f5;">
<cfoutput>
<div style="max-width: 600px; margin: 0 auto; background: white;">
<div style="background: ##4caf50; color: white; padding: 30px; text-align: center;">
<h1 style="margin: 0;">✓ Order Confirmed!</h1>
<p style="margin: 10px 0 0 0;">Thank you for your purchase</p>
</div>
<div style="padding: 30px;">
<p>Hi #order.customerName#,</p>
<p>Your order has been confirmed and will be shipped soon.</p>
<div style="background: ##e3f2fd; padding: 15px; margin: 20px 0;">
<p style="margin: 0;"><strong>Order Number:</strong> #order.orderID#</p>
<p style="margin: 5px 0 0 0;"><strong>Order Date:</strong> #dateFormat(order.orderDate, "mmmm d, yyyy")#</p>
</div>
<h3>Order Details</h3>
<table style="width: 100%; border-collapse: collapse;">
<thead>
<tr style="background: ##f5f5f5;">
<th style="padding: 10px; text-align: left; border-bottom: 2px solid ##ddd;">Item</th>
<th style="padding: 10px; text-align: center; border-bottom: 2px solid ##ddd;">Qty</th>
<th style="padding: 10px; text-align: right; border-bottom: 2px solid ##ddd;">Price</th>
<th style="padding: 10px; text-align: right; border-bottom: 2px solid ##ddd;">Total</th>
</tr>
</thead>
<tbody>
<cfloop array="#order.items#" index="item">
<tr>
<td style="padding: 10px; border-bottom: 1px solid ##eee;">#item.name#</td>
<td style="padding: 10px; text-align: center; border-bottom: 1px solid ##eee;">#item.quantity#</td>
<td style="padding: 10px; text-align: right; border-bottom: 1px solid ##eee;">$#numberFormat(item.unitPrice, "0.00")#</td>
<td style="padding: 10px; text-align: right; border-bottom: 1px solid ##eee;">$#numberFormat(item.total, "0.00")#</td>
</tr>
</cfloop>
</tbody>
<tfoot>
<tr>
<td colspan="3" style="padding: 10px; text-align: right;">Subtotal:</td>
<td style="padding: 10px; text-align: right;">$#numberFormat(order.subtotal, "0.00")#</td>
</tr>
<tr>
<td colspan="3" style="padding: 10px; text-align: right;">Tax:</td>
<td style="padding: 10px; text-align: right;">$#numberFormat(order.tax, "0.00")#</td>
</tr>
<tr>
<td colspan="3" style="padding: 10px; text-align: right;">Shipping:</td>
<td style="padding: 10px; text-align: right;">$#numberFormat(order.shipping, "0.00")#</td>
</tr>
<tr style="background: ##f5f5f5; font-weight: bold; font-size: 16px;">
<td colspan="3" style="padding: 15px; text-align: right;">TOTAL:</td>
<td style="padding: 15px; text-align: right;">$#numberFormat(order.total, "0.00")#</td>
</tr>
</tfoot>
</table>
<h3>Shipping Information</h3>
<p><strong>Delivery Address:</strong><br>#order.shippingAddress#</p>
<p><strong>Tracking Number:</strong> #order.trackingNumber#</p>
<h3>Payment Method</h3>
<p>#order.paymentMethod#</p>
<div style="text-align: center; margin: 30px 0;">
<a href="https://www.mycompany.com/track?order=#order.orderID#" style="display: inline-block; padding: 15px 30px; background: ##2196f3; color: white; text-decoration: none; border-radius: 5px;">
Track Your Order
</a>
</div>
<p>Questions? Contact us at support@mycompany.com</p>
</div>
</div>
</cfoutput>
</body>
</html>
</cfmail>
<div style="background: ##e8f5e9; border: 2px solid ##4caf50; padding: 20px; margin: 20px 0; border-radius: 5px;">
<h3 style="color: green; margin-top: 0;">✓ Order Confirmation Email Sent!</h3>
<cfoutput>
<p><strong>Sent to:</strong> #order.customerEmail#</p>
<p><strong>Subject:</strong> Order Confirmation - #order.orderID#</p>
<p><strong>Sent at:</strong> #dateTimeFormat(now(), "yyyy-mm-dd HH:nn:ss")#</p>
</cfoutput>
</div>
<cflog file="order_emails" type="information"
text="Order confirmation sent: #order.orderID# to #order.customerEmail#">
<cfcatch type="any">
<div style="background: ##ffebee; border: 2px solid ##f44336; padding: 20px; margin: 20px 0; border-radius: 5px;">
<h3 style="color: red; margin-top: 0;">✗ Email Sending Failed</h3>
<p><strong>Error:</strong> #cfcatch.message#</p>
<p><strong>Detail:</strong> #cfcatch.detail#</p>
</div>
<cflog file="email_errors" type="error"
text="Failed to send order confirmation for #order.orderID#: #cfcatch.message#">
</cfcatch>
</cftry>
<cfelse>
<!--- Send Email Button --->
<div style="background: ##fff3e0; border: 2px solid ##ff9800; padding: 20px; margin: 20px 0; border-radius: 5px; text-align: center;">
<h3 style="margin-top: 0;">Ready to Send Email</h3>
<p>Click the button below to send the order confirmation email to the customer.</p>
<a href="?send=true" style="padding: 15px 40px; background: ##4caf50; color: white; text-decoration: none; border-radius: 5px; display: inline-block; font-size: 16px; font-weight: bold;">
📧 Send Order Confirmation Email
</a>
</div>
</cfif>
<!--- Email Preview --->
<h3>📧 Email Preview</h3>
<div style="background: ##f5f5f5; padding: 20px; border-radius: 5px;">
<p style="color: ##666; margin-bottom: 15px;">This is how the email will appear to the customer:</p>
<!--- Email Preview Container --->
<div style="max-width: 600px; margin: 0 auto; background: white; border: 2px solid ##ddd; box-shadow: 0 2px 5px rgba(0,0,0,0.1);">
<div style="background: ##4caf50; color: white; padding: 30px; text-align: center;">
<h1 style="margin: 0;">✓ Order Confirmed!</h1>
<p style="margin: 10px 0 0 0;">Thank you for your purchase</p>
</div>
<div style="padding: 30px;">
<cfoutput>
<p>Hi #order.customerName#,</p>
<p>Your order has been confirmed and will be shipped soon.</p>
<div style="background: ##e3f2fd; padding: 15px; margin: 20px 0; border-radius: 3px;">
<p style="margin: 0;"><strong>Order Number:</strong> #order.orderID#</p>
<p style="margin: 5px 0 0 0;"><strong>Order Date:</strong> #dateFormat(order.orderDate, "mmmm d, yyyy")#</p>
</div>
<h3>Order Details</h3>
<table style="width: 100%; border-collapse: collapse;">
<thead>
<tr style="background: ##f5f5f5;">
<th style="padding: 10px; text-align: left; border-bottom: 2px solid ##ddd;">Item</th>
<th style="padding: 10px; text-align: center; border-bottom: 2px solid ##ddd;">Qty</th>
<th style="padding: 10px; text-align: right; border-bottom: 2px solid ##ddd;">Price</th>
<th style="padding: 10px; text-align: right; border-bottom: 2px solid ##ddd;">Total</th>
</tr>
</thead>
<tbody>
<cfloop array="#order.items#" index="item">
<tr>
<td style="padding: 10px; border-bottom: 1px solid ##eee;">#item.name#</td>
<td style="padding: 10px; text-align: center; border-bottom: 1px solid ##eee;">#item.quantity#</td>
<td style="padding: 10px; text-align: right; border-bottom: 1px solid ##eee;">$#numberFormat(item.unitPrice, "0.00")#</td>
<td style="padding: 10px; text-align: right; border-bottom: 1px solid ##eee;">$#numberFormat(item.total, "0.00")#</td>
</tr>
</cfloop>
</tbody>
<tfoot>
<tr>
<td colspan="3" style="padding: 10px; text-align: right;">Subtotal:</td>
<td style="padding: 10px; text-align: right;">$#numberFormat(order.subtotal, "0.00")#</td>
</tr>
<tr>
<td colspan="3" style="padding: 10px; text-align: right;">Tax:</td>
<td style="padding: 10px; text-align: right;">$#numberFormat(order.tax, "0.00")#</td>
</tr>
<tr>
<td colspan="3" style="padding: 10px; text-align: right;">Shipping:</td>
<td style="padding: 10px; text-align: right;">$#numberFormat(order.shipping, "0.00")#</td>
</tr>
<tr style="background: ##f5f5f5; font-weight: bold; font-size: 16px;">
<td colspan="3" style="padding: 15px; text-align: right;">TOTAL:</td>
<td style="padding: 15px; text-align: right; color: ##4caf50;">$#numberFormat(order.total, "0.00")#</td>
</tr>
</tfoot>
</table>
<h3>Shipping Information</h3>
<p><strong>Delivery Address:</strong><br>#order.shippingAddress#</p>
<p><strong>Tracking Number:</strong> #order.trackingNumber#</p>
<h3>Payment Method</h3>
<p>#order.paymentMethod#</p>
<div style="text-align: center; margin: 30px 0;">
<a href="https://www.mycompany.com/track?order=#order.orderID#" style="display: inline-block; padding: 15px 30px; background: ##2196f3; color: white; text-decoration: none; border-radius: 5px;">
Track Your Order
</a>
</div>
<p>Questions? Contact us at support@mycompany.com</p>
</cfoutput>
</div>
</div>
</div>
<div style="background: ##e3f2fd; border-left: 4px solid ##2196f3; padding: 15px; margin: 20px 0;">
<h4>💡 Order Confirmation Best Practices:</h4>
<ul>
<li><strong>Immediate Send:</strong> Send confirmation immediately after order placement</li>
<li><strong>Complete Details:</strong> Include all order items, prices, and totals</li>
<li><strong>Tracking Info:</strong> Provide tracking numbers when available</li>
<li><strong>PDF Attachment:</strong> Attach PDF invoice using cfmailparam</li>
<li><strong>Payment Security:</strong> Show only last 4 digits of payment method</li>
<li><strong>Clear Layout:</strong> Use tables for itemized lists</li>
<li><strong>Action Links:</strong> Include track order and view order buttons</li>
<li><strong>Contact Info:</strong> Provide customer service contact details</li>
</ul>
</div>