Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gmail smtp with rails 3

I am trying to get a confirmation email sending using a gmail account. I have looked around and there is nothing that is obvious. There is no errors or anything, it just dosn't send

I have this as the initalizer:

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = true


ActionMailer::Base.smtp_settings = {
  :address              => "smtp.gmail.com",
  :port                 => 587,
  :domain               => "gmail.com",
  :user_name            => "<address>@gmail.com",
  :password             => "<password>",
  :authentication       => "plain",
  :enable_starttls_auto => true
}

ActionMailer::Base.default_url_options[:host] = "localhost:3000"
like image 445
elasticmonkey Avatar asked Jun 16 '11 23:06

elasticmonkey


2 Answers

You don't need tlsmail gem anymore at least with Rails 3.2

This will be sufficient

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

From the all-mighty-guide ActionMailer configuration for gmail

like image 163
brutuscat Avatar answered Sep 21 '22 18:09

brutuscat


add tlsmail to gemfile

gem 'tlsmail'

run :

bundle install

add these settings to config/envirnoments/development.rb file

YourApplicationName::Application.configure do
    require 'tlsmail'
      Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
      ActionMailer::Base.delivery_method = :smtp
      ActionMailer::Base.perform_deliveries = true
      ActionMailer::Base.raise_delivery_errors = true
      ActionMailer::Base.smtp_settings = {
          :address => "smtp.gmail.com",
          :port => "587",
          :domain => "gmail.com",
          :enable_starttls_auto => true,
          :authentication => :login,
          :user_name => "<addreee>@gmail.com",
          :password => "<password>"
      }

    config.action_mailer.raise_delivery_errors = true
like image 21
Muhammad Sannan Khalid Avatar answered Sep 18 '22 18:09

Muhammad Sannan Khalid