5

雖然使用Rails的ActionMailer與我創建了兩個多部分郵件:NONAME附件

approve_trade_email.html.erb

approve_trade_email.text.erb

我不接受一個在我的郵件客戶端(Mac OSX)中格式良好的電子郵件,但當檢查我的Gmail帳戶的同一封電子郵件時,我得到一個空的身體與內部多部分noname attachissment?

幫助?

爲什麼我在Gmail中得到這個?

THX

喬爾

這裏的NONAME ATTACHEMENT在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: <[email protected]ocal.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: <[email protected]ocal.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-- 
+0

我目前有一個非常類似的配置同樣的問題,你有沒有找到一個解決方案? –

回答

2

我得到了同樣的問題,找到了解決辦法:

這是舊的ActionMailer API中的錯誤Rails 3,它不包含郵件頭中的多部分邊界定義。

見:https://github.com/rails/rails/pull/3090

你只需要使用新的API(使用mail法)

class UserMailer < ActionMailer::Base 
    default :from => "[email protected]" 

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

它現在適用於郵件方式!多謝!!! – zabumba