JimStrosky Posted February 25, 2010 Share Posted February 25, 2010 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 More sharing options...
The Little Guy Posted February 25, 2010 Share Posted February 25, 2010 Try using this function quoted_printable_decode echo "On $prettydate, $email said <br /> \"".quoted_printable_decode($body)."\".<br /><br /><br />"; Link to comment https://forums.phpfreaks.com/topic/193311-problem-with-php-mail-encoding/#findComment-1017874 Share on other sites More sharing options...
JimStrosky Posted February 25, 2010 Author Share Posted February 25, 2010 Try using this function quoted_printable_decode echo "On $prettydate, $email said <br /> \"".quoted_printable_decode($body)."\".<br /><br /><br />"; Thanks alot The Little Guy, it works perfect now, thank you!!! Link to comment https://forums.phpfreaks.com/topic/193311-problem-with-php-mail-encoding/#findComment-1017883 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.