2015-11-11 153 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

原来我只是需要关闭并重新打开导轨控制台。出于某种原因重新加载是不够的。