Tutorial: Decode and solve in PHP quoted-printable characters from plain emails (PHP)

Decode and solve in PHP quoted-printable characters from plain emails

If you handle Mails in PHP they sometimes have a 8bit strings looks like =3D or =0A or =0D etc. when trying to get the plain text mail out of a HTML mail for example. The PHP engine brings a built-in function called quoted_printable_decode() to decode such strings and get the plain, normal looking mail in return.










Decode those bit strings


Let's take this example mail with these bit strings in it:



It's exactly how its supposed to be according to the manual except I changed=
the url of where the .js file is.
Another random mail line is here.
This code would be=
the source. Thanks!

> Mr. Example,
> =0D=0A> does your inserted script look like that
> =0D=0A> =0D=0A> website.url

With the function quoted_printable_decode we could decode now those =0A [...] chars like that:



<?php
$mailString = 'The mail from above';
$decodedMailString = quoted_printable_decode($mailString);

echo $decodedMailString;
?>

The output of the script would look like that now and those special characters got decoded:



It's exactly how its supposed to be according to the manual except I changed the url of where the .js file is.
Another random mail line is here.
This code would be the source. Thanks!

> Mr. Example,
> does your inserted script look like that
> website.url