Ruby on rails Net::SMTPAuthenticationError(不接受535-5.7.8用户名和密码)。仅限Openshift生产
我正试图通过gmail/actionmailer发送电子邮件,它在我本地的开发箱上运行得非常好,但是当我尝试在生产服务器上运行相同的代码时,它会给我一个Ruby on rails Net::SMTPAuthenticationError(不接受535-5.7.8用户名和密码)。仅限Openshift生产,ruby-on-rails,openshift,actionmailer,Ruby On Rails,Openshift,Actionmailer,我正试图通过gmail/actionmailer发送电子邮件,它在我本地的开发箱上运行得非常好,但是当我尝试在生产服务器上运行相同的代码时,它会给我一个Net::SMTPAuthenticationError(535-5.7.8用户名和密码不被接受。。我想这是因为gmail拒绝了我来自未知服务器的登录凭据。但我不确定!如何修复它 背景: 我正在使用gem,并在openshift服务器上使用:rhc set env设置环境变量。我已经检查了服务器上是否设置了环境变量 这些问题都很好,但没有解决我的
Net::SMTPAuthenticationError(535-5.7.8用户名和密码不被接受。
。我想这是因为gmail拒绝了我来自未知服务器的登录凭据。但我不确定!如何修复它
背景:
我正在使用gem,并在openshift服务器上使用:rhc set env
设置环境变量。我已经检查了服务器上是否设置了环境变量
这些问题都很好,但没有解决我的问题。我的问题有点不同,因为它只出现在我的服务器上,在我的本地机器上一切正常
发展:
在开发模式下,我安装了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
制作:
制作:
我用git将代码推送到OpenShift repo,服务器重新启动,表面上一切正常。除了当我创建一个新的占位符时,我从服务器得到了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拒绝我从未知服务器登录
在任何人提出建议之前,我已经:
- 尝试并使用该密码。(无效,我现在已切换回常规帐户密码)
Net::SMTPAuthenticationError(535-5.7.8用户名和密码不被接受。
。我想这是因为gmail拒绝了我来自未知服务器的登录凭据。我该如何修复它?结果是,如果你尝试以编程方式每十分钟多次访问它。我想我一定是在测试功能时这样做的
>> 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'