PHP Reading POP Account - How to decode utf8 with php

Discussion in 'Email Discussions' started by esnagel, Jun 28, 2012.

  1. esnagel

    esnagel Director of Common Sense

    Joined:
    Oct 23, 2008
    Messages:
    20
    Likes Received:
    0
    I've got my PHP script reading a POP account, and I can pull everything out nicely, but I'm getting some strange subject lines. Here are two:

    Code:
    Subject: =?utf-8?Q?It=27s=20time=20to=20brighten=20your=20weekends...=20Launching=20Blooms=20to=20Go=21=20=3A=29?=
    Subject: =?UTF-8?B?RFZEIERpc2Mtby1yYW1hIOKAlCBGbGlja3MgVW5kZXIg?= =?UTF-8?B?JDchIFRoZSBTb24gb2YgQnV5bmFuemEgU3RyaWtlcyE=?=
    Now the first one, I can almost make out:

    PHP:
    php > echo(quoted_printable_decode("=?utf-8?Q?It=27s=20time=20to=20brighten=20your=20weekends...=20Launching=20Blooms=20to=20Go=21=20=3A=29?="));
    =?
    utf-8?Q?It's time to brighten your weekends... Launching Blooms to Go! :)?
    But doing the same thing for the second, I get junk

    PHP:
    php > echo(quoted_printable_decode("?UTF-8?B?RFZEIERpc2Mtby1yYW1hIOKAlCBGbGlja3MgVW5kZXIg?= =?UTF-8?B?JDchIFRoZSBTb24gb2YgQnV5bmFuemEgU3RyaWtlcyE=?="));
    ?
    UTF-8?B?RFZEIERpc2Mtby1yYW1hIOKAlCBGbGlja3MgVW5kZXIg?= =?UTF-8?B?JDchIFRoZSBTb24gb2YgQnV5bmFuemEgU3RyaWtlcyE=?
    I've also tried utf8_decode() and didn't get any closer. Any ideas how I can read these subjects?

    Thanks,
    Eric
     


  2. esnagel

    esnagel Director of Common Sense

    Joined:
    Oct 23, 2008
    Messages:
    20
    Likes Received:
    0
    Ray helped me out, and here's what we figured out:

    So the one line, we use quoted_printable_decode and the other, use imap_base64.

    PHP:
    php var_dump(quoted_printable_decode('It=27s=20time=20to=20brighten=20your=20weekends...=20Launching=20Blooms=20to=20Go=21=20=3A=29'));
    string(65"It's time to brighten your weekends... Launching Blooms to Go! :)"
    PHP:
    php var_dump(imap_base64('RFZEIERpc2Mtby1yYW1hIOKAlCBGbGlja3MgVW5kZXIgJDchIFRoZSBTb24gb2YgQnV5bmFuemEgU3RyaWtlcyE='));
    string(65"DVD Disc-o-rama รข Flicks Under $7! The Son of Buynanza Strikes!"
     

Want to reply or ask your own question?

It only takes a minute to sign up (and it's free!). Click the orange sign up button to choose a username and then you can ask your own questions on the forum.
Loading...