Russian Character encoding with IMAP

2019-09-05 18:03发布

I have a PHP script that accesses an imap mailbox.

When I send through English, Spanish and French it works perfectly but Russian I realize it is probably an encoding issue but nothing I try seems to work.

this is what it printed:

PiAq8NLJ18XUIM3PyiDE0tXHKiAuCj4+Cj4+Cj4+Cj4K

   $email=$_REQUEST['email'];
  $mbox = imap_open ("{localhost:995/pop3/ssl/novalidate-cert}", "info@******.com", "**********");
  $num_mensaje = imap_search($mbox,"FROM $email");      
    $body =  imap_fetchbody($mbox,$num_mensaje[0],"1");
    $str =   imap_utf8($body);
    if ($str != null){
   $arr=array('id'=>'0','email'=>"$email",'respuesta'=>"$str");
  $output[] = $arr;
   print(json_encode($output));
    }else{
   $arr2=array('id'=>'0','email'=>"$email",'respuesta'=>"norespuesta");
$output2[] = $arr2;
print(json_encode($output2));
}
imap_close($mbox);

1条回答
Emotional °昔
2楼-- · 2019-09-05 18:54

Convert to utf with

imap_utf8($text);

See http://php.net/manual/ru/function.imap-utf8.php for more details

查看更多
登录 后发表回答