How to read multilingual emails using php?

I don't want any webmail script.

I want to use imap/pop3 functions

http://www.php.net/manual/en/function.imap-open.php

Following code works well for listing emails but have some errors and it cannot read email other than ENGLISH language

Help Anybody

<?php 

// Inbox 

// Display Messages from POP by Ronny Adonis .                               

// mail.host.com 
$host = "hostname"; 

// username 
$username = "mailboxusername"; 

$password = "password"; 

// make connection 

$inbox = @imap_open ("{". $host . "/pop3:110}",$username, $password) 
 or header("Could not connect. Somethings wrong !"); 

$total = imap_num_msg($inbox); 

?> 
<html> 

<head> 

// check all messages 
<script language=javascript><!-- 
function toggle() 
{ 
   for( var i = 0; i < document.form1.elements.length; i++ ) 
      document.form1.elements[i].checked = document.form1.tog.checked; 
} 
//--></script> 



</head> 
<body bgcolor="White">  

<? 
// header 
$title = "Inbox ($total total)"; 
?> 

<table width="100%" border="0" cellspacing="0" cellpadding="6" > 
<tr bgcolor="#083580"><td valign="top" align="center" width="100%">&nbsp;</td> 
     
<td valign="top" align="center"> 
<a class="menu" href="compose.php" border="0"> 
<font face="Verdana" size="-2">Compose</font></a></td> 

<td valign="top" align="center"> 
<a class="menu" href="javascript:document.forms[0].submit()"> 
<font face="Verdana" size="-2">Delete</font></a></td> 

<td valign="top" align="center"> 
<a class="menu" href="inbox.php"> 
<font face="Verdana" size="-2">Send/Receive</font></a></td> 
</tr> 
</table> 
<?  
if ($total > 0) 
{ 
?> 
<table width="100%" border="0" cellspacing="0" cellpadding="5"> 
<form action="delete.php" name="form1" method="post"> 

<tr bgcolor="#012752"> 
    <td width="3%"><font size="-1"> 
    <input type=checkbox name=tog onclick="javascript:toggle();">&nbsp;</font></td> 
    <td width="3%"><font size="-1">&nbsp;</font></td> 
    <td width="29%"><font face="Arial" color="#ffffff" size="-1"> 
    <b>From</b></font></td>     
    <td width="34%"><font face="Arial"  color="#ffffff" size="-1"> 
    <b>Subject</b></font></td> 
    <td width="21%"><font face="Arial"  color="#ffffff" size="-1"> 
    <b>Date</b></font></td> 
    <td width="10%"><font face="Arial"  color="#ffffff" size="-1"> 
    <b>Size</b></font></td> 
</tr> 
     


<?php 
for($x=$total; $x>0; $x--)  
{ 
    $headers = imap_header($inbox, $x); 
    $structure = imap_fetchstructure($inbox, $x); 
     
// rotate  cell background color 
    if ($bgColor == "#FFFFFF") { 
           $bgColor = "#d8d8d8"; 
       } else { 
            $bgColor = "#FFFFFF"; 
        } 
   $overview=imap_fetch_overview($inbox,$x); 
   $size=sizeof($overview); 
   for($i=$size-1;$i>=0;$i--) 
   $val=$overview[$i]; 
   $msg=$val->id; 
   $from=$val->from; 
   $date=$val->date; 
   $subject=$val->subject; 
   $seen=$val->seen; 
   $Recent=$val->Recent; 
   $from = ereg_replace("\"","",$from);  
// make date display 
   list($dayName,$day,$month,$year,$time) = split(" ",$date);  
   $time = substr($time,0,5); 
   $date = $day ." ". $month . " ".$time; 
 // restrict subject  lenght   
        if (strlen($subject) > 30) { 
           $subject = substr($subject,0,29) ."..."; 
        } 
        ?> 
<tr bgcolor="<?php echo $bgColor; ?>"> 
<td align="right" valign="top"> 
<input type="Checkbox" name="dmsg[]" value="<? echo $x; ?>"> 
</td> 
<td valign="center"> 
</td> 
<td valign="top"> 
<font face="Arial" size="-1"> 
<? echo "$from"; ?></font> 
</td><td valign="top"><font face="Arial" size="-1"> 
<a href="readmessage.php?id=<? echo $x; ?>"> 
<?  
    // correction for empty subject 
    if ($subject == "") 
    { 
    echo "No subject"; 
    } 
    else 
    { 
    echo $subject;  
    } 
?> 
</a> 
</font> 
</td><td valign="top"><font face="Arial" size="-1"> 
<?php echo $date; ?></font> 
</td><td valign="top"><font face="Arial" size="-1"> 
<? 
// message size 
echo ceil(($structure->bytes/1024)), " KB";  
?> 
</font> 
</td></tr> 
<? 
} 
// clean up 
imap_close($inbox); 
?>  
</form></table> 
<? 
// if mailbox is empty 
} 
else 
{ 
echo "<font face=Arial size=-1>You have no mail at this time</font>"; 
} 
?> 
</body> 
</html>

can you please tell me how I can get the body of email context here

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.