How to config devise gem to send email to the reso

2019-05-21 11:19发布

问题:

I am using devise gem not what should i configure to send emails to the registered user ?

i have saw some links but did not understand .please help me

回答1:

# 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.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"]
}

and

config/initializers/devise.rb

config.mailer_sender = 'email@example.com'