1

我正在使用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。

Inline attachment

+0

只是要明確解決或者說解決辦法。在發佈之前,我做了功課。這裏提到的解決方案 - http://stackoverflow.com/questions/8356924/rails-attachments-inline-are-not-shown-correctly-in-gmail,不適用於我。 –

回答

0

嗯,這是工作升級到Rails的4.我能送內嵌圖像沒有任何問題的Rails 4

1

在我的生產應用我們發送使用上述方法內嵌圖像和我的一切工作非常細的我。所以我創建了工作代碼片段的公共要點。請看看它是否對你有幫助。 Gist Public gist with mailers

如果不工作,請嘗試粘貼您的development.log這裏。

感謝

+0

感謝這個Vivek。我曾嘗試指定內聯圖像的MIME類型。但沒有變化。圖像顯示中斷。在development.log文件中不會生成錯誤。 –

相關問題