gpt4 book ai didi

ruby-on-rails - image_tag 在 rails 中以 base64 编码

转载 作者:数据小太阳 更新时间:2023-10-29 08:33:52 26 4
gpt4 key购买 nike

有没有什么办法可以让rails 3.1中的image_tag将图片转为base64格式发送到email中。

如果没有办法做到这一点,谁能告诉我如何发送包含存储在服务器端的图像的电子邮件?如果我只是使用 image_tag 渲染图像,它们不会显示在电子邮件中。

最佳答案

要通过电子邮件发送图像,请使用邮件的附件属性通过邮件发送文件:

attachments['logo.png'] = File.read(Rails.public_path + '/images/logo.png')

此文件将与邮件附件一起发送。要在电子邮件正文中使用此图像,请使用 attachments.inline[],然后在模板 image_tag attachments[].url 中使用。

还要注意 Rails 3 有 issue对于内联附件,所有普通附件在主要电子邮件客户端(如 Thunderbird 或 Outlook)中将不可见。

关于ruby-on-rails - image_tag 在 rails 中以 base64 编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8327727/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com