1
我想發送一個包含單個HTML附件的電子郵件。問題是附件HTML出現在電子郵件的正文中,並且該視圖顯示爲附件。幾乎與我預期的相反。發送與ActionMailer的HTML附件3
我能夠正確地發送其他類型的附件,但是當試圖發送一個HTML附件時,它始終顯示而不是「附加」。
class Notifier < ActionMailer::Base
default :from => "[email protected]"
def welcome(email)
attachments['this is an html file.html'] = "<b>yeah this is html!</b>"
mail(:to => email, :subject => "Attempting an attachment")
end
end
而且我app/views/notifier/welcome.html.erb
Hi there! This is <b>html</b> within a view
所得的電子郵件看起來是這樣的:
(注意附件的HTML實際上是顯示在電子郵件正文)
感謝您的信息。我仍然想知道爲什麼顯示附件,並且視圖是以沒有文件名的HTML附件的形式發送的。有些事情是不正確的。通過這個基於Web的郵件客戶端,我可以附加一個html文件,並按預期工作。我認爲我正在用actionmailer做一些不正確的事情。 – olore 2011-05-14 02:47:19