【问题标题】:如何永久验证谷歌验证码以在 Rails 中发送电子邮件 smtp
【发布时间】:2022-01-23 14:47:59
【问题描述】:

我已经使用 ruby​​ 2.6.5 创建了 Rails 6 应用程序。使用 SMTP 发送电子邮件。 在 config/environment/*rb 文件中添加配置。

config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  user_name:      ENV['SENDMAIL_USERNAME'],
  password:       ENV['SENDMAIL_PASSWORD'],
  domain:         ENV['MAIL_HOST'],
  address:       'smtp.gmail.com',
  port:          '587',
  authentication: :plain,
  enable_starttls_auto: true
}

出现错误:Net::SMTPAuthenticationError: 534-5.7.14

[https://accounts.google.com/b/1/DisplayUnlockCaptcha][1] 

它工作了一段时间,然后又开始抛出同样的错误。 我还为我的电子邮件启用了不太安全的应用程序。

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-5 ruby-on-rails-6 developer-tools google-developers-console


    【解决方案1】:

    这是我在使用带有 google SMTP 配置的 action mailer 时遇到的常见问题。我曾经用下面的几个步骤来解决它。

    1. 尝试使用 Rails 服务器所在的相同位置手动登录 Google 帐户,并检查是否显示验证码。
    2. 一旦从 Rails 服务器工作的邮件再也不会手动登录到 goole 帐户。
    3. 尝试将身份验证::plain 更改为 :login

    【讨论】:

      猜你喜欢
      • 2018-12-04
      • 2011-02-10
      • 1970-01-01
      • 1970-01-01
      • 2018-06-02
      • 2020-08-17
      • 1970-01-01
      • 1970-01-01
      • 2014-04-15
      相关资源
      最近更新 更多