我的Gmail收件箱中的非名字附件

时间:2011-10-28 23:59:54

标签: ruby-on-rails-3 gmail actionmailer multipart multipart-alternative

在使用带有Multipart电子邮件的Rails ActionMailer时,我创建了两个:

approve_trade_email.html.erb

approve_trade_email.text.erb

我确实在我的邮件客户端(Mac OSX)中收到了一封HTML格式的电子邮件,但在检查我的Gmail帐户中是否收到了同一封电子邮件时,我得到了一个带有noname附件的空机身,里面有多部件?

帮助?

为什么我会在Gmail中收到此内容?

THX

乔尔

这是GMAIL中的非活动附件:

----==_mimepart_4eab3a61bb3a8_10583ff27b4e363c43018
Date: Sat, 29 Oct 2011 01:27:29 +0200
Mime-Version: 1.0
Content-Type: text/plain;
 charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Content-ID: <4eab3a61bc857_10583ff27b4e363c43191@joel-maranhaos-macbook-pro.local.mail>


Do not to forget to make a donation on our Site: /home/index?path_only=false


----==_mimepart_4eab3a61bb3a8_10583ff27b4e363c43018
Date: Sat, 29 Oct 2011 01:27:29 +0200
Mime-Version: 1.0
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Content-ID: <4eab3a61bd5fa_10583ff27b4e363c432cb@joel-maranhaos-macbook-pro.local.mail>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>  
<link href="/assets/powerplants.css" media="screen" rel="stylesheet" type="text/css" />

</head>
<body id="email">      

<p><b>Do not to forget to make a donation on our <a href="/home/index?path_only=false">Site</a>.</b></p>

</body>
</html>
----==_mimepart_4eab3a61bb3a8_10583ff27b4e363c43018--

1 个答案:

答案 0 :(得分:2)

我遇到了同样的问题并找到了解决方案:

这是Rails 3的旧ActionMailer API中的一个错误,它不包含邮件头中的多部分边界定义。

请参阅:https://github.com/rails/rails/pull/3090

您只需使用新API(使用mail方法)

class UserMailer < ActionMailer::Base
  default :from => "notifications@example.com"

  def welcome_email(user)
    @user = user
    @url  = "http://example.com/login"
    mail(:to => user.email, :subject => "Welcome to My Awesome Site")
  end
end