The Dopefly Tech Blog

<< The Dopefly Tech Blog Main page

Managing your application's emails

posted under category: General on April 3, 2009 at 2:00 am by MrNate

Here's a recurring problem I've discovered. Many, if not all, of my applications send email, and they tend to do it in an unmanaged, un-object oriented type of way. For instance, if you comment on this blog entry, I and other subscribers are sent an email. The template for this email is tucked away inside a CFC, right below where I insert the record into my database. This, of course, is a problem that can be solved in a repeatable, managed fashion.

I have actually solved this problem before at a previous company I worked at. Obviously all of that code is under lock and key, unusable due to NDAs and basically unethical anyway, so instead, I am planning on recreating something like it, but better, from scratch. Hey, if nothing else, I'll just use it on this blog. Of course I'm talking about open sourcing it - why would I tease readers with a cool toy, and not share it?

Overarching idea: A reusable open source library and API for both the management and sending of emails via templates.

Basic requirements:


Groupthink questions: Does anyone else do this? How do you solve it? Why have I not heard of anyone else doing it?

Final thoughts: Sending email from your application is a scenario that I see often, and can be handled by an administrative managed, reusable application. Move your email templates out of your code and reduce the complexity of your application.

Oh, and I don't have a name for it yet. I'd hate to call it the Email Template Manager or something stuffy and boring.

Too old to comment!
On Apr 5, 2009 at 2:00 AM Bob Silverberg (http://www.silverwareconsulting.com) said:
I think it's a great idea. The only reason I haven't done something like this is because it has always felt like the payback wouldn't be worth the effort.

I do have a component that I use for sending all of my emails, but that's all it does - send emails. I have to pass it the body text, which I generate prior to using the component.

The issue for me is that there is often a significant amount of logic required to build the body of an email, and that logic has to reside somewhere. So even with a template system I would have to write some code specific to the email, and if I'm doing that, I might as well just write the whole email (or so it seems at the time).

That's not to say that I don't think it's a good idea. It is - and is a nice way of solving a common problem. I have just never felt enough pain from writing and maintaining email content that I've been prompted to take the time to develop a solution.

On Feb 20, 2010 at 2:00 AM Barney Boisvert (bboisvert who really likes gmail.com) said:
At work, we do all our of our email templating via web requests to the site. So we have special pages that instead of generated browsable content, they generate email content. When we need to send an email, we hit the page with CFHTTP to get the content, and then do simple token replacement (${firstName}, ${productName}, etc.) to personalize it. This lets our content authors build emails in exactly the same way they build normal site pages, leveraging all the neat stuff our CMS provides (block reuse, versioning, automatic activation, approval workflow, etc.). It works really well.
Too old to comment!