简体   繁体   English

亚马逊ses ActionMailer红宝石在Rails上调试

[英]amazon ses ActionMailer ruby on rails debug

I followed the recommendation here from Sujoy Gupta to use smtp to send emails on rails. 我跟着建议, 在这里从Sujoy古普塔使用SMTP发送在轨道上的电子邮件。 I get no error on the console but the emails never seem to have reached ses: The statistics there show no email sent/received and I never got them in my inbox either. 我没有在控制台上看到任何错误,但电子邮件似乎从未达到过ses:那里的统计数据显示没有发送/接收电子邮件,我也从未在收件箱中收到它们。 I added this to my config/environments/development.rb/test.rb/production.rb: 我将此添加到我的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
  }

and app/mailers/UserMailer.rb: 和app / mailers / UserMailer.rb:

class UserMailer < ApplicationMailer
  default from: "user@hotmail.com"

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

Here is what printed in the console: 这是控制台中打印的内容:

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>>

Following the java documentation here , I was able to send an email successfully using the same host and smtp username/password. 按照此处的Java文档,我能够使用相同的主机和smtp用户名/密码成功发送电子邮件。

Any idea what I might have wrong? 知道我可能有什么问题吗? Where can I find more logs to dig more into it? 在哪里可以找到更多日志以进行更多挖掘?

Thanks! 谢谢!

Turns out I just needed to close and reopen the rails console. 原来,我只需要关闭然后重新打开Rails控制台。 For some reason reloading it is not enough. 由于某种原因,重新加载是不够的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM