1

I am using the server that comes with Rails and I need to configure it to send emails to recipients such as [email protected] and [email protected].

Do I need to use my Gmail account or install a local SMTP service. I'm a newbie in ruby on rails

I am executing this using Mailers.

An example that I saw on internet is below.

ActionMailer::Base.smtp_settings = {
  :user_name => 'your_sendgrid_username',
  :password => 'your_sendgrid_password',
  :domain => 'yourdomain.com',
  :address => 'smtp.sendgrid.net',
  :port => 587,
  :authentication => :plain,
  :enable_starttls_auto => true
} 

2 Answers 2

1

To send mail from local put the code below in you config/application.rb

config.action_mailer.delivery_method = :smtp
    config.action_mailer.smtp_settings = {
      :address              => "smtp.gmail.com",
      :port                 => 587,
      :domain               => 'gmail.com',
      :user_name            => 'your_email_id',
      :password             => 'password',
      :authentication       => 'plain',
      :enable_starttls_auto => true  }

Add the below line in application.rb file...

config.action_mailer.default_url_options = { :host => 'localhost', :port => 3000 }
1
  • I just got gmail smtp working with similar settings above. Depending on your gmail account, you may have to grant 'device' access in order to use gmail smtp. [See here] (stackoverflow.com/questions/18124878/…). I had to grant device access to my development and production machines, plus under google Account Settings > Allow access for 'less secure' apps.
    – Jason R
    Commented Feb 15, 2015 at 6:47
0

To send mail from local put the code below in you config/environments/devleopment.rb

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  address:              'smtp.gmail.com',
  port:                 587,
  domain:               'example.com',
  user_name:            '<your gmail username>',
  password:             '<and its password>',
  authentication:       'plain',
  enable_starttls_auto: true  }

REF :http://guides.rubyonrails.org/action_mailer_basics.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.