简体   繁体   English

如何在Rails中设置配置文件以使SendGrid在Heroku中工作? AuthenticationError(535错误:错误的用户名/密码

[英]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_USERNAMEGMAIL_PASSWORD而不是SENDGRID_USERNAMESENDGRID_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.

相关问题 Rails:Net :: SMTPAuthenticationError(535身份验证失败:用户名/密码错误) - Rails : Net::SMTPAuthenticationError (535 Authentication failed: Bad username / password ) Ruby on Rails:错误的用户名/密码? (535 认证失败) - Ruby on Rails: bad username / password? (535 Auth failed) 如何在Heroku上更改Rails应用程序的用户名和密码? - How can I change the username and password of a Rails application on Heroku? Sendgrid在Rails 4上设置 - Sendgrid set up on Rails 4 Ruby on rails电子邮件错误535-5.7.1不接受用户名和密码 - Ruby on rails email error 535-5.7.1 Username and Password not accepted 535-5.7.8 使用 Gmail 的 Rails Mailer 不接受用户名和密码 - 535-5.7.8 Username and Password not accepted in Rails Mailer using Gmail Ruby on Rails:Heroku:如何安装我的宝石? - Ruby on Rails: Heroku: How do I get my gems installed? 错误请求错误 - 使用 SendGrid 和 Rails 6 设置 Heroku 以接收传入电子邮件 - Bad Request Error - Setting up Heroku to receive Incoming Email using SendGrid and Rails 6 Heroku. Sendgrid 插件。 发送邮件时出现 Net::SMTPAuthenticationError (535 Authentication failed: account disabled) 错误 - Heroku. Sendgrid add-on. There is an Net::SMTPAuthenticationError (535 Authentication failed: account disabled) error when sending emails 如何在Heroku上设置pdftk或iText以使用Rails 3? - How to set up pdftk or iText to work with Rails 3 on Heroku?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM