无法在Heroku上使用Gmail发送电子邮件

我无法让我的Rails应用程序使用Gmail发送电子邮件。 我可以在我的本地开发环境中发送电子邮件,但我无法从Heroku发送它。 这是我的配置文件。

application.rb中

config.action_mailer.smtp_settings = { :address => 'smtp.gmail.com', :domain => 'gmail', :port => 587, :user_name => ENV['GMAIL_USERNAME'], :password => ENV['GMAIL_PASSWORD'], :authentication => 'login', :enable_starttls_auto => true } 

我尝试过身份validation:’登录’和’普通’,但这也不起作用。 我已经尝试将此配置放入application.rb和production.rb,但这不起作用。 我已经尝试了域名:“my_my_name_on_heroku.com”,但这也没有用。 我也试过’mail.google.com’,但也没有运气。 我在Heroku上设置了环境变量,用户名和密码正确(100%肯定)。 我启用了安全性较低的应用,以使应用程序可以在https://myaccount.google.com/lesssecureapps上运行 。 没有双因素身份validation。 我已启用validation码,允许通过http://www.google.com/accounts/DisplayUnlockCaptcha从不同设备登录,但仍然没有发送电子邮件。

在Heroku日志中,我看到它显示“向…发送电子邮件”,它使模板正常,没有任何错误,但我没有收到任何电子邮件。 我也检查了垃圾邮件文件夹,但没有电子邮件。

production.rb

  config.action_mailer.default_url_options = { host: 'my_app.herokuapp.com' } config.action_mailer.perform_caching = false config.action_mailer.perform_deliveries = true config.action_mailer.delivery_method = :smtp config.action_mailer.raise_delivery_errors = false config.action_mailer.default :charset => "utf-8" 

我错过了什么?

这是一个我永远有效的应用程序,邮件仍然有效。 尝试将auth类型更改为符号而不是字符串。 所以:平淡而不是“平淡”。

  config.action_mailer.smtp_settings = { :enable_starttls_auto => true, :address => 'smtp.gmail.com', :port => 587, :authentication => :plain, :domain => 'blarg.com', :user_name => 'info@blarge.com', :password => 'password' } config.action_mailer.default_url_options = { :host => 'blarg.heroku.com' } config.action_mailer.delivery_method = :smtp config.action_mailer.perform_deliveries = true config.action_mailer.raise_delivery_errors = true config.action_mailer.default :charset => "utf-8"