Zrinity is the leader in enterprise-class email marketing
management solutions and content management solutions for marketing professionals and developers worldwide.
The following code will send an email to bob@jones.com, fred@jones.com, and buddy@jones.com
<CF_MAIL
TO="bob@jones.com,fred@jones.com,buddy@jones.com"
FROM="Billy Jones <billy@jones.com>"
SUBJECT="Billy's got a new cow">
Hi, just wanted to announce that I've got a new cow!
</CF_MAIL>
The next example selects email addresses from a query, and dynamically makes the TO list using CF's ValueList() function. This example will also send a multi-part message, because both TEXTMESSAGE and HTMLMESSAGE is specified. This will also generate a verbose logfile with the date in the filename.
<cfquery name="qry" datasource="ds">
SELECT email, name
FROM farmers
</cfquery>
<CF_MAIL
QUERY="qry"
FROM="Billy Jones <billy@jones.com>"
TO="email"
SUBJECT="Hey %name% I got a new cow"
VERBOSE="1"
TOKENS="1"
TYPE="HTML"
TEXTMESSAGE="Hi %name%, just wanted to announce that I've got a new cow.">
Hi %name%, just wanted to announce that <b>I've got a new cow</b>.
</CF_MAIL>
The following QUERY could be used to generate an address that looks like First Last <email@address.com> with fields in a database named FirstName, LastName, and Email. Using this format recipients will see their name in the TO box of the message, instead of just the email address.
<cfquery name="qry" datasource="ds">
SET CONCAT_NULL_YIELDS_NULL OFF
SELECT firstname + ' ' + lastname + ' <' + email + '>' AS Email
FROM users
</cfquery>
Note: SET CONCAT_NULL_YIELDS_NULL OFF is used to prevent SQL Server from making the result of the concatenation NULL if any of the fields are null. If your name, and email address fields do not allow nulls then you may remove that line. If your email address field allows NULL's and you are concatenating with a name, you should add an extra statement to the where clause that removes null addresses (eg WHERE email <> ''). The above example was designed for SQL Server, if you are running other servers check your database server's documentation.
Add your SMTP username and password to the SERVER attribute using the pattern user:password@server:port
<CF_MAIL
TO="bob@jones.com,fred@jones.com,buddy@jones.com"
FROM="Billy Jones <billy@jones.com>"
SERVER="billy:password@mail.server.com"
SUBJECT="Billy's got a new cow">
Hi, just wanted to announce that I've got a new cow!
</CF_MAIL>
Add a comma seperated list of mail servers in the SERVER attribute using the pattern user:password@server:port user password and port are optional
<CF_MAIL
TO="bob@jones.com,fred@jones.com,buddy@jones.com"
FROM="Billy Jones <billy@jones.com>"
SERVER="smtp1.server.com,billy:password@smtp2.server.com, smtp3.server.com:2525,billy:pwd@smtp4.server.com:25"
SUBJECT="Billy's got a new cow">
Hi, just wanted to announce that I've got a new cow!
</CF_MAIL>
You want to send rich text email that can be read by AOL 6.0 users
<CF_MAIL
TO="bob@jones.com,fred@jones.com,buddy@jones.com"
FROM="Billy Jones <billy@jones.com>"
TYPE="html"
TEXTMESSAGE="I got a new cow"
SUBJECT="Billy's got a new cow">