0

html imap_fetchbodyGmail api GET方法的返回格式不同。

我将电子邮件写入文件,然后重新导入 Thunderbird。将imap_fetchbody书面电子邮件加载到Thunderbird时没有填充问题,而API返回的同一电子邮件有填充问题。

我看到的最大区别是3D

这里有几行来自imap_fetchbody

<html lang=3Den><head><meta content=3D"date=3Dno" name=3D"format-detection"=
><meta content=3D"email=3Dno" name=3D"format-detection"><style>.awl a {colo=
r: #FFFFFF; text-decoration: none;}.abml a {color: #000000; font-family: Ro=
boto-Medium,Helvetica,Arial,sans-serif; font-weight: bold; text-decoration:=
 none;}.adgl a {color: rgba(0, 0, 0, 0.87); text-decoration: none;}.afal a =
{color: #b0b0b0; text-decoration: none;}@media screen and (min-width: 600px=
) {.v2sp {padding: 6px 30px 0px;} .v2rsp {padding: 0px 10px;}}</style></hea=
d>

以及方法中的几行GMAIL api GET

<html lang=en><head><meta content="date=no" name="format-detection"><meta 
 content="email=no" name="format-detection"><style>.awl a {color: #FFFFFF; 
 text-decoration: none;}.abml a {color: #000000; font-family: Roboto-
 Medium,Helvetica,Arial,sans-serif; font-weight: bold; text-decoration: 
 none;}.adgl a {color: rgba(0, 0, 0, 0.87); text-decoration: none;}.afal a 
 {color: #b0b0b0; text-decoration: none;}@media screen and (min-width: 
 600px) {.v2sp {padding: 6px 30px 0px;} .v2rsp {padding: 0px 10px;}}</style> 
 </head>`

WhileGmail api GET方法返回base64 encode我通过以下方式转换的版本:

function decode($data)
{
    return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT));
}

两者之间到底有什么区别,为什么真的有区别?

通过 gmail api 获取的邮件的屏幕截图

通过 imap_fetchbody 获取的邮件的屏幕截图

您的评论和答案将不胜感激。

谢谢

4

1 回答 1

0

两者的区别在于imap_fetchbody回报:

它是带引号的可打印文本,可能是通过“哑”邮件客户端的结果。= 用于编码/转义不可打印/元字符,很像 &...; 在 HTML 中使用。=3d 是一个 =: 3d hex = 61 ascii = 等号的引用可打印表示。

参考:imap_fetchbody 带有奇怪字符的 HTML

WhileGmail api GET方法返回base64_encoded的字符串需要是decoded. 我们可以通过以下方式添加相同的quoted-printable效果:

quoted_printable_encode($string)
于 2018-05-04T10:48:25.380 回答