我在我的Notifier模型(20多封電子郵件)中對所有電子郵件使用了一種佈局......但是有時候我只是想發送一個沒有佈局或html的純文本電子郵件。我似乎無法弄清楚如何?如果我嘗試發送純文本電子郵件,我仍然可以獲得佈局以及電子郵件中的所有HTML。不同佈局的軌道郵件
我正在使用Rails 2.3.8。
我在這裏看到這個猴子補丁...但它似乎表明一個更新版本的軌道已經結束了嗎?如果我可以避免猴子補丁,我並不是真的想要猴子補丁。
Rails - setting multiple layouts for a multipart email with mailer templates
layout "email" # use email.text.(html|plain).erb as the layout
def welcome_email(property)
subject 'New Signup'
recipients property.email
from '[email protected]'
body :property => property
content_type "text/html"
end
def send_inquiry(inquire)
subject "#{inquire.the_subject}"
recipients inquire.ob.email
from "Test on behalf of #{inquire.name} <#{inquire.email}>"
body :inquire => inquire
content_type "text/plain"
end
我也有2個文件。
email.text.html.erb
email.text.plain.erb
它總是使用text.html.erb ......即使是CONTENT_TYPE 「text/plain的」
這可能是一個快速修復,但我仍然喜歡它,如果我能弄清楚爲什麼據說內置的功能不起作用。 IE瀏覽器,當我聲明一個content_type它應該尋找適當的文件? – holden 2010-09-10 16:14:52
我更新了我的答案..不確定,但值得一試。祝你好運。 – Mischa 2010-09-10 17:06:06