1

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;
}
Sander
  • 1,402
  • 2
  • 21
  • 44
  • That *is* quoted-printable encoding. Do you mean that your current code doesn't recognise the encoding properly, or that the quoted_printable_decode() function omits certain bits? In any case, since you are already using IMAP you might want to try `imap_qprint()` instead. – Álvaro González Mar 29 '16 at 08:57

0 Answers0