Send real mail with Rails from your development environment (on Mac OS X)
Jun
17

So I wanted to send real emails from my Rails application, on the development environment. Awesomely, Mac OS X comes with a preinstalled Postfix which we can use as an outgoing SMTP server. It’s stupidly simple:

Start the SMTP server
It’s as easy as this:

 sudo postfix start

To see if it’s running a’right, run the following command and you should see a similar output to mine:

 1 2  \$ nc localhost 25 220 aca80064.ipt.aol.com ESMTP Postfix

If that happens, you are almost done. Run the following command to send a test message:

 date | mail -s test your.name@gmail.com

In my case, it went to my Gmail Spam folder so I just this-is-not-spam-ed it.

Add this code to your config/environments/development.rb file:
 1 2 3 4 5 6  config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { :address => "localhost", :port => 25, :domain => "whatever.com", }