Jump to content

Problem with PHP Mail encoding


JimStrosky

Recommended Posts

Hello guys. I'm trying to make a mail parser but when i try to parse cyrillic mails i get this type of encoding problem. I dont know why. I'm newbie.

 

This is what i get as mail body...

=D1=82=D0=B5 =D0=BF=D0=BE=D0=BA=D0=B0=D0=BD=D0=B8 =D0=BD=D0=B0 = o_0

 

How can i convert this into utf-8 cyrillic text?

Thanks in advance.

 

This is the script im using:

<?php header ('Content-type: text/html; charset=UTF-8');

$mbox = imap_open ("{localhost:110/pop3/notls}INBOX", "[email protected]", "password", OP_DEBUG);

$message_count = imap_num_msg($mbox);

print "no of msgs: $message_count <br>";

    for ($i = 1; $i <= $message_count; ++$i) {
        $header = imap_header($mbox, $i);

        //$body = trim(substr(imap_body($mbox, $i), 0, 100));


$body = imap_body($mbox, $i);

$body = utf8_decode($body);


        $prettydate = date("jS F Y", $header->udate);

        if (isset($header->from[0]->personal)) {
            $personal = $header->from[0]->personal;
        } else {
            $personal = $header->from[0]->mailbox;
        }


        $email = "$personal <{$header->from[0]->mailbox}@{$header->from[0]->host}>";
        echo "On $prettydate, $email said <br /> \"$body\".<br /><br /><br />";
    };


imap_close($mbox);

?>

Link to comment
https://forums.phpfreaks.com/topic/193311-problem-with-php-mail-encoding/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.