Save Mail - Email Uploaded to Amazon S3
This app uploads emails it receives to S3. Out of the box, it works well to create "View On Web" links within personalized emails.
- Parse Webhook - This app relies on the SendGrid Parse Webhook, however, it could be configured to use another webhook.
- AWS Account
- Hosting Provider - Heroku is ready to go, however, you can upload to any provider that supports webhooks.
To start using this app you must do two things: deploy the app and setup your parse webhook.
- Clone the repository to your computer.
git clone https://github.com/nquinlan/save-mail.git save-mail
- Move into the repository.
- Initialize Heroku.
- Provide Heroku with your app's credentials.
heroku config:set S3_ACCESS_KEY_ID=your-s3-access-key S3_SECRET_ACCESS_KEY=your-s3-secret-key S3_BUCKET=your-s3-bucket
- Deploy to Heroku.
git push heroku master
- Setup a webhook to post to your new Heroku app.
This will start saving all mail received by the domain the Parse Webhook is setup on.
By default Save Mail saves each email with a Universally Unique Identifier, however, you may specify what you wish the file name to be instead.
You may specify the URL (or at least the file name) you intend for the stored email to have by specifying an
X-Save-Mail-ID in the headers of your message (as seen below). This ID will be the file name for the email when uploaded to S3.
The message will be stored on S3 at
All files stored by Save Mail have the extension
Save Mail comes with two templates, found in _templates, however you may modify and change these how you wish. To have an email be stored with a certain template, simply send your email with an
X-Save-Mail-Template header (as seen below). This will save the message with the specified template
The message will be saved with the template
Although this code is meant for the SendGrid Parse Webhook, it should also work with a few other services, with limited changes: (Warning: These have not been tested)
- Mandrill should work without modification
- zapier might work, but they sure do hide their documentation. Make sure
headersparameters are POSTed as a form.
- cloudmailin change
params[:message]and use their original HTTP POST format.
- mailgun change
This code is licensed MIT. Please, build things with it.