我想通过 PHP 发送带有内联/嵌入式图像(又名 cid)的邮件。邮件已成功发送并在 Gmail 中正确接收。但是,在 Thunderbird(适用于 Windows 的最新版本)中,不会显示内联/嵌入图像。
我遵循了 this 中给出的信息线程,但它仍然不起作用。因此,内联/嵌入图像显示在 Gmail 中,但不显示在 Thunderbird 中。有人知道这里的问题吗?
To: example@example.com
Subject: Test
From: noreply@test.com <noreply>
MIME-Version: 1.0
Content-Type: multipart/related; boundary="52cd9ebf4fb8c9b0547e93b82b3f3f6b"
--52cd9ebf4fb8c9b0547e93b82b3f3f6b
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test mail</title>
</head>
<body>
<img src="cid:myImage" alt="This is a embedded image" />
</body>
</html>
--52cd9ebf4fb8c9b0547e93b82b3f3f6b
Content-Type: image/jpg; name="myImage.jpg"
Content-Transfer-Encoding: base64
Content-ID: <myImage>
Content-Disposition: inline; filename="myImage.jpg"
[base64 encoded string goes here.]
--52cd9ebf4fb8c9b0547e93b82b3f3f6b--
最佳答案
嗯……在RFC 1521说 Content-Type header 的格式是这样的
The formal grammar for the content-type header field for text is as
follows:text-type := "text" "/" text-subtype [";" "charset" "=" charset]
text-subtype := "plain" / extension-token
charset := "us-ascii"/ "iso-8859-1"/ "iso-8859-2"/ "iso-8859-3" / "iso-8859-4"/ "iso-8859-5"/ "iso-8859-6"/ "iso-8859-7" / "iso-8859-8" / "iso-8859-9" / extension-token ; case insensitive
我的意思是内容类型,然后是字符集 但是你把
Content-Type: image/jpg; name="myImage.jpg"
所以...这可能会破坏您的形象... 另一个建议是将您的内容 ID 小写而不是驼峰式
问候 埃米利亚诺
关于PHP - Thunderbird 中不显示内联图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40442860/