2012-02-09 62 views
2

我已經安裝Sendgrid爲我的Heroku賬戶,但是日誌顯示了以下問題,當應用程序試圖發送郵件:Sendgrid在Heroku錯誤

的Net :: SMTPFatalError(550無法從指定的地址< [接收我在規定的使用devise.rb config.mailer_sender]>的 電子郵件地址: 未驗證發件人不允許

我production.rb設置:

config.action_mailer.delivery_method = :smtp 
    config.action_mailer.raise_delivery_errors = true 
    config.action_mailer.perform_deliveries = true 
    config.action_mailer.default_url_options = { :host => 'heroku.com' } 

    config.action_mailer.smtp_settings = { 
    address: "smtp.sendgrid.net", 
    port: 587, 
    authentication: "plain", 
    user_name: ENV["my sendgrid username"], 
    password: ENV["my sendgrid password"], 
    domain: 'heroku.com' 
    } 

我Sendgrid密碼/從Heroku的使用所獲得的用戶名heroku config -long

沒有人有任何建議,爲那裏的問題可能會在哪裏呢?我如何授予我在config.mailer_sender認證中定義的電子郵件地址?

回答

7

你user_name和密碼需要是關鍵的名稱,而不是值:

config.action_mailer.smtp_settings = { 
    address: "smtp.sendgrid.net", 
    port: 587, 
    authentication: "plain", 
    user_name: ENV["SENDGRID_USERNAME"], 
    password: ENV["SENDGRID_PASSWORD"], 
    domain: 'heroku.com' 
    } 

的想法是,你keep the configuration separate to your code

+1

Jeez。多麼愚蠢。我一直在盯着它幾個小時。非常感謝。 – Undistraction 2012-02-09 16:39:12