Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

RESTful email for Rails

branch: master

Name <someone@example.com> will now work for from and to settings

Now getting attribute values from mail.header[attr] instead of mail.send(attr). Before any name in from or to settings would get ignored
latest commit 417573e13f
Mathias Biilmann biilmann authored maccman committed
Octocat-spinner-32 lib Name <someone@example.com> will now work for from and to settings
Octocat-spinner-32 .gitignore Initial implementation
Octocat-spinner-32 MIT-LICENSE add license
Octocat-spinner-32 README.markdown The symbol is actually :ok, not :success
Octocat-spinner-32 Rakefile fixed up
Octocat-spinner-32 VERSION bump version
Octocat-spinner-32 remail.gemspec fix gemspec
README.markdown

Remail is RESTful email for Rails.

Forget configuring SMTP servers and queues, just use Remail. Remail uses Google App Engine to send and receive emails RESTfully.

Remail only support Rails 3.

Google App Engine gives you a free quota of 2000 emails per day or, with the paid version, 7,400,000 emails per day.

Features

  • ActionMailer POSTs emails to your Remail App Engine in order to send them
  • Remail POSTs received emails back to a configurable URL
  • Remail will retry the callback if the endpoint is not available

Setup

  • Configure and deploy the Remail App Engine
  • Install the Remail gem (sudo gem install remail)

Sending email

Configure ActionMailer and Remail:

config.action_mailer.delivery_method = :remail
config.action_mailer.remail_settings = {
  :app_id  => "remail-appname",
  :api_key => "changeme"
}

The sender address of a message must be the email address of an administrator for the Remail App Engine. If you want to send email on behalf of the application but do not want to use a single administrator's personal Google Account as the sender, you can create a new Google Account for the application using any valid email address, then add the new account as an administrator for the application.

Receiving email

First, configure the callback URL in your Remail App Engine.

Then create a email controller, that looks a bit like this (remember to configure the routes):

    class EmailsController < ApplicationController
      skip_before_filter :verify_authenticity_token

      def create
        if request.headers["Authorization"] != your_api_key
          return head(:unauthorized)
        end
        UserMailer.receive(params[:email][:raw])
        head :ok
      end
    end

The API key is passed through in the Authorization header, you should definitely validate that.

You might want to add :email to the filter_parameters configuration - you don't want your logs being clogged up with emails.

Your app can receive email at addresses of the following form: string@appid.appspotmail.com

Misc

To ensure your email doesn't get caught in spam filters, you should follow the tips in this tutorial I wrote - the important points being setting SPF and MX records.

Something went wrong with that request. Please try again.