【问题标题】:Heroku Action Mailer with Gmail, sends email only once = Net::SMTPAuthenticationError带有 Gmail 的 Heroku Action Mailer,仅发送一次电子邮件 = Net::SMTPAuthenticationError
【发布时间】:2015-11-29 22:31:54
【问题描述】:

我有奇怪的行为。我正在使用 gmail 在我的 Rails 应用程序中发送电子邮件。我将我的 gmail 配置为接受不太安全的应用程序。 但是,我发送了一封电子邮件,然后当我转到我的 google 帐户时,它会提示我通过手机恢复帐户。

在那之后,我的应用程序不再发送电子邮件,我在 Heroku 日志中看到了这个:

Net::SMTPAuthenticationError (534-5.7.9 Please log in with your web browser and then try again.

我的production.rb 是这样设置的:

config.action_mailer.delivery_method = :smtp
   config.action_mailer.smtp_settings = {
     :address              => "smtp.gmail.com",
   :port                 => 587,
   :user_name            => 'xxx@gmail.com',
   :password             => 'xxxxxx',
   :authentication       => "plain",
    :enable_starttls_auto => true,
  }

有人有什么想法吗?

【问题讨论】:

    标签: ruby-on-rails email heroku


    【解决方案1】:

    我认为您必须将domain 设置为gmail.com

    config.action_mailer.smtp_settings = {
          :address              => "smtp.gmail.com",
          :port                 => 587,
          :domain               => "gmail.com",
          :user_name            => "xxx@gmail.com",
          :password             => "xxxxxxx",
          :authentication       => :plain,
          :enable_starttls_auto => true
    }
    

    如果有效,则可以,如果无效,请尝试将 :authentication 更改为 :login

    建议:还要检查 Gmail 的安全事件,并仔细检查所有安全设置是否完好。

    【讨论】:

      【解决方案2】:

      所以我遇到了几个问题。由我的疏忽造成的一个原因是我没有正确阅读 Figaro gem 文档,也没有通过 figaro heroku:set -e production 向 Heroku 发送正确的信息。

      其次,在我创建帐户并发送第一封电子邮件后,我的帐户将进入锁定状态。步骤:

      • 启用两步验证
      • 生成应用专用密钥
      • 如果您使用的是 Figaro,请将它们放在您的 config/application.yml
      • 推送并运行 figaro 命令
      • 您可能需要清除 gmail 上的验证码,请参阅 here

      【讨论】:

        【解决方案3】:

        关注@Mohamed 的评论 建议:还要检查 Gmail 的安全事件,并仔细检查所有安全设置是否完好无损。 链接:https://www.google.com/settings/security/lesssecureapps

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2013-05-21
          • 2015-08-23
          • 2016-11-27
          • 1970-01-01
          • 1970-01-01
          • 2015-09-08
          • 2011-07-14
          相关资源
          最近更新 更多