Ruby on Rails:如何配置Devise Mailer?

Jor*_*rmo 2 ruby ruby-on-rails mailer devise

我已经在Ruby on Rails上做了一个应用程序。我正在使用Devise,并且需要使用可恢复的密码功能。我在development.rb上找到了以下配置:

config.action_mailer.default_url_options = { :host => 'localhost:3000' }

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.perform_deliveries = true
  config.action_mailer.raise_delivery_errors = false
  config.action_mailer.default :charset => "utf-8"

  config.action_mailer.smtp_settings = {
    address: "smtp.gmail.com",
    port: 2525,
    domain: "gmail.com",
    authentication: "plain",
    enable_starttls_auto: true,
    user_name: "MY_EMAIL",
    password: "MY_PASS"
  }
Run Code Online (Sandbox Code Playgroud)

当我对其进行测试时,它看起来还不错,它不会在应用程序上引发任何异常,但是电子邮件永远不会来临。请,我该如何配置?

Ped*_*nto 5

对于本地使用,我建议使用诸如letter_opener之类的东西

对于部署该应用程序,我建议使用诸如Sendgrid之类的服务,它具有免费层,足以满足小型应用程序的需求。

如果您坚持使用GMail发送电子邮件,请尝试使用TLS:

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  address: "smtp.gmail.com",
  domain: "gmail.com",
  port: 587,
  user_name: "jorge@example.org",
  password: "your_password",
  authentication: 'plain',
  enable_starttls_auto: true
}
Run Code Online (Sandbox Code Playgroud)