我不确定为什么我通过 ActionMailer 发送的带有附件的电子邮件没有显示附件,而是附件的内容只是显示/输出到电子邮件中。
class MyMailer < ActionMailer::Base
default :from => "email@email.com"
def test_email()
attachments['testresult1.html'] = {
:filename => 'testresult1.html',
:body => File.read('C:\\testresult1.html')
}
mail(:to => 'email@email.com',
:subject => 'Cool great message'
)
end
end
电子邮件的输出如下所示
Date: Tue, 17 Apr 2012 14:11:52 +1000
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8;
filename=testresult1.html
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename=testresult1.html
filename: testresult1.html
Content-ID: <4f8ced883c0d9_1b1c30b580813e@PC-049.mail>
然后是 HTML 文件/附件的全部内容。
我希望将 HTML 文件附加到电子邮件中,因为它将附加到普通电子邮件中,并且我应该能够双击附件并在浏览器中打开它。
Email Client = Microsoft Outlook
Connection = SMTP
Rails = 3.2.1
ActionMailer = 3.2.1
Mail = 2.4.4