我正在使用 ActionMailer 发送内嵌图像。 user_mailer.rb 文件如下所示:
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 => ["<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="fd89988e89888e988fbd9992909c9493d39e9290" rel="noreferrer noopener nofollow">[email protected]</a>"],:Subject => subject)
end
View 包含:
<%= image_tag attachments['orglogo.png'].url %>
图像没有出现在邮件中。这就是它在邮件客户端中的显示方式。我已经在 Outlook 和 Hotmail 上进行了测试。
最佳答案
在我的生产应用程序中,我们使用上述方法发送内联图像,对我来说一切都工作得很好。所以我为该工作代码片段创建了公共(public)要点。请看看是否对您有帮助。 要点Public gist with mailers
如果不起作用,请尝试将您的development.log粘贴到此处。
谢谢
关于ruby-on-rails - Rails 内联邮件附件无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16564366/