Automated email parser
It’s a simple mechanic to decompose emails into valuable parts, like some markup (to push emails directly into internal systems), create file attachments and extract inline images.
Flow is pretty simple, but we have a couple of components.
- We need something to “receive” emails. The easiest way is to use Amazon SES or mailgun or… something else. There are a couple of SASS solutions for that.
- Next step is to be notified when the email arrives, so we don’t have overhead with checking email every couple of minutes
- We have to “decompose” – decode email from it’s raw format to text, and attachments. We can achieve that using couple of existing libraries, but you get the idea
- We have to save all data and expose it to public
So we know what to do and roughly how to do the whole process. Points 1 and 2 are pretty straightforward for anyone who uses AWS and their services.
To decompose emails, we need a simple microservice; I used this go library: https://github.com/jhillyerd/enmime – it’s pretty simple and needs a little bit of play with details of email. It is also a perfect use case for AWS Lambda – because it’s just ideal for it. You don’t have to worry about many emails processed simultaneously, 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 the public (or not)
I gave you all ingredients to make this cake. If you wan’t me to bake it – you can hire me .