How to send UTF-8 email?

email, php, utf-8

Solution

You can add header "Content-Type: text/html; charset=UTF-8" to your message body.

$headers = "Content-Type: text/html; charset=UTF-8";

If you use native `mail()` function $headers array will be the 4th parameter `mail($to, $subject, $message, $headers)`

If you user PEAR Mail::factory() code will be:

$smtp = Mail::factory('smtp', $params);

$mail = $smtp->send($to, $headers, $body);

Problem

When I send out the email, the email does not show characters other than english. It does show like below: 余生ä»ä» May know actually what cause this? Even I tried to added Content-type and charset in the script, it still show the same. I used `Mail::Factory("mail");`

Original source