Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring devise to send emails

I wrote a custom mailer that sends an email whenever a user receives a notification. for some reason the custom mailer works but the built in devise mailer doesn't work. I'm not able to send confirmation emails

is something missing in my configuration ?

-devise.rb:

 config.mailer_sender = "[email protected]"

-setup_mail.rb:

require "development_mail_interceptor"

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



ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.register_interceptor(DevelopmentMailInterceptor) if Rails.env.development?
like image 265
Gady Avatar asked Apr 03 '11 07:04

Gady


2 Answers

I believe that looking into

config/initializers/devise.rb

will do the trick for you:

config.mailer = "Devise::Mailer"

you can uncomment it!

like image 136
Jonathan Lin Avatar answered Oct 10 '22 21:10

Jonathan Lin


This can be helpful. After r&D, the final complete text is below:

# ActionMailer Config in development/production rb file
  config.action_mailer.default_url_options = { :host => 'localhost:3000' }
  config.action_mailer.delivery_method = :smtp
  # change to true to allow email to be sent during development
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.default :charset => "utf-8"

  config.action_mailer.smtp_settings = {
    address: "smtp.gmail.com",
    port: 587,
    domain: "mail.google.com",####important
    authentication: "plain",
    enable_starttls_auto: true,
    user_name: ENV["GMAIL_USERNAME"],
    password: ENV["GMAIL_PASSWORD"]
  }
like image 45
pratik Avatar answered Oct 10 '22 23:10

pratik