I am wondering if anyone out there has experience in sending out e-mails in ColdFusion and not using the cfmail
tag. I ask because I'd like to use a third-party service (PostMark) to send them but am unsure how to keep some of the aspects I really like about cfmail
, such as grouped queries, etc.
I can probably figure it out with a bit of work but was hoping someone else has done this so I don't have to reinvent the wheel.
Off the top of my head, I know it would involve:
- Correctly generating the headers and recipient from the query
- Creating the output from a grouped query (probably storing it using
cfsavecontent
?) - Looping through each of the generated emails and sending it to the API
Does that sound right?
Even better would be a fallback so that if for some reason the API is not available, the email still gets sent, but this time using SMTP.
And obviously the best possible scenario is wrapping all of this in a custom tag so that nearly the only thing I'd have to do is change cfmail
to cf_mail_special
or something.
The only real difficulty comes here:
<cfmail from="info@example.org" to="#email#" subject="Your widget #foo#" query="Recipients">
Built-in ColdFusion tags can have pound signs in them that aren't immediately evaluated, but they would be for my custom tag. So I guess I'd have to rewrite it
<cf_mail_special from="info@example.org" to="##email##" subject="Your widget ##foo##" query="Recipients">
And then run Evaluate
on it?