[ruby] 535 5.7.0 Authentication failed. (Net::SMTPAuthenticationError)

はじめに

いきなりメールが送られなくなった…

エラー内容

/Users/user/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/net-smtp-0.3.1/lib/net/smtp.rb:1071:in `check_auth_response': 535 5.7.0 Authentication failed. (Net::SMTPAuthenticationError)
	from /Users/user/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/net-smtp-0.3.1/lib/net/smtp.rb:828:in `auth_plain'
	from /Users/user/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/net-smtp-0.3.1/lib/net/smtp.rb:820:in `public_send'
	from /Users/user/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/net-smtp-0.3.1/lib/net/smtp.rb:820:in `authenticate'
	from /Users/user/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/net-smtp-0.3.1/lib/net/smtp.rb:653:in `do_start'
	from /Users/user/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/net-smtp-0.3.1/lib/net/smtp.rb:604:in `start'
	from /Users/user/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/mail-2.7.1/lib/mail/network/delivery_methods/smtp.rb:109:in `start_smtp_session'
	from /Users/user/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/mail-2.7.1/lib/mail/network/delivery_methods/smtp.rb:100:in `deliver!'
	from /Users/user/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/mail-2.7.1/lib/mail/message.rb:276:in `deliver!'
	from mail.rb:23:in `<main>'

解決方法

メールのパスワードを再設定して解決!
たしかに「Authentication failed」やったけど、、、えっ?乗っ取られてた?!

おわりに

パスワードは複雑なものにしなきゃだなぁ

参考

rubyでテスト用のスクリプトをさっと書いて確認してみただ

# mail.rb
require 'mail'

options = {
  address: 'smtp.xxxxx.com',
  domain: 'example.com',
  port: 587,                   
  user_name: 'test@example.com', 
  password: 'xxxxxxx',   
  authentication: :login,
}

mail = Mail.new do
  from    'test@example.com'  
  to      'munakata@example.com'  
  subject 'title'   
  body    'body.'  
end

mail.delivery_method(:smtp, options)
mail.deliver!

`ruby mail.rb` 認証情報があってるかさっと確認

コメント

タイトルとURLをコピーしました