【问题标题】:Gmail on heroku with Rails 3带有 Rails 3 的 Heroku 上的 Gmail
【发布时间】:2011-10-21 22:13:13
【问题描述】:

我正在尝试从 Heroku 发送电子邮件并开始运行。目前我可以通过http://blog.heroku.com/archives/2009/11/9/tech_sending_email_with_gmail/ 的“教程”从 Heroku 发送电子邮件,这很好。

我目前的问题是,当我让它在 Heroku 工作时,我无法让它在开发中工作。我使用 environment.rb 或 development.rb 中的设置启动并运行它,但是在教程中的内容开始后我删除了 env/dev.rb 中的设置它不起作用。

在浏览器中我收到错误消息: 530-5.5.1 Authentication Required. Learn more at(在了解更多信息后会删减)

在服务器控制台中,我收到错误消息: Net::SMTPAuthenticationError (530-5.5.1 Authentication Required. Learn more at
):

我已经设置了heroku config:add GMAIL_SMTP_USER=username@gmail.comheroku config:add GMAIL_SMTP_PASSWORD=yourpassword(带有我的信息;)),但它没有帮助。

任何想法我做错了什么?

我可以在开发中使用旧方法并以某种方式跳过 heroku 脚本吗?

卡尔干杯

【问题讨论】:

  • 在我的 Linode 实例中使用 Gmail 的 Rails 动作邮件程序也面临同样的问题。 2天前它工作正常,但今天突然显示该错误。
  • 你找到解决这个问题的方法了吗?我也有同样的问题...

标签: ruby-on-rails heroku gmail


【解决方案1】:

按照上述用户所说的 SMTP 设置进行操作。
除此之外,Gmail 会阻止来自应用程序的身份不明登录到您的帐户,而无需您进行验证。
所以去你的Gmail客户端并在那里登录。

如果这不起作用,请转到unlock captcha

【讨论】:

  • 我收到此错误:Net::SMTPAuthenticationError (534-5.7.14 accounts.google.com/ContinueSignIn?plt=...)。访问您的链接修复它。谢谢!
【解决方案2】:

我个人遇到过使用 Gmail 发送的错误,需要解决解锁 CAPTCHA 以允许发送。 Gmail 有时对安全性很挑剔,而且文档不是很明显。

完整的信息应该是:

530-5.5.1 Authentication Required. Learn more at https://support.google.com/mail/bin/answer.py?hl=en&answer=14257

请查看that link 并按照那里的指示进行操作。

您可能需要登录 Gmail 网络应用程序或(我必须做的)solve the unlock CAPTCHA。或者可能是您的应用程序或环境中的某些东西,但是按照 Google 的指示值得一试。

【讨论】:

    【解决方案3】:

    请在config/environments/development.rb中添加以下代码

    config.action_mailer.raise_delivery_errors = false
    config.action_mailer.delivery_method = :smtp
    config.action_mailer.perform_deliveries = true
    

    并确保您在 config/initializers/smtp_gmail.rb

    中添加了以下内容
    ActionMailer::Base.smtp_settings = {
      :address              => "smtp.gmail.com",
      :port                 => 587,
      :user_name            => "abc@xyz.com",
      :password             => "password",
      :authentication       => "plain",
      :enable_starttls_auto => true
    }
    

    【讨论】:

      【解决方案4】:

      您是否在本地计算机上导出了这些环境变量?你说你正在将 GMAIL_SMTP... 添加到 heroko 配置中,但是你是:

      $ export GMAIL_SMTP_USER=username@gmail.com $ export GMAIL_SMTP_PASSWORD=你的密码

      我遇到了您的问题,因为我也有电子邮件在 dev 中工作,并且想知道 2009 年关于如何让 smtp 和 gmail 在 heroku 上工作的帖子是否仍然必要。显然是这样。

      【讨论】:

        【解决方案5】:

        我在 Heroku 应用上通过 Gmail 发送邮件。如果有帮助,这是我的配置。我没有使用任何第三方插件,只使用 Rails 3。

        config/initializers/setup_mail.rb

        ActionMailer::Base.smtp_settings = {
          :address  => "smtp.gmail.com",
          :port  => 587,
          :user_name  => "foo@bar.com",
          :password  => "foobar",
          :authentication  => :plain,
          :enable_starttls_auto => true
        }
        

        config/environments/production.rb

        config 块的end 语句之后,我添加了

        ActionMailer::Base.smtp_settings[:enable_starttls_auto] = false

        【讨论】:

          猜你喜欢
          • 2011-09-16
          • 1970-01-01
          • 1970-01-01
          • 2019-02-04
          • 2013-08-30
          • 1970-01-01
          • 2014-10-30
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多