在Rails App Heroku中发送邮件

时间:2013-01-20 00:45:30

标签: ruby-on-rails postgresql heroku devise actionmailer

我的用户可以通过电子邮件邀请其他人加入他们正在处理的项目,但我一直收到以下错误 -

Net::SMTPAuthenticationError 

以下是我为生产环境配置邮件设置的方法

  config.action_mailer.default_url_options = { :host => 'myapp.herokuapp.com' }

  #Sending email on the production side
  config.action_mailer.smtp_settings = {
    :enable_starttls_auto => true,
    :address => "smtp.gmail.com",
    :port => "587",
    :domain => "gmail.com",
    :authentication => :plain,
    :user_name => "example@gmail.com",
    :password => "password"
  }

它在我的本地环境中使用sqlite3正如我所期望的那样但当我推送到heroku时它会在运行heroku日志后抛出上述错误。我相信我的配置设置是正确的,显然heroku使用postgresql,所以我在这里缺少什么?

感谢您的关注。

1 个答案:

答案 0 :(得分:0)

我在How to send confirmation e-mails using gmail smtp service for registration using devise under development mode locally?

找到了原因

Google在新创建的帐户中发现了一些“可疑”活动,并阻止我发送电子邮件。验证帐户后,我可以使用上述配置发送电子邮件并切换:domain => "heroku.com"