我为我的Heroku帐户设置了Sendgrid,但是当应用尝试发送邮件时,日志会显示以下问题:
Net :: SMTPFatalError(550无法从指定的地址接收< [the 我在devise.rb中使用config.mailer_sender指定的电子邮件地址>: 未经身份验证的发件人不允许
我的production.rb设置为:
config.action_mailer.delivery_method = :smtp
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = { :host => 'heroku.com' }
config.action_mailer.smtp_settings = {
address: "smtp.sendgrid.net",
port: 587,
authentication: "plain",
user_name: ENV["my sendgrid username"],
password: ENV["my sendgrid password"],
domain: 'heroku.com'
}
我的Sendgrid密码/用户名是使用heroku config -long
有没有人对问题所在的位置有任何建议?如何授予我在config.mailer_sender身份验证中定义的电子邮件地址?
答案 0 :(得分:8)
您的用户名和密码必须是键名,而不是值:
config.action_mailer.smtp_settings = {
address: "smtp.sendgrid.net",
port: 587,
authentication: "plain",
user_name: ENV["SENDGRID_USERNAME"],
password: ENV["SENDGRID_PASSWORD"],
domain: 'heroku.com'
}