Net::SMTPAuthenticationError(535-5.7.8 用户名和密码未被接受。)仅限 Openshift 生产
Net::SMTPAuthenticationError (535-5.7.8 Username and Password not accepted.) Openshift production only
我正在尝试通过 gmail/actionmailer 发送电子邮件,它在我的本地开发盒上完美运行,但是当我尝试 运行 生产服务器上的相同代码时,它给了我一个 Net::SMTPAuthenticationError (535-5.7.8 Username and Password not accepted.
。我认为这是因为 gmail 拒绝了来自未知 server.But 的我的登录凭据,我不确定!我该如何解决?
背景:
我正在使用 figaro gem,我在 openshift 服务器上设置我的环境变量:rhc set-env
。我检查了服务器上是否设置了环境变量。
问题here, here, and here都很好,但是没有解决我的问题。我的问题有点不同,因为它只出现在我的服务器上,在我的本地机器上一切正常。
发展:
在开发模式下,我安装了 figaro gem,我的配置文件存储在 application.yml 中,未 签入 git.
这是它的内容:
## config/application.yml
# Add configuration values here, as shown below.
gmail_username: 'PLACE_HOLDER_EMAIL@gmail.com'
gmail_password: 'PLACE_HOLDER_PASSWORD'
在我的控制器中:
## PLACEHOLDER_controller.rb
def create
@placeholder = Placeholder.new(placeholder_params)
respond_to do |format|
if @placeholder.save
puts "SENDING..."
puts "Sending to: #{ENV['gmail_username']}..."
PLACEHOLDERMailer.placeholder_email(some, params).deliver
puts "SENT!"
end
end
产量:
## /config/environments/production.rb
# SMTP
config.action_mailer.delivery_method = :smtp
# SMTP settings for gmail
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:user_name => "#{ENV['gmail_username']}",
:password => "#{ENV['gmail_password']}",
:authentication => "plain",
:enable_starttls_auto => true
}
产量:
我使用 git 将代码推送到我的 OpenShift 存储库,服务器重新启动,表面上一切正常。除了当我创建一个新的占位符时,我从服务器返回 500。
这是日志输出:
>> rhc tail -a MY_APP
SENDING...
Sending to: "PLACE_HOLDER_EMAIL@gmail.com"... ## This is the correct email! It's clearly pulling the proper values from ENV.
INFO -- : Rendered placeholder_mailer/placeholder_email.text.erb (0.1ms)
INFO -- :
Sent mail to 9739069711@txt.att.net (132.3ms)
INFO -- : Completed 500 Internal Server Error in 224ms
FATAL -- :
Net::SMTPAuthenticationError (535-5.7.8 Username and Password not accepted. Learn more at
):
app/controllers/placeholders_controller.rb:35:in `block in create'
app/controllers/placeholders_controller.rb:29:in `create'
表示用户名和密码未被接受。现在,我知道我拥有正确的用户名和密码。我很确定这不是问题所在。我怀疑(如链接问题中所述)smtp.gmail.com 拒绝我从未知服务器登录。
在有人建议之前,我已经:
- Disabled Two Factor Authentication
- 尝试 creating an application specific password 并改用它。 (没用,我现在已经切换回普通账号密码了)
- Enabled access to less secure applications.
TL;DR
我正在尝试从服务器发送电子邮件。当我在服务器上 运行 它给我:Net::SMTPAuthenticationError (535-5.7.8 Username and Password not accepted.
。我认为这是因为 gmail 拒绝了我来自未知服务器的登录凭据。我该如何解决?
结果是 gmail blocks you temporarily 如果您尝试以编程方式访问它超过每十分钟一次。我想我一定是在测试功能时这样做的。
我正在尝试通过 gmail/actionmailer 发送电子邮件,它在我的本地开发盒上完美运行,但是当我尝试 运行 生产服务器上的相同代码时,它给了我一个 Net::SMTPAuthenticationError (535-5.7.8 Username and Password not accepted.
。我认为这是因为 gmail 拒绝了来自未知 server.But 的我的登录凭据,我不确定!我该如何解决?
背景:
我正在使用 figaro gem,我在 openshift 服务器上设置我的环境变量:rhc set-env
。我检查了服务器上是否设置了环境变量。
问题here, here, and here都很好,但是没有解决我的问题。我的问题有点不同,因为它只出现在我的服务器上,在我的本地机器上一切正常。
发展:
在开发模式下,我安装了 figaro gem,我的配置文件存储在 application.yml 中,未 签入 git.
这是它的内容:
## config/application.yml
# Add configuration values here, as shown below.
gmail_username: 'PLACE_HOLDER_EMAIL@gmail.com'
gmail_password: 'PLACE_HOLDER_PASSWORD'
在我的控制器中:
## PLACEHOLDER_controller.rb
def create
@placeholder = Placeholder.new(placeholder_params)
respond_to do |format|
if @placeholder.save
puts "SENDING..."
puts "Sending to: #{ENV['gmail_username']}..."
PLACEHOLDERMailer.placeholder_email(some, params).deliver
puts "SENT!"
end
end
产量:
## /config/environments/production.rb
# SMTP
config.action_mailer.delivery_method = :smtp
# SMTP settings for gmail
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:user_name => "#{ENV['gmail_username']}",
:password => "#{ENV['gmail_password']}",
:authentication => "plain",
:enable_starttls_auto => true
}
产量:
我使用 git 将代码推送到我的 OpenShift 存储库,服务器重新启动,表面上一切正常。除了当我创建一个新的占位符时,我从服务器返回 500。
这是日志输出:
>> rhc tail -a MY_APP
SENDING...
Sending to: "PLACE_HOLDER_EMAIL@gmail.com"... ## This is the correct email! It's clearly pulling the proper values from ENV.
INFO -- : Rendered placeholder_mailer/placeholder_email.text.erb (0.1ms)
INFO -- :
Sent mail to 9739069711@txt.att.net (132.3ms)
INFO -- : Completed 500 Internal Server Error in 224ms
FATAL -- :
Net::SMTPAuthenticationError (535-5.7.8 Username and Password not accepted. Learn more at
):
app/controllers/placeholders_controller.rb:35:in `block in create'
app/controllers/placeholders_controller.rb:29:in `create'
表示用户名和密码未被接受。现在,我知道我拥有正确的用户名和密码。我很确定这不是问题所在。我怀疑(如链接问题中所述)smtp.gmail.com 拒绝我从未知服务器登录。
在有人建议之前,我已经:
- Disabled Two Factor Authentication
- 尝试 creating an application specific password 并改用它。 (没用,我现在已经切换回普通账号密码了)
- Enabled access to less secure applications.
TL;DR
我正在尝试从服务器发送电子邮件。当我在服务器上 运行 它给我:Net::SMTPAuthenticationError (535-5.7.8 Username and Password not accepted.
。我认为这是因为 gmail 拒绝了我来自未知服务器的登录凭据。我该如何解决?
结果是 gmail blocks you temporarily 如果您尝试以编程方式访问它超过每十分钟一次。我想我一定是在测试功能时这样做的。