首页 > 解决方案 > Rails SMTPAuthenticationError - 不接受用户名和密码

问题描述

我正在使用 Rails 6 并试图让动作邮件程序进行开发。一切正常,直到涉及 SMTP 身份验证。这是我的配置:

config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  :address => "smtp.gmail.com",
  :port => 587,
  :user_name => "name@gmail.com",
  :password => "gmail-password",
  :authentication => :plain,
  :enable_starttls_auto => true,
}
config.action_mailer.perform_caching = true
config.action_mailer.default_url_options = { :host => "localhost:3000" }

我确实允许谷歌允许不太安全的应用程序。它有什么问题。这是日志:

[ActiveJob] [ActionMailer::MailDeliveryJob] [3d533896-b670-404f-baa7-aaf9ecd8ff81] Error performing 
ActionMailer::MailDeliveryJob (Job ID: 3d533896-b670-404f-baa7-aaf9ecd8ff81) from Async(mailers) in 
9827.83ms: Net::SMTPAuthenticationError (535-5.7.8 Username and Password not accepted. Learn more at
):

C:/Ruby26-x64/lib/ruby/2.6.0/net/smtp.rb:981:in `check_auth_response'
C:/Ruby26-x64/lib/ruby/2.6.0/net/smtp.rb:736:in `auth_plain'
C:/Ruby26-x64/lib/ruby/2.6.0/net/smtp.rb:728:in `authenticate'
C:/Ruby26-x64/lib/ruby/2.6.0/net/smtp.rb:565:in `do_start'
C:/Ruby26-x64/lib/ruby/2.6.0/net/smtp.rb:518:in `start'

它还需要什么工作?

标签: ruby-on-rails

解决方案


我有同样的错误。问题是Gmail password不正确,因为 Google APP 不再可用。所以我不得不在我的 Gmail 帐户上重新创建应用程序并重新生成密码,就是这样!


推荐阅读