【发布时间】:2014-11-16 18:16:13
【问题描述】:
在我的应用程序中,我设置了 sendgrid SMTP 服务。我正在使用 Figaro gem 为 SMTP 配置设置 ENV 变量。
在开发模式下一切正常 - 我可以发送电子邮件。但是当我在 Linode 上部署到我的 VPS 时,每次我尝试发送邮件时都会得到:
Net::SMTPAuthenticationError (535 Authentication failed: Bad username / password
在生产服务器的 Rails 控制台上,我可以验证 ENV["GRID_USER'] 和 ENV["GRID_PASS"] 是否正确。当我检查Figaro.env.grid_user 和Figaro.env.grid_pass(在生产模式下)时,我得到的结果相同。
凭据正确。
身份验证失败的原因可能是什么,令人惊讶的是仅在生产模式下?
在这里你可以在production.rb 中看到我的 smtp 配置:
config.action_mailer.smtp_settings = {
address: "smtp.sendgrid.net",
user_name: ENV['GRID_USER'],
password: ['GRID_PASS'],
domain: "why.bio",
port: 587,
authentication: 'plain',
enable_starttls_auto: true
}
这是我在application.yml 中声明我的凭据的方式:
GRID_USER: "MySendGridUserName"
GRID_PASS: "very_wierd_password"
我在 StackOverflow 和许多博客中检查了数百个问题,但找不到解决方案。
【问题讨论】:
标签: ruby-on-rails email ruby-on-rails-4 sendgrid