Skip to content

Custom Premailer Modifications

Categories: Software, Web Development

Table of Contents

I’ve had to do quite a bit of email newsletter design recently and I’ve become very familiar with premailer, an awesome open source email preprocessing library that makes developing emails a little more sane.

My workflow is a bit different than what premailer expects out of the box, and there are a couple of improvements that I wanted to add to the project. I’ve forked the project, merged in some other users’ improvements,¬†and made a couple customizations:

  • In plain text mode, links and the parentheses surrounded the links, will not be broken up onto separate lines
  • Images will be replaced by their alt text
  • Instead of using the remote CSS file <link />ed in the HTML when using –base-path premailer will search for the local CSS file based on the path of the input file and use that if available. This is helpful when you have a local CSS file that you want to use to ‘compile’ the email newsletter HTML but have a different CSS file on the server that you want to use to display the email on your website.
  • Unmergable styles will be written into the body (makes a little easier for copying output into iContact and other ESPs)
  • The MailChimp reset styles will be preserved

Just an FYI for anyone looking for similar modifications to the default premailer.