Rails 5 smtp Sendgrid 451 Authentication failed: Could not authenticate

对着背影说爱祢 提交于 2019-12-24 22:04:47

问题


We are using Sendgrid for sending SMTP emails in our Rails 5 app, I had a weird error stating:

451 Authentication failed: Could not authenticate

My configuration in production.rb file is like this:

  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    user_name: ENV['ENV_username'],
    password: ENV['ENV_PASSWORD'],
    domain: 'xxxxxx',
    address: 'smtp.sendgrid.net',
    port: 587,
    authentication: :plain,
    enable_starttls_auto: true
  }

The exception that we have is as follows:

vendor/ruby-2.6.3/lib/ruby/2.6.0/net/smtp.rb:981 check_auth_response
vendor/ruby-2.6.3/lib/ruby/2.6.0/net/smtp.rb:736 auth_plain
vendor/ruby-2.6.3/lib/ruby/2.6.0/net/smtp.rb:728 authenticate
vendor/ruby-2.6.3/lib/ruby/2.6.0/net/smtp.rb:565 do_start
vendor/ruby-2.6.3/lib/ruby/2.6.0/net/smtp.rb:518 start
vendor/ruby-2.6.3/lib/ruby/2.6.0/monitor.rb:230 mon_synchronize
vendor/ruby-2.6.3/lib/ruby/2.6.0/monitor.rb:230 mon_synchronize
app/controllers/xxxxxx/registrations_controller.rb:3 create

Generally, the emails are sent correctly & everything is working fine but for this issue, it is a bit vague what the problem is, from Sendgrip docs I can see it means

451 Temporary local problem - please try later The message simply failed, usually due to a far-end server error. We continue to retry messages for up to 72 hours.

I am not sure if that means an exception from Sendgrid side or on my application

Any thoughts about this?

来源:https://stackoverflow.com/questions/58418195/rails-5-smtp-sendgrid-451-authentication-failed-could-not-authenticate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!