【问题标题】:Net::SMTPAuthenticationError in UsersController#create用户控制器中的 Net::SMTPAuthenticationError#create
【发布时间】:2016-06-22 07:18:55
【问题描述】:

我们的 Rails 3.2 应用程序的“重新发送激活码”邮件功能一直有效,直到代码从以前的开发人员转移给我们。现在我们得到这个错误

Net::SMTPAuthenticationError in UsersController#create  

我们的邮件设置保持不变,如下所示:

ActionMailer::Base.smtp_settings = {  
:address              => "smtp.sendgrid.net",  
:port                 => 587,  
:domain               => "example.com",  
:user_name            => "username",  
:password             => "password",  
:authentication       => "plain",  
:enable_starttls_auto => true  
}  

我们无法弄清楚电子邮件停止工作的原因。
我们检查了 gmail 服务器也通过 telnet 回复了我们。
我们还在安全性 -> 帐户权限 -> 访问不太安全的应用程序中启用了 Gmail 的不太安全的应用程序功能
提前致谢。

【问题讨论】:

  • 向我们展示您的所有 config.action_mailer。 delivery_method、default_url_options、perform_deliveries、raise_delivery_errors 等等……如果你可以去 /var/log/mail.log,请显示你的 mail.log。

标签: ruby-on-rails ruby ruby-on-rails-3 gmail


【解决方案1】:

您提到使用 Gmail 的设置,我认为您应该试试这个:

ActionMailer::Base.smtp_settings = {
 address: "smtp.gmail.com",
 port: 587,
 user_name: ENV['GMAIL_USERNAME'],
 password: ENV['GMAIL_PASSWORD'],
 authentication: :plain,
 enable_starttls_auto: true
}

如果您使用的是 Sendgrid,如上所述,您应该有类似的内容:

ActionMailer::Base.smtp_settings = {
    user_name: ENV['SENDGRID_USERNAME'],
    password: ENV['SENDGRID_PASSWORD'],
    domain: 'heroku.com', #for your helo domain
    address: 'smtp.sendgrid.net',
    port: 587,
    authentication: :plain,
    enable_starttls_auto: true
  }

不要忘记适当地定义您的 ENV 变量。 你可以找到more discussion around this here

【讨论】:

    猜你喜欢
    • 2015-02-07
    • 1970-01-01
    • 2012-09-27
    • 2016-12-08
    • 1970-01-01
    • 2013-09-07
    • 2018-09-09
    • 1970-01-01
    相关资源
    最近更新 更多