简体   繁体   中英

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@email.com";
$subject = "Subject";
$message = "Question is ".$question;
$from = "auto@from.com";
$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.

$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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM