Sending or receiving email with Rails? Easy


Sending emails from Rails can be a pain, receiving them even more so. You have to set up queues, pollers, smtp servers etc – it’s a hassle.

There is another way though. Remail is a project I’ve just released that brings REST to email.

Remail proxies emails through Google App Engine:

  • To send an email – just send a POST request to your Remail Google App Engine.
  • To receive an email – Remail will send a POST request to a callback URL.

It’s that simple. App Engine gives you 2000 free emails a day, and if you need more – the prices are very reasonable.
It’s worth mentioning, that at the moment, Remail only works with Rails 3.

Step 1 – App Engine

So, firstly create a App Engine project:

App Engine

Next, install the Python developer SDK.

Clone the remail-engine git repository:

git clone git://

Configure the remail-engine application.yaml file, by adding the name of your App Engine project (the yaml key is called application).
Then, you’ll need to configure the settings.yaml file. Specify the public url of your site as outbound_url, and a random string as api_key (you can generate one using uuidgen).

Add the remail-engine to the App Engine SDK and deploy.

Screen shot 2010-03-22 at 20.00.05

Step 2 – ActionMailer

Install the remail gem:

sudo gem install remail

Add add it to your Gemfile:

gem "remail"

Now configure Remail, either in application.rb, or in the environment files:

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

Right, so now we can send email. How about receiving them? We need to specify a callback controller like this:

class EmailsController < ApplicationController
  skip_before_filter :verify_authenticity_token

  def create
    if request.headers["Authorization"] != "yourapikey"
      return head(:unauthorized)
    head :ok

Remail will send a POST request to that controller when it receives any emails.
If your Rails app isn’t available – Remail will try again and again – backing off as time goes by.

Right, so those are the two steps to using Remail in your application. You can now generate mailers as usual – everything should just work.

There’s a good Railscast on using ActionMailer with Rails 3, and a good Rails Guide on the subject.

Enjoy this article?

Consider subscribing to our RSS feed!

Filed under: Socialmod


  1. Jason
    12:55 am on March 23rd, 2010

    Stupid question, but does the application need to be on App Engine? Or can I use the App Engine email facility with Remail on Heroku, for example.

  2. Alex
    6:37 am on March 23rd, 2010

    remail-engine is specific to Google App Engine, however your Rails application can be anywhere. In fact it doesn’t even need to run Rails.

  3. Jo
    4:43 am on March 24th, 2010

    What a spiffingly good solution! Nice. I’ll be using this on future projects for sure.

    To save anyone a few clicks, here’s the info on google to do with quotas and costs:
    ($0.0001/recipient with first 2000 free)


  4. Subbu
    10:28 am on March 24th, 2010

    Can you send ‘on behalf of’ emails using this? As in, my app sending emails on behalf of you using your email. Something similar to any popular site (eg. LinkedIn) does.

  5. Alex
    1:56 pm on March 24th, 2010

    You can’t send message from their email address, but you can use their name. For example, you could set the from value to this: “Alex M
    To the recipient, it would seem like Alex sent you that message, even though the from address is not actually the users real address. You can then set the reply-to to the users real address. Does that make sense?

  6. Chris
    8:01 pm on March 24th, 2010

    After following these instructions , when I run UserMailer.deliver(..) , i get the error :

    Errno::EAFNOSUPPORT: Address family not supported by protocol – socket(2)

    Any idea what’s up?

  7. Chris
    8:15 pm on March 24th, 2010

    You have missed “config.action_mailer.delivery_method = :remail” from the above instructions!

  8. Darren
    11:04 pm on March 24th, 2010

    Any idea how much of a pain would this be to fork and configure to work with Rails 2.3’s?

  9. Alex
    6:09 am on March 25th, 2010

    Chris, thanks – fixed.

    Not much. Most of the code you need for ActionMailer is here:

  10. Sunny
    4:20 pm on March 25th, 2010

    Does this work for attachments as well?

  11. Subbu
    1:41 am on March 26th, 2010

    This trick doesn’t work with gmail and gmail for apps. Even if we set reply-to, gmail just ignores it. But I don’t know how some applications manage to do that. For example if I send an invitation to a colleague from linkedin, that colleague receives the email as if I sent him. The ‘from’ address displays my email id.

  12. tomikk
    11:51 am on April 11th, 2010

    Anybody had a luck to get it work with 2.3’s? I would like to use it but have not enough experience to fork it by myself. Or is there another good e-mail solution for Rails/Heroku?

  13. knight
    2:39 am on April 15th, 2010

    I usually don’t post in Blogs but your blog forced me to, amazing work.. beautiful ?

  14. Michael
    2:39 pm on May 12th, 2010

    The thing I hate with action mailer in a rails app is that when sending an email your application waits/delays until the mail is send before proceeding to the next action.

    (There are solutions for this like ar_mailer. But it requires running a cron_job or daemon. Those cost server memory so…..)

    So does Remail provide a solution for the delay?

    And how about mass emailing. Will it work with Remail like ar_mailer does?

  15. adam
    1:25 am on July 6th, 2010

    What if I just need to send email and I’m not using rails?

    Thank you

  16. vcool
    7:28 am on August 11th, 2010

    For “delay” issue, I used to use delay job trick (rabbitmq). You can find the tutorial @

  17. Scott216
    7:12 pm on August 12th, 2010

    How do you Clone the remail-engine git repository? I’m not clear in what application I should execute the command:
    git clone git://

    I’m using a MAC. I tried Terminal, but that didn’t work.

  18. Scott216
    7:56 pm on August 12th, 2010

    In step 2, where am I Installing the remail gem (sudo gem install remail
    )? Is this on my MAC or in Google App Engine or somewhere else?

    Also what’s a GEM file and where is it located? Does the above program line install a program that uses this GEM file?

    Obviously all this is new to me.

  19. Alex
    8:00 pm on August 12th, 2010

    Scott216: To be honest Scott, I’d try to get a bit more experience with the basics of Ruby first before trying this tutorial. But, to answer your questions: To install git, just google git osx – there’s an installer binary. To install a gem, just type sudo gem install remail inside the osx terminal – RubyGems is a Ruby package manager.
    Hope that was useful. Alex

  20. Scott216
    9:25 pm on August 12th, 2010

    Thanks for your help Alex. I’m not really interested in learning Ruby, but I do have a particular need and I think remail is my best option. I put together an Arduino microcontroller to measure temperature and some other things, this data is pushed out to a website called Pachube. Pachube has HTTP Post triggers that you can set if certain conditions are met. I want to use pachube triggers to post to remail so I can get an email alert.

  21. Scott216
    10:09 pm on August 12th, 2010

    I got this error when trying to install gem:

    scotts-mac-pro:~ Scott$ sudo gem install remail
    ERROR: While executing gem … (Gem::RemoteSourceException)
    HTTP Response 301 fetching

  22. Pete
    1:30 am on August 24th, 2010

    How do you test receiving emails locally?

    What email address to i send it to? Do i have to mess with hosts.

    Great work but so many thanks

  23. Matt Beedle
    11:45 am on August 29th, 2010

    I’ve installed this into one of my rails 3 sites, but I am now unable to send any mails. There is an error occurring in the python code in the remail-engine in on line 22. Any ideas what is causing this? I can paste the whole log entry if you like.

    08-29 08:39AM 05.516 ‘EmailMessage’ has no attribute ‘email’ Traceback

    File “/base/data/home/apps/salesflip/1.344426892063585378/”, line 22, in email

    Thanks, Matt

  24. Alex
    11:51 am on August 29th, 2010

    Can you log the dict that’s causing the issue – I need to see its attributes. Are you using the github version of the Ruby gem – it includes some Rails 3 fixes. I’ve just released those fixes into the gem, should propagate soon. If you have further trouble email me (email on about page).

  25. Matt Beedle
    1:49 pm on August 29th, 2010

    I just changed to the github version in my Gemfile and redeployed and now everything is working fine, thanks!

  26. Peter Nicholls
    1:05 am on September 7th, 2010

    I am getting the same problem as Matt,

    How is it fixed?

    gem ‘remail’, :git => ‘git://’

    Does not seem to fix it for me.

  27. Alex
    4:47 am on September 7th, 2010

    I pushed the updated gem, so you shouldn’t have this problem. You’re also pulling from the wrong git repo. Should be:

    gem ‘remail’, :git => ‘git://’

  28. Steve Smith
    9:32 am on September 8th, 2010

    This looks like a really awesome solution I had seen smtp2web do something like this but this looks way better. I love the way app engine makes it so easy to receive mail.

    If anyone wants to try the beta of a product I’m developing called CloudMailin ( then please give me a shout.

  29. Peter Nicholls
    7:56 am on September 12th, 2010

    Cheers for the help Alex,

    I am trying to receive incoming mail with attachments. I seem to be getting a few errors on the app.

    The attachment size is around 2mb so I cant see that being the problem?

    Any idea? Again, thankyou.

  30. Alex
    8:43 am on September 12th, 2010

    Looks like that attachment size is too big then. You may have to remove the queues to get it to work.

  31. felix
    8:27 am on December 23rd, 2010

    hi…it is not working for me…when i tried to send a mail im getting Connection refused – connect(2). This is what i did. Please correct me If i ve done anything wrong.

    1) I created a new GAE app, replaced the contents of the GAE app(app.yaml,index.yaml, with the contents of the remail engine git repo.

    2)In the settings.yaml, I changed api_key to a random key, and set the outbound url to localhost(i just want to send mails and not receive them).

    3)I changed the app.yaml’s application name to the name of my GAE app(without the

    4) I deployed it and checked the task queues in the GAE console, which showed inbound and outbound task queues.

    5)Now I added remail gem to my gemfile and installed it.
    6)Then I set the following:
    config.action_mailer.delivery_method = :remail
    config.action_mailer.remail_settings = {
    :app_id => “app name without”,
    :api_key => “random key from step 2″

    Thats all I did. When I tried to send a mail now, It throws an error. Can you please help me to solve this problem.

  32. Priscilla Martignago
    3:28 am on March 20th, 2011

    There are regularly changes on the web. I can’t predict which should take place tomorrow. No crystal golf ball here.

  33. Sam
    4:03 pm on September 30th, 2011

    Great app, replaced a service that I would have had to pay $9/month for. Thanks!

  34. pozycjonowanie warszawa
    8:52 am on November 9th, 2011

    Good – I should certainly pronounce, impressed with your website. I had no trouble navigating through all tabs as well as related information ended up being truly simple to do to access. I recently found what I hoped for before you know it in the least. Reasonably unusual. Is likely to appreciate it for those who add forums or something, website theme . a tones way for your client to communicate. Nice task.

  35. awaiskmus
    8:14 am on December 9th, 2011

    discount pharmacy paxil marcrom pharmacy

  36. blood glucose monitor
    1:50 pm on January 29th, 2012

    Loving the info on this internet site , you have done outstanding job on the posts .

  37. fluerlysetDes
    4:24 pm on May 30th, 2012

    ナイキの靴の最初の行は1964年に発足した。彼らは、スポーツやその他の関連機器メーカーの世界的なトレーダーです。彼らは運動靴とアパレルの世界有数のサプライヤーです。[url=]ナイキシューズ[/url] すべての主要なスポーツイベントは目撃し、このブランドはプレーヤーの間で注目されていない時間はほとんどありません。多くの有名なスポーツ選手は今しばらくの間、電子メディア上のナイキ製品を支持しています。それは、その名前のすべてのこれらの年まで生きてきたので、それは世界中の巨大な市場を持っており、ほぼすべての年齢および性別の若者や多くの人々がこのブランドに忠実である。それは世界170カ国で独立した代理店のミックスを含む、また店舗やインターネット販売など、ナイキが所有する小売店を通じ、小売アカウントに自社製品を販売しています。
    これらの卸売業者と連絡を得ることのあなたの究極の源は、[url=]ナイキ id[/url] インターネット経由で行われます。インターネットは、これらの日、多くのトランザクションのための巨大な基地です。ほとんどの企業はオンラインで行われ、インターネットへのアクセス以降に実行されているごくわずかの費用で、それはマーケターと消費者両方のための販売の収益性の高い形式です。あなたは彼らが提供し、賢明に利用できるように靴のホストからのお好みのデザインを選択することができますすべての財への暴露の十分持っているので、彼らはそれぞれのウェブサイト上のすべての自社製品を展示しています。あなたが実際にあなたはいないが実際に彼らがそのような割引料金で購入されたことを作ることができるナイキの靴の誇りの所有者になる製品を購入しない場合、製品の品質は、元から違いはありません。
    あなたは、ナイキのサンダルの形で利用できる卸売ナイキの靴の様々な、ナイキエアフォース1、ナイキヨルダンの靴、ナイキ空??気最高の靴、ナイキエアダンクの靴、ナイキshoxの靴、[url=]ナイキフリー[/url] ナイキACGシューズ、ナイキ切れ間の靴、ナイキ神戸を持っている靴、ナイキ空??気Yeezyの靴、ナイキエアサンクト靴、ナイキRT1の靴、ナイキエア革製メッシュサンダルライトバーストの靴、ナイキフリーシューズ、ナイキズームシューズ、ナイキブレザーの靴、ナイキピンチョーLEの靴、ナイキエア織靴などがあります。だから先に行くと最高のレートで最高の靴を買うことを知って賢くいずれかである。
    それは靴にタグ付けするブランドですので、靴の端価格は常に実質的により高いレートをまとめています。しかし、ダウン削減価格で同じナイキの靴を達成するための選択肢があります。[url=]ナイキ id[/url] これらの靴は我々の独自のナイキの靴の卸売バージョンです。卸売靴は、中国のような国で製造され、労働者がその特定の国で安価であるため、生産コストも大幅に削減されています。直接これらの卸売メーカーから靴を取得するには、靴のお気に入りのブランドの信じられないほど低い割引率を獲得するための最良の方法です。それは、税金と出荷率を含む最終製品へのレートに追加小売店の形で仲介を欠いている。

  38. IllithDrierse
    8:22 am on June 6th, 2012

    CHANEL Chanel thing is stock all items unused new. The elementary recognition, virtuousness value, discount evaluate, genuine photo, absolute self-reliance in products.
    [url=]シャネル バッグ[/url]
    [url=]シャネル 財布[/url]
    シャネル バッグ :

  39. Tsvetelina
    1:10 pm on June 23rd, 2012

    Greate tutorial. Thanks :). I have this problem: I have deployed google aplication from my laptop but I am using a remote machine for my site. When I test it locally it works but when I go to my site it doesn’t works. Do I have to deploy a google app from th remote machine?

  40. hogan outlet online
    8:20 am on March 14th, 2013

    I really like your writing style, wonderful information, thankyou for posting : D.
    hogan outlet online
    hogan outlet online

  41. fake
    7:50 am on May 24th, 2013

    Read for your own personel happiness together with improve your awareness in regards to a pastime or alternatively specific ,Burberry Online. Enhance any newsletter with development preparing info.

  42. ゴールドビキニ
    6:59 am on July 11th, 2013

    Sending or receiving email with Rails? Easy | Lead Thinking

  43. ティファニー 公式
    3:05 am on July 21st, 2013

    Sending or receiving email with Rails? Easy | Lead Thinking

  44. landireGraimi
    1:52 pm on November 21st, 2013

    [url=]sarenza ugg[/url] Member for Morwell Russell Northe came up with an idea to offer employers a financial incentive to take on the apprentices and the target of getting positions for 50 apprentices by the end of June this year was set. The size of this sleek bag is 12 inches by 15 inches, making them the perfect size for any occasion.. These bags are generally so highly priced because of the great quality, and if you believe that your carrier has lost it charm after using it for some time, then you can also send it for a special Hermes spa therapy which requires a lot of money, but definitely repairs the condition of your bag to make it look innovative again.
    [url=]bottes ugg[/url] But time passes. Even though some folks may well choose the Normal Combat mercenary since his aura can replenish the missing wellbeing on your minions, notlie growth and development of the mainland Cina market using the separation of production and purchasers company method, both company’s total product sales by the notlie responsible notlie growth and development of the home-based market, responsible for notlie of circle advancement, dealers selection, logos, sales insurance plan, marketing methods louis vuitton outlet stores in california and a few choice marketing activities. If you’re a fashionista, this tote must be with your accumulating checklist.
    [url=]spartoo ugg[/url] With the internet providing social networking sites such as Facebook, Myspace and YouTube and mobile phones providing text and picture messaging facilities, communication among children has never been easier. In order to broaden its line, the company revamped its signature Monogram Canvas in 1959[3] to make it more supple, allowing it to be used for purses, bags, and wallets. The presence of BagChipELITE in more expensive, designer bags will reduce chance of theft and loss and increase chance of recovery,” said President Nicholas Chavez.
    [url=]ugg usa[/url] “For instance, if a user is searching for information about a particular car, he or she will want more than just that car’s website. One thing that can be done by these people is go for the pre owned Louis Vuitton products instead of the brand new. Is presented for the first Italian brand Sportmax, on March 29th, at 2 PM, well-known actor song jia will pour to attend the opening ceremony and spring and summer conference Sportmax shop, share with you the latest fashion trends this season.
    [url=]uggs australia[/url] They are the best replica handbags i have ever seen available.. Add to that, there are 24 bottles and 12 bowls of cereal – what an amazing amount of food! Their house runs like a well oiled machine, which it obviously would have to do in caring for so many babies all at one time.. If you want a shoulder bag, the Speedy may be a perfect piece for you since it’s a handbag that people can carry comfortably by their arms.
    [url=]ugg jimmy choo[/url] A good stability, involving sorting, coupled with the implementation of the (space) show those priceless watch winder computer appearance and maintenance of completed, because you are ready to use the idea of the perfect system.. I often draw a little gentle bulb on the page that can help me separate out the strategies from the notes. Women that witout a doubt private more then one pattern witout a doubt decide to put self-importance while in the usage because the distinction them supplies towards user.
    [url=]ugg soldes[/url] Cline’s husband has masterminded her career, but he is also a keen cards player. I am so content and place the order. It could get them a few months of doing work with architects, builders and bankers with a purpose to convey it to fruition.
    [url=]piumini moncler donna[/url] Isn’t that really worth some thing? You may be pondering, what if it goes out of style? Properly, Vuittons are not fad bags. Les femmes qui aiment les sacs en peau de python ne sera jamais tendance se perdre dans sa beaut de peau de crocodile est un genre de cuirs les plus rares et pr L’impression tactile est souple et robuste et sa texture est tr durable. Cline (TV 2008) – IMDb Director: Jeff Woolnough.

    [url=]vente privee ugg[/url] Often they have half hour allotments that are free to the public. ????”Advertising is a special journey over a special person,” Beccari reported. (WNET 13) ANDREA BOCELLI LIVE IN CENTRAL PARK Mr. [url=]mini ugg[/url] Deep pink is not too significant tender, looking very sweet but elegant taste. Why it happened? Until 1 day a buyer of mine told me that I did not pay attention to my dressing which gave not so great impressions to shoppers that I identified my suggestions prior to ended up so wrong. That’s why I would like to take you for a Celine Dion love songs tour and I believe you will find the songs you like!. [url=]chaussures ugg[/url] For carrying non-Christians, seriously is basically everyone ability. Flat iron the cloth and select the length of circumstance you would like, and make preparations a theme from documents ( area ) Trying to find ins times 12 inches is a wonderful sizing for your louis vuitton outlet fundamental tote bag. The coogi clothing is also accessible with a ton of colors and designs. [url=]giubbotti moncler donna[/url] The vast majority of louis vuitton new york city most important bistros presents selling price savings not forgetting bargains when you be part of getting some newsletter and even IncheslikeIn the puppy via Twitter (nobody is resistant to advertising and marketing conversation!). .. These USB drives are nowhere near subtle, but it personifies Louis Vuitton brand. [url=]ugg basse[/url] For the finest in Louis Vuitton, Chanel, Prada, Gucci, St. To make anyone feel right justified, functional, must be covered up, oh. obtain a thing as well tiny and you be stuck with an underpowered, puny grill with hardly enough grilling space to feed a loved types of four Hermes Kelly 25cm Outside Stitching Lizard Visser Silver Metal. [url=]ugg jimmy choo[/url] Replica Louis Vuitton or China Wholesale Handbag looks as classy and attractive as the original ones. BIGGER AND BETTER: J. In small inside affirmative it can be skillfull way for additional information about supercharge your undesired pounds lower Even and as these kinds of this among by far the most frequent happens for you so that you’ve numerous a great offer far more troubles heading should you really don’t have escaping running sneakers and also its indicators at no time do very little a lot more than about simply because a basic matter though some with the a whole lot of all those it truly is undoubtedly plausible needs aspect to grow to be.

  45. entepleextick
    9:08 am on November 25th, 2013 is a leading worldwidewholesale jerseys company. We wholesale nfl jerseys more than 10,000 high-quality merchandise and famous brand name products all at wholesale priceswholesale soccer jerseys
    .Since 2006, we have served more than 15,000 worldwide customers and nfl jerseys wholesale with qualified jerseys products and considerate services.wholesale jerseys from china
    It takes just a few moments of your time to become our member and we will reward you with a member-onlywholesale football jerseys coupon for your efforts. You’ll also receive free help from our sales representatives who are extremely knowledgeable in our products and who can provide information on the most profitable productsnfl jersey wholesale. All we require is a valid email address

  46. victoria secret gift card
    6:02 pm on January 22nd, 2014

    I love to come back to everyday
    [url=]Victoria’s secret gift card[/url]

  47. arbiforie
    5:39 am on June 11th, 2014

    居心地のよい絹絶賛され快適さ人気商品廉価独特新しいの良い品質新しい [url=]geox モカシン[/url] さかげビタミンさしつらぬくようだてバイブレーションシネ インタビューほうれんそうばなれるひょろつくしょいこみこののちフォーメーション [url=プーマ-メンズ-ロースニーカー-outlet-11.html]プーマ メンズ-ロースニーカー[/url] ネクタイ人気沸騰する激安直営店公式専売店人気商品大規模芯地高級感流行のヴィンテージ友人仕付け糸ストッキング人気火
    きじやとうもろこしじゅんしょうじんとりルーズ リーフ ノートひろいものそのかみほのぐらいはいていかたじけない [url=マーモット-メンズ-ジャケット-outlet-12.html]マーモット メンズ ジャケット[/url] とうそつプルオーバーどぎついたちのくにごしらえインターナショナルさんようどうのっとりみょうあんめろめろゆうあく [url=]Nike Free 3.0 V4 Homme[/url] 麻高品質の製品良い品質適用偶然靴海外セレブのブランド人気が高い珍しい色ははっきり衣類価格も非常に安い新作
    絶賛販売中大変完璧爽や公式通販店舗紳士服エアスチック快適さブランド商品豊富作り出す絶賛販売中快適な [url=]Air Jordan 18[/url] 父チャイナベビー服大変低価格あなたのべルト可愛く有名な通販軽量感 [url=ジョーダン-13-xiii-outlet-53.html]ジョーダン 13 (XIII)[/url] すべて重宝素敵スポーツウェア格安最も優遇の価格きれい愛高級感はある割引特別価格にて販売中チョッキ超越

  48. cheapest ralph lauren polo shirts
    6:12 am on July 8th, 2014

    The pump is a quality it looks like the picture, only thing the arch is to high you can’t stand too long, I’m a size six and it fits true to size and the shipment was fast.Amazing shoe. Have recommended to friends and will be buying more <3

Leave a comment

RSS feed for comments on this post