Rails:Mailer显示没有错误,但电子邮件无处可去

时间:2011-10-18 19:18:06

标签: ruby-on-rails actionmailer mailer

每次尝试从Rails发送电子邮件时。它似乎工作所有人都希望电子邮件永远不会被送达。

所以这是邮件类:

class UserMailer < ActionMailer::Base
  default :from => "contact@triplingo.com"

  def purchase_email(name, email, txid, itemname, code)
    @name = name
    @txId = txid
    @itemName = itemname
    @code = code
    @email = email[1].gsub("%", "@")
    mail(:to => @email, :subject => "Thank you for your purchase")
  end

end

我在控制器中调用它:

UserMailer.purchase_email(@name, @email, @txId, @itemName, @code).deliver

没有错误,事实上我在控制台中得到了很好的反馈:

Rendered user_mailer/purchase_email.html.erb (0.6ms)
Rendered user_mailer/purchase_email.text.erb (0.5ms)

Sent mail to ross@triplingo.com (25ms)
Date: Tue, 18 Oct 2011 14:40:03 -0400
From: contact@triplingo.com
To: ross@triplingo.com
Message-ID: <4e9dc803a34b2_1f83ffc0d5d19f4487bd@RossRankins-MacBook-Pro.local.mail>
Subject: Thank you for your purchase
Mime-Version: 1.0
Content-Type: multipart/alternative;
 boundary="--==_mimepart_4e9dc8038ee3f_1f83ffc0d5d19f4484b3";
 charset=UTF-8
Content-Transfer-Encoding: 7bit

----==_mimepart_4e9dc8038ee3f_1f83ffc0d5d19f4484b3
Date: Tue, 18 Oct 2011 14:40:03 -0400
Mime-Version: 1.0
Content-Type: text/plain;
 charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-ID: <4e9dc803a179e_1f83ffc0d5d19f448553@RossRankins-MacBook-Pro.local.mail>

-<snip>-

----==_mimepart_4e9dc8038ee3f_1f83ffc0d5d19f4484b3
Date: Tue, 18 Oct 2011 14:40:03 -0400
Mime-Version: 1.0
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-ID: <4e9dc803a27fc_1f83ffc0d5d19f44864b@RossRankins-MacBook-Pro.local.mail>

<!DOCTYPE html>
<html>
 -<snip>-

----==_mimepart_4e9dc8038ee3f_1f83ffc0d5d19f4484b3--

那么我该如何开始诊断问题呢?谢谢!

1 个答案:

答案 0 :(得分:4)

默认情况下,Rails实际上并不在开发环境中发送电子邮件。如果您想要在开发中发送电子邮件,那么您应该按照此问题中的步骤进行操作:

Sending mail with Rails 3 in development environment