【问题标题】:Rails, Gmail SMTP and failureRails、Gmail SMTP 和失败
【发布时间】:2017-10-26 12:24:59
【问题描述】:

我正在尝试设置一个操作邮件程序,以便人们可以使用我网站上的联系表发送消息。

这是我的生产配置:

 config.action_mailer.default_url_options = { host: 'mydomain.co' }
  config.action_mailer.delivery_method = :smtp
  ActionMailer::Base.smtp_settings = {
    :address        => 'smtp.gmail.com',
    :port           => 587,
    :authentication => :plain,
    :user_name      => ENV['GMAIL_USERNAME'],
    :password       => ENV['GMAIL_PASSWORD'],
    :domain         => 'mydomain.co',
    :enable_starttls_auto => true
  }

我试图对其进行测试并且邮件已送达,但之后我立即收到来自“邮件送达子系统”的主题为“送达状态通知(失败)”的消息。

是什么导致了这个消息以及如何避免它?

【问题讨论】:

    标签: ruby-on-rails smtp gmail


    【解决方案1】:

    我的看起来像这样

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

    还要确保您已在 Gmail 设置中启用“安全性较低的应用程序”: https://support.google.com/accounts/answer/6010255?hl=en

    希望有帮助!

    【讨论】:

      猜你喜欢
      • 2019-01-20
      • 2020-09-24
      • 2014-07-21
      • 1970-01-01
      • 2015-03-20
      • 2020-12-29
      • 2021-04-01
      • 2020-05-15
      • 2019-03-14
      相关资源
      最近更新 更多