Decapitatef Decapitatef - 5 months ago 27
PHP Question

not able to send arabic email with good caracters

i want to send an arabic email with using php , but it gives me others caracters , how to send it with the arabic caracters ?
this is my code :


$subject = $_POST['subject'];
$message = $_POST['message'] . "\n\n" . 'Regards, ' . $_POST['name'] . '.';
$headers = 'From: ' . $_POST['name'] . "\r\n" . 'Reply-To: ' . $_POST['email'] . "\r\n" . 'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

if( $_POST['copy'] == 'on' )
{
mail($_POST['email'], $subject, $message, $headers);
}
}
?>

Answer

By default, email (or the smtp protocol) only accepts the first 7 bits in ascii. To enable support for other languages add the following field to your headers:

Content-Type: text/plain; charset=UTF-8

Here is the RFC backing: rfc5335