0

I want to put UTF-8 characters in the from part of an email.

Every part of the message is UTF-8 and it's working correctly except the FROM part.

I'm using this:

//boundary
    $div = "==Multipart_Boundary_x".md5(time())."x";
    //headers
    $head = "From: $name\n".
        "MIME-Version: 1.0\n".
        "Content-Type: multipart/mixed;\n".
        " boundary=\"$div\"";

$name has UTF-8 characters and I can display correctly it in the message body.

I have tried with "\xEF\xBB\xBF" .$name" and still it's not working.

What am I doing wrong?

user123_456
  • 5,635
  • 26
  • 84
  • 140
  • 1
    Email headers must be exclusively ASCII encoded. To use any non-ASCII characters you need to MIME encode them. See aforelinked duplicate for how to do that. – deceze Jul 30 '13 at 10:09

1 Answers1

0

Don't reinvent the wheel, use some library:

http://swiftmailer.org/

http://framework.zend.com/manual/1.12/en/zend.mail.html

there are others

Marek
  • 7,337
  • 1
  • 22
  • 33
  • While not incorrect, "use some library" is not the correct technical answer for why it doesn't work or how one can make it work using the default tools. – deceze Jul 30 '13 at 10:15