Automated email parser

Automated email parser

It’s a simple mechanic to decompose emails into useful parts, like some markup (to squiz emails directly into internal systems) and create file attachments – and extract inline images.

Flow is pretty simple, but we have couple components.

  1. We need something to “receive” emails. Easiest way is to use Amazon SES or mailgun or… something else. There is a couple SASS solutions for that
  2. Next step is to be notified when email arrive, so we don’t have overhead with checking email every couple of minutes
  3. We have to “decompose” – decode email from it’s raw format to text, and attachments. We can achieve that using couple existing libraries, but you get the idea
  4. We have to save all data and expose it to public

So we know what to do, and roughly how to do whole process. Points 1 and 2 are pretty straight forward for anyone who uses AWS and their services.

To decompose e-mails we need simple micro service, I used this go library: https://github.com/jhillyerd/enmime – it’s pretty simple, just need a little bit of play with details of email. This is also perfect use case for AWS Lambda – because it’s just ideal for it. You don’t have to worry about no. of emails processed in the same time, and with low traffic you can get it for free.

Moving on – point 4 – super easy. You can upload your “elements” to S3, or anywhere and expose it to public (or not)

I gave you all ingredients to make this cake. If you wan’t me to bake it – you can hire me .