Lio
Lio

Reputation: 1503

PHP Pear Mail Can't Send Name With Unicode Characters

On my server i'm using php pear package and when i send email, and i type in "name" field unicode characters, it doesn't send.. when i type latin characters, it works just fine.

so, guys, can you help me, to configure mail settings, that i could use in unicode (utf-8) characters too ?

code example:

$headers = array("From" => "UNICODE NAME HERE <[email protected]>", "Subject" => "my subject");

Upvotes: 4

Views: 841

Answers (1)

matino
matino

Reputation: 17725

Try this (not tested):

$headers = array(
    "Content-Type" => "text/plain; charset=\"UTF-8\"",
    "From" => "=?utf-8?B?".base64_encode($unicode_name)."?=" . " <[email protected]>", 
    "Subject" => "my subject"
);

You should do the same with subject if you want to use UTF-8 characters there.

Upvotes: 4

Related Questions