Heroku 上的 SendGrid 失败 [英] SendGrid on Heroku fails

查看:41
本文介绍了Heroku 上的 SendGrid 失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我的 heroku 应用设置了发送网格启动器.

I setup send grid starter for my heroku app.

我把它放在我的 config/environment.rb 中:

I put this in my 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
}

我创建了这个类模型/notifier.rb:

I create this class 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

我把它放在另一个控制器中发送电子邮件:

I put this in another controller to send the email:

def contact
  Notifier.notify().deliver
  redirect_to("/", :notice => "We Have Received Your Request And Will Contact You Soon.")
end

当我部署并尝试发送电子邮件时,我收到此错误:

When I deploy and try to send an email I get this error:

Net::SMTPAuthenticationError (535 Authentication failed: Bad username/password

我已完全设置发送网格,它说我已准备好发送电子邮件.

I have setup send grid completely and it says I am ready to send emails.

我还运行了 heroku config --long 来获取实际的密码和用户名并对它们进行硬编码,但仍然给了我同样的错误.

I also ran heroku config --long to get the actual password and user name and hard coded them and that still gave me the same error.

推荐答案

我曾尝试使用以下命令设置密码:

I had tried to set my password with the command:

heroku config:add SENDGRID_PASSWORD=my-new-password

但事实证明,这只会更改heroku 存储为您的密码的内容,实际上并不会更改您的密码.执行此操作后,您也无法找回密码.

But it turns out this only changes what heroku has stored as your password, it doesn't actually change your password. You also cannot retrieve your password after doing this.

我必须删除并重新添加 sendgrid 插件.

What I had to do was remove and re-add the sendgrid add on.

这篇关于Heroku 上的 SendGrid 失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆