Amazon SES email 'From:' header tweaking

August 31, 2011

In the previous post, Amazon SES and Ubuntu Server, I discussed getting the service up and running using Postfix and Ubuntu Server, and the need to install various perl modules via CPAN to get things working. Since then, there has been one other tweak I needed to apply in order to get emails to send from users using a web application.

By default, the web application allows users to email eachother, as part of the application functionality. (The web application in question is OJS Open Journal Systems). Users can email eachother through the system to discuss the drafts and revisions they need to make to manuscripts submitted to the peer review system.

However, the issue arises with the fact that Amazon only allows sending via registered 'Sender addresses', which must be verified via an email system in order to be authorised to send. Forcing all our users to go through the verification system is ugly, and requires considerable effort - explaining to them why they need to click a link from an online store in order to use a manuscript submission system is quite a complex procedure.

The system we adopted in the end was to munge the headers of the emails sent by OJS using a custom python Postfix filter, which receives messages via stdin, replaces the From: header with the verified address, and then set the Reply-To: field to the correct address. Then the message is re-injected to Postfix. This allows outgoing emails to leave via SES without triggering the verification system, and means we don't have to modify the underlying web applications which sit above the system.

An early draft of the python script we used to do the header modifications can be found at Github, and others are free to add/adjust the script to their needs. I imagine this is a reasonably common issue with people using mailing lists etc. and so this solution might help people aiming to use SES, but struggling in a multi-user environment.