1

我们通过 PHP5-imap 检索和解析电子邮件,在解析电子邮件时,我们注意到一些电子邮件包含不会自动过滤掉的特殊字符(例如:=2E=换行符之前)

过滤这些字符的最佳方法是什么?

我们使用这部分代码来获取邮件正文:

$structure = imap_fetchstructure(static::$_connection, $msg_id);
$unparsed = imap_fetchbody(static::$_connection, $msg_id, $i + 1);

if ($structure->parts[$i]->encoding == 3) { // 3 = BASE64
    $parsed = base64_decode($unparsed);
}
elseif ($structure->parts[$i]->encoding == 4) { // 4 = QUOTED-PRINTABLE
    $parsed = quoted_printable_decode($unparsed);
}
else {
    $parsed = $unparsed;
}
4

0 回答 0