Nicolas.
Nicolas.

Reputation: 453

Using mail() to sent UTF8 e-mail

I'm trying to send an e-mail with PHP, including multi-language characters. The whole site (html header, php header) are set to UTF8 aswell as the form charset.

To PHP code I have now is:

$to = "[email protected]";
$subject = "Subject";
$message = "Question is ".$question;
$from = "[email protected]";
$headers = "From:" . $from . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-UTF-8' . "\r\n";

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

I supose I'm wrong somewhere ?

I'm getting '?' characters with Japanese letters for examnple.

Upvotes: 1

Views: 123

Answers (1)

Novocaine
Novocaine

Reputation: 4786

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

should be all you need.

I may be wrong, but as far as I know iso-UTF-8 is not a valid charset, at least it doesn't look like it is.

Upvotes: 1

Related Questions