[英]amazon ses ActionMailer ruby on rails debug
我跟着建议, 在这里从Sujoy古普塔使用SMTP发送在轨道上的电子邮件。 我没有在控制台上看到任何错误,但电子邮件似乎从未达到过ses:那里的统计数据显示没有发送/接收电子邮件,我也从未在收件箱中收到它们。 我将此添加到我的config / environments / development.rb / test.rb / production.rb中:
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
}
和app / mailers / UserMailer.rb:
class UserMailer < ApplicationMailer
default from: "user@hotmail.com"
def test(email)
mail(to: email, subject: 'ses test')
end
end
这是控制台中打印的内容:
UserMailer.test("user@hotmail.com").deliver_now
Rendered user_mailer/test.html.erb within layouts/mailer (0.1ms)
UserMailer#test: processed outbound mail in 16.2ms
Sent mail to user@hotmail.com (769.1ms)
Date: Wed, 11 Nov 2015 10:26:33 -0800
From: user@hotmail.com
To: user@hotmail.com
Message-ID: <56438859b7ee2_a6503fe78cc601fc19958@10ddb1e504ea.ant.amazon.com.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: user@hotmail.com>, <To: user@hotmail.com>, <Message-ID: <56438859b7ee2_a6503fe78cc601fc19958@10ddb1e504ea.ant.amazon.com.mail>>, <Subject: ses test>, <Mime-Version: 1.0>, <Content-Type: text/html>, <Content-Transfer-Encoding: 7bit>>
按照此处的Java文档,我能够使用相同的主机和smtp用户名/密码成功发送电子邮件。
知道我可能有什么问题吗? 在哪里可以找到更多日志以进行更多挖掘?
谢谢!
原来,我只需要关闭然后重新打开Rails控制台。 由于某种原因,重新加载是不够的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.