Reputation: 1514
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 = "user@gmail.com"
-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?
Upvotes: 6
Views: 15598
Reputation: 809
I catch an issue today and I spend 5 hours on it. Devise 's confirmation email cannot work when the confirmation_token relational columns is blank. Well when the columns is null it works well.
#this works well
add_column :users, :confirmation_token, :string
add_column :users, :confirmed_at, :datetime
add_column :users, :confirmation_sent_at, :datetime
add_column :users, :unconfirmed_email, :string
#But this cannot work !!!
add_column :users, :confirmation_token, :string, :null => false, :default => ''
add_column :users, :confirmed_at, :datetime, :null => false, :default => '1970-01-01'
add_column :users, :confirmation_sent_at, :datetime, :null => false, :default => '1970-01-01'
add_column :users, :unconfirmed_email, :string, :null => false, :default => ''
hope help U when catching this issue alike.~
Upvotes: 0
Reputation: 64
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"]
}
Upvotes: 2
Reputation: 20724
I believe that looking into
config/initializers/devise.rb
will do the trick for you:
config.mailer = "Devise::Mailer"
you can uncomment it!
Upvotes: 4