6
5

More than 3 years have passed since last update.

SendGrid の Net::SMTPAuthenticationError: 535 Authentication failed: Bad username / password 解決方法

Posted at

概要

SendGrid で Net::SMTPAuthenticationError: 535 Authentication failed: Bad username / password というエラーが発生したときの解決方法をご紹介します。

エラーメッセージ

Net::SMTPAuthenticationError: 535 Authentication failed: Bad username / password

解決方法 SendGrid API の場合 user_nameapikey

APIキーで送信するときにハマったのですが、APIキーを使って送信する場合にはユーザー名にapikeyを指定しないとSMTPAuthenticationErrorのような認証エラーがでます。
引用元: SendGridを使ってSMTPでメールを送信する方法 | Simple is Beautiful.

smtp_settings が下記のような場合 SMTP_USER は SendGrid API key を発行したページにある情報ではなく apikey という文字列を指定する必要がありました。

  ActionMailer::Base.smtp_settings = {
    user_name:             ENV['SMTP_USER'],
    password:              ENV['SMTP_PASS'],
    domain:                ENV['SMTP_DOMAIN'],
    address:               'smtp.sendgrid.net',
    port:                  587,
    authentication:        :plain,
    enable_starttls_auto:  true
  }

以上、SendGrid で Net::SMTPAuthenticationError: 535 Authentication failed: Bad username / password エラーが発生して困り果てた、現場からお送りしました。

6
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5