2012-04-07 94 views
4

我安装发送网格启动器为我的heroku应用程序。Heroku上的SendGrid失败

我把这个在我到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:

class Notifier < ActionMailer::Base 

    def notify() 
    mail( 
     :to => "[email protected]", 
     :subject => "New Website Contact", 
     :body => "body", 
     :message => "message", 
     :from => "[email protected]" 
    ) 
    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得到实际的密码和用户名,并硬编码他们,并仍然给了我相同的错误。

+0

您是否已经通过[heroku sendgrid配置](https://devcenter.heroku.com/articles/sendgrid) – 2012-04-07 04:18:09

+0

您的帐户是否已配置? – 2012-04-07 09:34:41

回答

3

我曾试图用命令设置了密码:

heroku config:add SENDGRID_PASSWORD=my-new-password 

但事实证明,这只是改变什么的Heroku已经存储你的密码,它实际上并没有更改您的密码。完成此操作后,您也无法检索您的密码。

我必须做的是删除并重新添加sendgrid添加。

+1

为了说明,'heroku config:add'或'heroku config:set'只是在你的Heroku堆栈上设置一个环境变量。在Ruby中,您可以将其作为ENV ['SENDGRID_PASSWORD']'来访问。您还可以在Heroku上查看环境变量的值:'heroku config:get SENDGRID_PASSWORD' – Dennis 2014-02-12 18:13:16