Open GoogleCodeExporter opened 8 years ago
Any updates?
Original comment by ilyakono...@gmail.com
on 5 Mar 2011 at 11:42
I too face same kind of some problem. But not sure whether it is BASE64
encoding or not. I receive garbage characters as Subject
"J֠y�����nW�y�b���������" What can i do?
Help Please?
Original comment by arunkuma...@gmail.com
on 21 Apr 2011 at 5:45
same problem
Original comment by epicgo...@gmail.com
on 27 Feb 2012 at 12:41
Same problem being faced
Original comment by m4ma...@gmail.com
on 20 Mar 2012 at 7:32
Same issue
Original comment by martin.a...@lemonhq.com
on 2 May 2012 at 9:35
You can get the decoded content of that message using:
$to = iconv_mime_decode($Parser->getHeader('to'), 0, "UTF-8");
$from = iconv_mime_decode($Parser->getHeader('from'), 0, "UTF-8");
$subject = iconv_mime_decode($Parser->getHeader('subject'), 0, "UTF-8");
$html = iconv($Parser->getMessageEncoding('html'), "UTF-8",
$Parser->getMessageBody('html'));
$text = iconv($Parser->getMessageEncoding('text'), "UTF-8",
$Parser->getMessageBody('text'));
$attachments = $Parser->getAttachments();
You have to add this to MimeMailParser.class.php:
public function getMessageEncoding($type = 'text', $attach = "NO") {
$body = false;
$mime_types = array(
'text'=> 'text/plain',
'html'=> 'text/html'
);
if (in_array($type, array_keys($mime_types))) {
foreach($this->parts as $part) {
if ($this->getPartContentType($part) == $mime_types[$type]) {
$headers = $this->getPartHeaders($part);
switch($attach) {
case "NO":
if((!substr(trim($headers['content-disposition']),0,10) == "attachment"))
$body .= $this->getPartContentCharset($part);
break;
case "ONLY":
if((substr(trim($headers['content-disposition']),0,10) == "attachment"))
$body .= $this->getPartContentCharset($part);
break;
default: // YES
$body .= $this->getPartContentCharset($part);
break;
};// switch($atatch)
}
}
} else {
throw new Exception('Invalid type specified for MimeMailParser::getMessageBody. "type" can either be text or html.');
}
return $body;
}
I also used a fix from here:
http://code.google.com/p/php-mime-mail-parser/issues/detail?id=18#c2
Original comment by peter.pe...@gmail.com
on 29 Oct 2012 at 8:22
I forgot to mention that you should also add this to MimeMailParser.class.php:
private function getPartContentCharset($part) {
if (isset($part['content-charset'])) {
return $part['content-charset'];
}
return false;
}
Original comment by peter.pe...@gmail.com
on 29 Oct 2012 at 8:28
Original issue reported on code.google.com by
ilyakono...@gmail.com
on 23 Feb 2011 at 6:28