【问题标题】:Embed blob Image from database by phpMailer通过phpMailer从数据库中嵌入blob图像
【发布时间】:2012-03-12 13:57:51
【问题描述】:

我将图像作为 BLOB 数据保存在数据库中。如何使用 phpMailer 将它们嵌入到 html 电子邮件中?

PhpMailer 有一个使用 AddEmbeddedImage 嵌入普通图像的功能,它需要“path”、“cid”和“name”,我只有一串 blob 数据,所以它不起作用。我能想到的唯一方法是在使用 AddEmbeddedImage 之前从字符串临时生成图像,但担心它可能会增加执行时间。

请问有人有更好的主意吗?

【问题讨论】:

    标签: php image email blob phpmailer


    【解决方案1】:

    AddStringAttachment() 在主要的PHPmailer 文档中没有记录。它允许来自字符串而不是文件的附件。不知道你是否可以通过src="cid:..." 的东西来参考这个附加的图像,但至少你可以将文件附加到电子邮件中,而不必先将它写到临时文件中。

    这里的 phpmailer 教程中有一些关于它的介绍:http://phpmailer.worxware.com/index.php?pg=tutorial

    【讨论】:

    • 谢谢 Marc,我试过了,电子邮件确实附上了,但我不知道如何让 CID 将图像链接到电子邮件中。
    • 这不是无证的; it's right here.
    猜你喜欢
    • 2015-07-28
    • 1970-01-01
    • 2016-10-09
    • 1970-01-01
    • 2021-12-20
    • 2021-10-31
    • 1970-01-01
    • 1970-01-01
    • 2012-07-16
    相关资源
    最近更新 更多