[英]How do I set up my config files in Rails to get SendGrid to work in Heroku? AuthenticationError (535 failed: Bad username / password
I'm trying to set up active mailer functionality in my Rails app with Devise and SendGrid so that users can receive a confirmation email when they sign up and can request a forgot password link. 我正在尝试使用Devise和SendGrid在我的Rails应用程序中设置活动的邮件发送器功能,以便用户注册时可以收到确认电子邮件,并可以请求忘记密码的链接。 When I deploy to Heroku and try and sign up I get an error when I hit 'sign up'.
当我部署到Heroku并尝试注册时,当我点击“注册”时会收到错误消息。 In the Heroku logs the I can see that there is an error as follows:
在Heroku日志中,我可以看到有如下错误:
Completed 500 Internal Server Error in 547ms (ActiveRecord: 8.1ms)
Net::SMTPAuthenticationError (535 Authentication failed: Bad username / password
It's probably something to do with the way I have my config files but I can't put my finger on it. 这可能与我拥有配置文件的方式有关,但我对此一无所知。 Any help would be massively appreciated!
任何帮助将不胜感激! Here are my files.
这是我的文件。
config/application.yml 配置/ application.yml
production:
SECRET_KEY_BASE: <%= ENV["SECRET_KEY_BASE"] %>
development:
GMAIL_USERNAME: scott.ian.munro@gmail.com
GMAIL_PASSWORD: password
SENDGRID_USERNAME: app115625999@heroku.com
SENDGRID_PASSWORD: password
test:
GMAIL_USERNAME: scott.ian.munro@gmail.com
GMAIL_PASSWORD: password
SENDGRID_USERNAME: app115625999@heroku.com
SENDGRID_PASSWORD: password
production:
GMAIL_USERNAME: scott.ian.munro@gmail.com
GMAIL_PASSWORD: password
SENDGRID_USERNAME: app115625999@heroku.com
SENDGRID_PASSWORD: password
I'm using the figaro
gem to manage my environment variables. 我正在使用
figaro
gem管理我的环境变量。
Your problem appears to be that you're referencing GMAIL_USERNAME
and GMAIL_PASSWORD
instead of SENDGRID_USERNAME
and SENDGRID_PASSWORD
, and you're still referencing the Gmail SMTP server and port. 您的问题似乎是您引用的是
GMAIL_USERNAME
和GMAIL_PASSWORD
而不是SENDGRID_USERNAME
和SENDGRID_PASSWORD
,而您仍在引用Gmail SMTP服务器和端口。
Assuming you're using this gem: https://github.com/stephenb/sendgrid , this should do the trick for your production config file: 假设您正在使用以下gem: https : //github.com/stephenb/sendgrid ,这应该可以解决您的生产配置文件:
config.action_mailer.smtp_settings = {
address: "smtp.sendgrid.com",
port: 25,
domain: "heroku.com",
authentication: :plain,
user_name: ENV["SENDGRID_USERNAME"],
password: ENV["SENDGRID_PASSWORD"],
}
Update: per you comment that you're using the figaro
gem, make sure to run the rake task that adds the ENV
variables to Heroku: rake figaro:heroku
更新:根据您的评论,您正在使用
figaro
gem,请确保运行将ENV
变量添加到Heroku的rake任务: rake figaro:heroku
I use more params too: 我也使用更多参数:
ActionMailer::Base.smtp_settings = { . ActionMailer :: Base.smtp_settings = { .
。 .
。 enable_starttls_auto: true, openssl_verify_mode: "none" }
enable_starttls_auto:true,openssl_verify_mode:“ none”}
:) :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.