2012-04-07 97 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