Downloads

Download ColdFusion CFMAIL Test Harness Script

cfmail Test Harness

Mode: #encodeForHtml(mode)#. Use responsibly.









SMTP Overrides (optional)







Advanced









// Collect inputs
p = {
to = safe(form.to), from = safe(form.from), subject = safe(form.subject),
body = form.body, html = structKeyExists(form,”html”),
cc = safe(form.cc), bcc = safe(form.bcc), replyTo = safe(form.replyTo),
server = safe(form.server), port = safe(form.port),
username = safe(form.username), password = safe(form.password),
useTLS = structKeyExists(form,”useTLS”), useSSL = structKeyExists(form,”useSSL”),
attachments = safe(form.attachments), headers = form.headers,
rateMs = val(form.rateMs), mode = safe(form.mode)
};

// Safety: prevent sending to large distribution lists accidentally
if (listLen(p.to) > 5 and p.mode eq “prod”) {
throw(type=”HarnessSafety”, message=”Too many recipients in prod mode.”);
}

// Send the message
start = getTickCount();


<cfmail to="#p.to#" from="#p.from#" subject="#p.subject#" charset="utf-8" type="#iif(p.html,'html','text')#" server=”#p.server#”
port=”#p.port#”
username=”#p.username#”
password=”#p.password#”
useTLS=”true”
useSSL=”true”
cc=”#p.cc#”
bcc=”#p.bcc#”
replyto=”#p.replyTo#”
>
#preserveSingleQuotes(p.body)#

























logLine = serializeJSON({
timestamp = dateTimeFormat(now(), “yyyy-mm-dd HH:nn:ss”),
to = p.to, from = p.from, subject = p.subject, status = status, elapsedMs = elapsed,
server = p.server, port = p.port, tls = p.useTLS, ssl = p.useSSL, mode = p.mode
}) & chr(10);
fileWrite(logFile, logLine, true);

Result: #encodeForHtml(status)# (elapsed: #elapsed# ms)

Log file: #logFile#


See also  Download ColdFusion PDF Generation Examples (CFDOCUMENT)

About the author

Aaron Longnion

Aaron Longnion

Hey there! I'm Aaron Longnion — an Internet technologist, web software engineer, and ColdFusion expert with more than 24 years of experience. Over the years, I've had the privilege of working with some of the most exciting and fast-growing companies out there, including lynda.com, HomeAway, landsofamerica.com (CoStar Group), and Adobe.com.

I'm a full-stack developer at heart, but what really drives me is designing and building internet architectures that are highly scalable, cost-effective, and fault-tolerant — solutions built to handle rapid growth and stay ahead of the curve.