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 tlsmailThen configure Merb Mailer to work with Gmail
in config/init.rb:
Merb::BootLoader.after_app_loads do dependency 'tlsmail' # Activate SSL Support Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE) # Configure Merb Mailer Merb::Mailer.config = { :host => 'smtp.gmail.com', :port => '587', :user => 'user@gmail.com', :pass => 'pass', :auth => :plain } endThen to send mail:
m = Merb::Mailer.new :to => 'foo@bar.com', :from => 'bar@foo.com', :subject => 'Welcome to whatever!', :text => partial(:sometemplate) m.deliver!
Leave a Reply
Recent Posts
- Light 2
(Thursday 12/6/2012 – 10 Comments) - Solve Something – The Best Helper App for Draw Something
(Tuesday 04/17/2012 – No Comments) - Marble Paint
(Friday 02/4/2011 – 1 Comment) - More Flickr Original Updates
(Sunday 01/23/2011 – 14 Comments)
