We retrieve and parse e-mails via PHP5-imap, and when parsing e-mails, we noticed that some of the e-mails contain special characters which are not filtered out automatically (ex: =2E
or =
before a line break)
What is the best way to filter these characters out ?
We're using this section of code to get the mail body:
$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;
}