日语电子邮件附件名称乱码PHP邮件

时间:2016-11-25 09:29:07

标签: php

以下代码在Google Mail和Yahoo Mail中正常运行。附件文件名工作正常但在日文文件名的Hotmail附件中是乱码。

// multipart boundary
$message =  "--{$mime_boundary}\n" . "Content-Type: ".$contentType."; charset=\"iso-8859-2,utf-8\"\n"  .
"Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";

//---- dummy size
$tempsize= 1024 ;
//---- dummy size

$ctrFileName = 0;
// preparing attachments
if(count($attachment) > 0){
    foreach ($attachment as $file_data) {
        $message .= "--{$mime_boundary}\n";
        $data = chunk_split(base64_encode($file_data));
        $message .= "Content-Type: application/octet-stream; name=\"".$filenameattach[$ctrFileName]."\"\n" .
        "Content-Description: ".$filenameattach[$ctrFileName]."\n" .
        "Content-Disposition: attachment;\n" . " filename=\"".$filenameattach[$ctrFileName]."\"; size=".$tempsize.";\n" .
        "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
        $ctrFileName++;
        //$message .= "--{$mime_boundary}--";
    }
} else {

    $message .= "--{$mime_boundary}--";
}

//$message .= "--{$mime_boundary}--";
//$returnpath = "-f" . $fromaddress;


$success = @mail($to, $subject, $message, $headers);

0 个答案:

没有答案