在使用php mail function 寄送信件時出現亂碼

先前的server環境windows,後來轉到linux的環境。

由php mail function寄送信,收件者開啟信件時內容是一串亂碼。

mail function在寫入信件標頭時在windows的環境下使用 “rn" 做斷行符號都沒有問題。

linux上只要將換行符號改為 “n"。

$headers = ‘MIME-Version: 1.0’ . “n";
$headers .= ‘Content-type: text/html; charset=utf-8’ . “n";

// Additional headers
$headers .= “To: {$to} " . “n";
$headers .= ‘From: admin ‘ . “n";

// Mail it
mb_language(‘uni’);
mb_internal_encoding(“UTF-8″);
mb_send_mail($Mail, $subject, $message, $headers);

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

Google+ photo

You are commenting using your Google+ account. Log Out / 變更 )

連結到 %s