0

第一次尝试从 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--

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

4

1 回答 1

4

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

在开发环境中使用 Rails 3 发送邮件

于 2011-10-18T20:29:24.067 回答