2015-11-11 170 views
0

我遵循Sujoy Gupta的建議here來使用smtp在rails上發送電子郵件。我沒有在控制檯上發現任何錯誤,但電子郵件似乎從未達到過:那裏的統計數據顯示沒有發送/接收的電子郵件,我從來沒有收到他們在我的收件箱中。 我將此添加到我的配置/環境/ development.rb/test.rb/production.rb:amazon ses ActionMailer ruby​​ on rails debug

config.action_mailer.delivery_method = :smtp 
config.action_mailer.smtp_settings = { 
     :address => "email-smtp.us-west-2.amazonaws.com", 
     :port => 587, 
     :user_name => "...", # My SMTP user here. 
     :password => "...", # My SMTP password here. 
     :authentication => :login, 
     :enable_starttls_auto => true 
    } 

和應用程序/郵寄/ UserMailer.rb:

class UserMailer < ApplicationMailer 
    default from: "[email protected]" 

    def test(email) 
    mail(to: email, subject: 'ses test') 
    end 
end 

這裏是印在控制檯:

UserMailer.test("[email protected]").deliver_now 
    Rendered user_mailer/test.html.erb within layouts/mailer (0.1ms) 

UserMailer#test: processed outbound mail in 16.2ms 

Sent mail to [email protected] (769.1ms) 
Date: Wed, 11 Nov 2015 10:26:33 -0800 
From: [email protected] 
To: [email protected] 
Message-ID: <[email protected]mail> 
Subject: ses test 
Mime-Version: 1.0 
Content-Type: text/html; 
charset=UTF-8 
Content-Transfer-Encoding: 7bit 

<html> 
    <body> 
    <!DOCTYPE html> 
<html> 
    <head> 
    <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /> 
    </head> 
    <body> 
    A quick brown fox jumped over the lazy dog. 
    </body> 
    </html> 
    </body> 
</html> 

=> #<Mail::Message:70263775568080, Multipart: false, Headers: <Date: Wed, 11 Nov 2015 10:26:33 -0800>, <From: [email protected]>, <To: [email protected]>, <Message-ID: <[email protected]mail>>, <Subject: ses test>, <Mime-Version: 1.0>, <Content-Type: text/html>, <Content-Transfer-Encoding: 7bit>> 

繼Java文檔here,我是能夠成功地發送電子郵件使用相同的主機和SMTP用戶名/密碼。

任何想法我可能有錯嗎?我在哪裏可以找到更多日誌來挖掘更多內容?

謝謝!

+0

確保您的服務器設置爲發送電子郵件。我有一個類似的問題,使用一些PHP – Whitecat

回答

0

原來我只是需要關閉並重新打開導軌控制檯。出於某種原因重新加載是不夠的。