【问题标题】:Rails: Mailer show no error but email goes nowhereRails:邮件程序没有显示错误,但电子邮件无处可去
【发布时间】:2011-12-10 09:05:23
【问题描述】:

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

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

【问题讨论】:

    标签: ruby-on-rails actionmailer mailer


    【解决方案1】:

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

    Sending mail with Rails 3 in development environment

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-29
      • 2020-01-08
      • 2011-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-29
      相关资源
      最近更新 更多