Alaa Gamal
Alaa Gamal

Reputation: 1125

mail parsing subject encoding

i am using this class https://code.google.com/p/php-mime-mail-parser

to parse emails

class is fully of problems

today i found big one

i have just recieved message from gmail now

message subject is encoded, and i can't decode it!

Subject: =?windows-1256?B?4+XjIMzPx/AgyO3kx8ogys7VIMfhz+bj7eQ=?=
From: Some One <[email protected]>

i can't decode the subject..

any one know a better mail parsing class?

IF NO: How can i decode this subject?

Upvotes: 1

Views: 825

Answers (2)

Folke
Folke

Reputation: 21

more flexible:

$x = "=?windows-1256?B?4+XjIMzPx/AgyO3kx8ogys7VIMfhz+bj7eQ=?=";
mb_internal_encoding("UTF-8");
echo mb_decode_mimeheader($x); 

check http://php.net/mb_decode_mimeheader

Upvotes: 1

minaz
minaz

Reputation: 5780

you may have to manually convert to another encoding:

$x = "=?windows-1256?B?4+XjIMzPx/AgyO3kx8ogys7VIMfhz+bj7eQ=?=";
@iconv('windows-1256', 'UTF-8', base64_decode($x));
print_r($x);

Take a look at http://www.php.net/manual/en/ref.iconv.php for more info.

Upvotes: 1

Related Questions