close
mb_internal_encoding('UTF-8');
$subject=mb_encode_mimeheader('測試', 'UTF-8');
$message= $html; //HTML格式的信件內容
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=utf-8\r\n";
$headers .=
"From: ".mb_encode_mimeheader('測試網', 'UTF-8')." <xxxx@xxxx.xxx.xx>\r\n";
mail($to,$subject,$message,$headers);
因mb_encode_mimeheader()預設的字串編碼為西方ISO-8859-1,
而此範例使用UTF-8編碼中文字,
故程式中需使用mb_internal_encoding()將內部預設編碼改為UTF-8
全站熱搜