I'm having a challenge with sending emails with arabic content using PHP's mail function. Let's say I have this simple arabic string:
????
I've tried several ways to utilize the headers, but the emails content all still end up with something like: X*X1X(X1Y X/
. However, the email subject is correctly encoded if I use arabic characters (thanks to the base64_encode, see function below)
Here's one of the email functions I've tried
function sendSimpleMail($to,$from,$subject,$message) {
$headers = 'MIME-Version: 1.0' ."
";
$headers .= 'To: '.$to ."
";
$headers .= 'From: '.$from . "
";
$headers .= 'Content-type: text/plain; charset=UTF-8; format=flowed' . "
";
$headers .= 'Content-Transfer-Encoding: 8bit'."
";
mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=',$message, $headers);
}
Any suggestions on alternative ways to achieve this goal?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…