我在使用纯 Ruby 发送电子邮件时遇到问题。这是我的脚本的样子:
Mail.defaults do
delivery_method(
:smtp,
address: 'smtp.sendgrid.net',
port: 587,
user_name: 'sendgrid_username',
password: 'sendgrid_password',
authentication: :login,
enable_starttls_auto: false,
openssl_verify_mode: "none"
)
end
Mail.deliver do
from 'Test Email'
to 'user@example.com'
subject 'Here is the image you wanted'
body "Test Email"
end
此脚本引发以下错误:
/Users/mateuszurbanski/.rubies/ruby-2.7.2/lib/ruby/2.7.0/net/smtp.rb:975:in `check_auth_response': 535 Authentication failed: Bad username / password (Net::SMTPAuthenticationError)
我正在使用我的 Ruby on Rails 项目之一的凭据,它们很好。有任何想法吗?