ruby-on-rails – Heroku上的SendGrid失败
发布时间:2020-12-17 02:17:36 所属栏目:百科 来源:网络整理
导读:我为我的heroku app设置了发送网格启动器. 我把它放在我的config / environment.rb中: ActionMailer::Base.smtp_settings = { :user_name = ENV["SENDGRID_USERNAME"],:password = ENV["SENDGRID_PASSWORD"],:domain = "my-sites-domain.com",:address = "s
我为我的heroku app设置了发送网格启动器.
我把它放在我的config / environment.rb中: ActionMailer::Base.smtp_settings = { :user_name => ENV["SENDGRID_USERNAME"],:password => ENV["SENDGRID_PASSWORD"],:domain => "my-sites-domain.com",:address => "smtp.sendgrid.net",:port => 587,:authentication => :plain,:enable_starttls_auto => true } 我创建了这个类models / notifier.rb: class Notifier < ActionMailer::Base def notify() mail( :to => "my-email@gmail.com",:subject => "New Website Contact",:body => "body",:message => "message",:from => "website@my-sites-domain.com" ) end end 我把它放在另一个控制器发送电子邮件: def contact Notifier.notify().deliver redirect_to("/",:notice => "We Have Received Your Request And Will Contact You Soon.") end 当我部署并尝试发送电子邮件时,我收到此错误: Net :: SMTPAuthenticationError(535身份验证失败:用户名/密码错误 我已完全设置发送网格,它说我准备发送电子邮件. 我还运行了heroku config –long来获取实际的密码和用户名并对其进行硬编码,这仍然给了我同样的错误. 解决方法
我曾尝试使用以下命令设置密码:
heroku config:add SENDGRID_PASSWORD=my-new-password 但事实证明这只会改变heroku存储的密码,它实际上并没有改变你的密码.执行此操作后,您也无法检索密码. 我要做的是删除并重新添加sendgrid添加. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |