ActionMailer SMTP settings in rails

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.rbActionMailer::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" endend4. Test your configuration
EmailMailer.deliver_test_email

Advertisements

About sandipransing

Web Developer #ruby #rails #JS
This entry was posted in Ruby on Rails and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s