2011-11-02 96 views
4

我試圖通過sendgrid從Heroku上的Rails應用程序上的ruby發送郵件。 這是一個只嘗試發送測試電子郵件的獨立應用程序。我沒有收到任何錯誤,但郵件沒有發送。感謝您的幫助。郵件未發送:使用Ruby on Rails的heroku上的sendgrid

== config/environment.rb === 
    ActionMailer::Base.smtp_settings = { 
    :user_name => ENV['SENDGRID_USERNAME'], 
    :password => ENV['SENDGRID_PASSWORD'], 
    :domain => ENV['SENDGRID_DOMAIN'], 
    :address => "smtp.sendgrid.net", 
    :port => 587, 
    :authentication => :plain, 
} 
=== 

==== config/environments/production.rb === 
    config.action_mailer.delivery_method = :smtp 
    config.action_mailer.raise_delivery_errors = true 
===== 

== app/models/notifier.rb == 
    class Notifier < ActionMailer::Base 

    include SendGrid 

    default from: "[email protected]" 
    #sendgrid_category :use_subject_lines 
    #sengrid_enable :ganalytics, :opentrack 

    def test_notification 
     mail(:to => "[email protected]", :subject => "mail from heroku") 
     puts("Sent mail from notifier") 
    end 

    end 
======== 

我試圖從Heroku的控制檯

>> Notifier.test_notification 

(此打印出一些日誌信息。)

#<Mail:Message:279922420, Multipart: false, Headers: <from.., To, Subject, etc). 

運行test_notification方法,但send_grid不報告發出的任何郵件從我的帳戶。我沒有收到電子郵件。

我也嘗試通過調用/ home/index/controller中的test_notification來發送郵件,這將在訪問應用程序的主頁時發送。作爲發送要麼

=== 
class HomeController < ApplicationController 
def index 
Notifier.test_notification() 
end 

end 

=== 

統計不報告的郵件。任何幫助是極大的讚賞。

謝謝! DS

+0

我有同樣的問題。我認爲整合剛剛破裂。我寫了支持。我們會看看那是怎麼回事。 – devinfoley

+0

你們是否能夠弄清楚這一點?我有同樣的問題。 – hajpoj

回答

0

確保你有一個SendGrid附加到你的Heroku.To代碼

user_name => ENV['SENDGRID_USERNAME'], 
:password => ENV['SENDGRID_PASSWORD'], 
:domain => ENV['SENDGRID_DOMAIN'], 

細節應該是你sendgrid用戶名,密碼和域名

+0

是域的必要?這是做什麼的? – Jwan622

相關問題