0

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:

  1. Correctly generating the headers and recipient from the query
  2. Creating the output from a grouped query (probably storing it using cfsavecontent?)
  3. 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?

Jordan Reiter
  • 20,467
  • 11
  • 95
  • 161
  • My question would be why? What is the issue with CFMail that is forcing you to find an alternative? – Dave Ferguson Oct 11 '12 at 16:44
  • For a long time at my previous job, we used activmail, which seems to be defunct now. It handled all of our bulk mail just fine, but as cfmail became more reliable, we transitioned back. There's no real reason to need a third party solution anymore. – Joe C Oct 11 '12 at 18:15
  • @DaveFerguson Basically I have transactional e-mails that I need to know got through. Sometimes messages don't get spooled or don't get sent along by the SMTP server. This outsources all of that to a company that focuses exclusively on sending transactional e-mails (i.e. not bulk e-mails, mailing lists, or spam). Basically they do all the work of making sure an email gets to the recipient, including issues like automatically detecting bounces, etc. You can read about the service here: http://postmarkapp.com/why-postmark I'm not trying to sell it but someone I know was involved in the business. – Jordan Reiter Oct 11 '12 at 20:24
  • @barnyr has the right answer. Using the SMTP API allows you to continue to use CFMAIL but use a third party. You just need to pass some additional attributes. – baynezy Oct 12 '12 at 05:08

2 Answers2

1

You could use the PostMark SMTP API

Alternatively, there's a Java Library which you could probably make use of, possibly hiding behind your cf_mail_special tag?

barnyr
  • 5,678
  • 21
  • 28
  • Yeah, I saw that. Would be nice to know for sure that the mail went through. Unfortunately for us, mail spool is problematic pretty often. We're working on figuring it out. – Jordan Reiter Oct 12 '12 at 16:03
0

if you want to send messages without cfmail and smtp, you can also check out sendgrid.com and look at their api.

Also, depending on the type of server your running on, if your using a microsoft windows server, 2003 for example, you can create a file using cffile to write a text file into the mailroot pickup folder and it will bypass coldfusion's cfmail tag.

I've had a similar issue with CFMAIL having it lock up and having the spool folder just stockpile messages until restarting the java mail server or restarting the cf service. Been dealing with it since cf6.

I wrote a scheduled routine to check my spool folder every 10 minutes. It looks at the oldest file in the folder and if the file is 9 minutes or older, it sends me a text message to my cell phone through twillio, or I can have it restart the CF service.

I maybe see it once a month or 2, but it allows me to stay on top of it.

I havent found one true fix for this issue.

steve
  • 1,490
  • 10
  • 18
  • There's actually an easier automated fix for this that doesn't even involve restarting CF. Code here: http://pastebin.com/xdLe4CA2 – Jordan Reiter Oct 12 '12 at 16:02