我正在使用ActionMailer發送嵌入式圖像。該user_mailer.rb文件看起來像這樣:Rails嵌入式郵件附件無法正常工作
def welcome_mail(user, mail_content, subject)
@user = user
@mail_content = mail_content.html_safe
attachments.inline['orglogo.png'] = File.read("#{Rails.root}/app/assets/images/orglogo.png")
mail(:to => ["[email protected]"],:Subject => subject)
end
和視圖包含:
<%= image_tag attachments['orglogo.png'].url %>
圖像沒有在郵件中出現。這是它在郵件客戶端中的顯示方式。我已經測試了Outlook和Hotmail。
只是要明確解決或者說解決辦法。在發佈之前,我做了功課。這裏提到的解決方案 - http://stackoverflow.com/questions/8356924/rails-attachments-inline-are-not-shown-correctly-in-gmail,不適用於我。 –