Create Text & Online Versions of Emails Automatically
django-firstclass, a proxy email backend for Django that automatically creates plain text versions and online-viewable emails.
For this I’ve created django-firstclass. Firstclass is a proxy email backend for Django that allows for global email transformations such as automatically creating a plain text version of html emails or automatically creating an online version of the email that can be read in browser.
My goal was to have this be a drop in solution requiring no change to a code base. I also wanted this to be flexible enough so that it can work with a wide variety of projects. I accomplished this by adding a middleware pipeline to Django’s email process. I’ve bundled a few useful middleware in and plan to add a few more. Creating your own middleware is simple. Middleware is a single Python class that defines process_message.
For example if you wanted to create a middleware that would add a tracking pixel to all of your emails.
class TrackingPixelMiddleware(object):
def process_message(self, message):
message.body = '%s <img src="http://example.com/track" />' % (message.body,)
return message
You would then simply add TrackingPixelMiddleware to FIRSTCLASS_MIDDLEWARE.
