xer*_*gun 7 ruby email gmail ruby-on-rails
我很确定我已经正确配置了所有内容,但是我不断收到“Net::SMTPAuthenticationError: 535-5.7.8 用户名和密码不被接受”的消息。在尝试通过我的 rails 应用程序发送邮件时出错,了解更多信息。此外,错误消息中的“at”后面只有一个空格,所以我什至不知道在哪里查找更多信息。我也 100% 确定密码和电子邮件是正确的。
在我的 config/development.rb (我在 application.rb 中也有这个)
config.action_mailer.delivery_method = :smtp
# SMTP settings for gmail
config.action_mailer.smtp_settings = {
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'gmail.com',
:user_name => 'username@gmail.com',
:password => 'password',
:authentication => 'plain',
:enable_starttls_auto => true
}
Run Code Online (Sandbox Code Playgroud)
我允许在实际的 gmail 帐户上访问安全性较低的应用程序。
小智 5
这是适用于我的 Google 企业应用程序的配置。尝试将端口更改为 465
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
tls: true,
address: ENV["EMAIL_URL"],
port: 465,
domain: ENV["EMAIL_DOMAIN"],
user_name: ENV["EMAIL_USER_NAME"],
password: ENV["EMAIL_PASSWORD"],
authentication: 'plain',
enable_starttls_auto: true }
Run Code Online (Sandbox Code Playgroud)