Why isn't this message subject encoded properly? (php mail)

Posted by Camran on Stack Overflow See other posts from Stack Overflow or by Camran
Published on 2010-12-23T23:41:34Z Indexed on 2010/12/23 23:54 UTC
Read the original article Hit count: 134

Filed under:
|
|
|
|

I use this code to send an email:

$headers="MIME-Version: 1.0"."\n";
$headers.="Content-type: text/plain; charset=UTF-8"."\n";
$headers.="From: $name <$email>"."\n";

mail($to, '=?UTF-8?B?'.base64_encode($subject).'?=', $text, $headers, '[email protected]'); 

If I use special characters Å Ä Ö from the swedish alphabet, they are not encoded properly, so they turn up like ö for ö.

However, this doesn't happen if I change the $to variable to a gmail account email, then they are shown correctly.

Anybody got any idea?

Thanks

UPDATE:

When I echo $name, the name is displayed correctly, in utf8, with all special chars nicely shown.

© Stack Overflow or respective owner

Related posts about php

Related posts about html