CFMAIL
Easily send MIME and PLAIN type emails
Usage
<cfmail> ... </cfmail>
Attributes
Attribute | default | required | summary |
---|---|---|---|
ATTRIBUTECOLLECTION | A structure containing the tag attributes | ||
TO | ![]() |
The email address to send the email to. Multiple emails delimited by ; or ,. If using a query, this is the column name where the TO field is | |
CC | The email address to cc send the email. Multiple emails delimited by ; or ,. If using a query, this is the column name where the CC field is | ||
BCC | The email address to bcc send the email. Multiple emails delimited by ; or ,. If using a query, this is the column name where the BCC field is | ||
REPLYTO | The email address for the REPLYTO field | ||
FAILTO | The email address for the Return-Path field | ||
SUBJECT | ![]() |
The subject of the email | |
MAILERID | OpenBD | The X-MAILER value | |
TYPE | plain | The type of email to send. HTML or PLAIN | |
STARTROW | 0 | If using a query, then this is the start of the row | |
MAXROWS | -all- | If using a query, then this is the maximum rows to send | |
QUERY | The query object containing the data. For each row, an email will be generated | ||
GROUP | If using a query, then this is the GROUP'ing of the query | ||
GROUPCASESENSITIVE | false | If using a query, this is the GROUP sensitivity | |
USESSL | false | Set to true to send using SSL | |
USETLS | false | Set to true to send using TLS | |
TIMEOUT | How long to wait for the MTA to respond before returning an error | ||
MIMEATTACH | Attach a file to this email, using the file path | ||
WRAPTEXT | -do not- | The number of columns to wrap the text to if using TYPE=PLAIN | |
SERVER | The server list of MTA agents to deliver the email to. Can be in format: [user:password@]server[:port],[user:password@]server2[:port] | ||
CHARSET | The character set to use for this email | ||
PRIORITY | The priority value in the range 1-5 to use for this email | ||
CALLBACK | The name of the CFC that will have onMailSuccess/onMailFail callbacks | ||
CALLBACKDATA | A string that will be passed on through to the callback functions; can be any string |
Extra
Using the callback feature lets you get a handle on when email gets delivered successfully or if it fails.
<cfmail to="alan@fail.com" from="info@alan.com" subject="this is a subject" callback="mycallback"> My Test Email </cfmail>
Create a CFC called 'mycallback'. Within this callback, you do not have access to the 'form', 'url' or 'cgi' scopes, but you do have 'application'.
<cfcomponent> <cffunction name="onMailSend"> <cfargument name="to" type="array"/> <cfargument name="from" /> <cfargument name="subject" /> <cfargument name="messageid" /> <cfargument name="mailserver" /> <cfargument name="customdata" /> </cffunction> <cffunction name="onMailFail"> <cfargument name="to" type="array" /> <cfargument name="from" /> <cfargument name="subject" /> <cfargument name="messageid" /> <cfargument name="mailserver" /> <cfargument name="customdata" /> <cfargument name="error" /> <cfargument name="file" hint="full path to the failed file" /> </cffunction> </cfcomponent>
For more information on the sending features of OpenBD please refer to the OpenBD Engine Mail page.
Using CFMAIL with Google Mail (GMail)
<cfmail to="tosomeone@mail.com" from="yourmail@gmail.com" subject="test" server="smtp.gmail.com" useSSL="true" port="465" username="yourmail@gmail.com" password="yourgmailpassword"> Test </cfmail>