Saturday, August 21, 2010

ActionMailer SMTP settings in rails

by Sandip Ransing 0 comments
Tags

1. Add following line to rails environment file
ActionMailer::Base.delivery_method = :smtp
2. Include your email authentication
Create a ruby file called smtp_settings under config/initializers directory # config/initializers/smtp_settings.rb ActionMailer::Base.smtp_settings = { :address => "smtp.gmail.com", :port => 587, :authentication => :plain, :enable_starttls_auto => true, :user_name => "replies@gmail.com", :password => "_my_gmail_password_" } noTE** Keep starttls_auto always true
3. Create sample mailer in order to ensure that your settings are correct
Create a sample mailer
class EmailMailer < ActionMailer::Base def test_email from 'xx@gmail.com' to 'some@xx.com' subject "This is test email" message "It should get delivered to recipient inbox" end end 4. Test your configuration
EmailMailer.deliver_test_email

blog comments powered by Disqus

About The Author

Sandip is a ruby on rails developer based in pune and also a blogger at funonrails. Opensource contributor and working with Josh software Private Limited. for more info read Follow Sandip on Twitter for updates.

Connect With Me...

Github Projects

@sandipransing Twitter