Can anyone help me for email message parsing and header parsing for reading multilingual email messages?

Member Avatar for diafol

maybe - what do you want? Post your code so far - what errors do you get?

maybe - what do you want? Post your code so far - what errors do you get?

index.php

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Pragma" content="cache" />
<meta http-equiv="Cache-Control" content="public" />
<?php
$host = "";
$username = "";
$password = "";

// make connection
$imap = @imap_open ("{". $host . "/imap:143}",$username, $password)
or header("Could not connect. Something is wrong !");



echo "<h1>Mailboxes</h1>\n";
$folders = imap_listmailbox($imap, "{". $host . "/imap:143}", "*");

if ($folders == false) {
    echo "Call failed<br />\n";
} else {
    foreach ($folders as $val) {
        echo $val . "<br />\n";
    }
}

echo "<h1>Headers in INBOX</h1>\n";
$headers = imap_headers($imap);

 $n_msgs = imap_num_msg($imap);

for($x=$n_msgs; $x>0; $x--) 
	{	 
$overview=imap_fetch_overview($imap,$x,0);
$size=sizeof($overview); 
	for($i=$size-1;$i>=0;$i--)
	{ 
		$val=$overview[$i]; 
		$msg=$val->msgno; 
		$from=$val->from; 
		$date=$val->date; 		
		$subj=$val->subject; 
		list($dayName,$day,$month,$year,$time) = split(" ",$date); 
		$time = substr($time,0,5);
		$date = $day ." ". $month;
		echo "From: $from &nbsp; <a href='readmail.php?id=$x'>  Subject: $subj </a> &nbsp; Date:$date<br>";
	 }}

imap_close($imap);
?>

readmail.php

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

$host = "";
$username = "";
$password = "";


// make connection
$inbox = @imap_open ("{". $host . "/imap:143}",$username, $password)
or header("Could not connect. Something is wrong !");


$mid=$_REQUEST['id'];
$partno="2";
 $message = imap_qprint(imap_fetchbody($inbox, $mid,$partno));  

  if(!$message) {
    $message = "[This message has no body]\n\n\n\n\n\n";
  }
  else{
  echo" $message";
  
  }
 
 
?>

I cannot read multilingual emails. English emails are displayed well but when multilingual emails come it reads like,
"=?ISO-8859-5?B?utDa3iDh2D8gKCBob3cgYXJlIHlvdSA/ICggTWFjZWRvbmlhbiApKQ==?="


I found class for that purpose but it is going over my head.
Class: MIME E-mail message parser

Please help with this.

Member Avatar for diafol

Got me. I know you can send with mb_send_mail(), but haven't seen anything about reading imap data. Sorry.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.