Sending email through Gmail SMTP with Merb

Monday 11/3/2008  –  Category: Uncategorized

I was having email delivery problems while using Postfix (emails were getting caught by spam filters) so I decided to try using Gmail SMTP to send stuff off.

Initially I tried to follow a tutorial like this to get Postfix to relay to Gmail but there was a lot of footwork involved setting up certificates, etc...and I couldn't get it to work at the end.

Finally, after searching around the Merb wiki, I found that it's really a lot more simple:

Gmail SMTP

Install tls mail to enable SSL support (required by Gmail).

$ gem install tlsmail

Then configure Merb Mailer to work with Gmail

in config/init.rb:

Merb::BootLoader.after_app_loads do
  dependency 'tlsmail'

  # Activate SSL Support

  # Configure Merb Mailer
  Merb::Mailer.config = {
    :host   => '',
    :port   => '587',
    :user   => '',
    :pass   => 'pass',
    :auth   => :plain

Then to send mail:

m = :to => '',
                     :from => '',
                     :subject => 'Welcome to whatever!',
                     :text => partial(:sometemplate)

Leave a Reply