Email Uploaded to Amazon S3
Ruby
Latest commit 49c60f4 Jan 14, 2014 @nquinlan remove Gemfile.lock
Permalink
Failed to load latest commit information.
_templates added another template Jan 14, 2014
.gitignore remove Gemfile.lock Jan 14, 2014
Gemfile more for heroku Jan 14, 2014
LICENSE added license Jan 14, 2014
Procfile copy paste errors Jan 14, 2014
Readme.md readme! Jan 14, 2014
app.rb mantained naming Jan 14, 2014

Readme.md

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.

Requirements

Quick Start

To start using this app you must do two things: deploy the app and setup your parse webhook.

  1. Clone the repository to your computer.
    git clone https://github.com/nquinlan/save-mail.git save-mail
  2. Move into the repository.
    cd save-mail
  3. Initialize Heroku.
    heroku init
  4. 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
  5. Deploy to Heroku.
    git push heroku master
  6. 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.

URLs

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.

X-Save-Mail-ID: super-cool-message

The message will be stored on S3 at http://s3.amazonaws.com/your-bucket-name/super-cool-message.html

All files stored by Save Mail have the extension .html

Templates

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

X-Save-Mail-Template: preserve-headers

The message will be saved with the template preserve-headers.html.erb.

Other Services

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 html and headers parameters are POSTed as a form.
  • cloudmailin change params[:headers] to params[:message] and use their original HTTP POST format.
  • mailgun change Mail.new(params[:headers]) to simply params[:message-headers]

License

This code is licensed MIT. Please, build things with it.