I send email with PHP's mail() function. I need to have the from field encoded in UTF-8 so I set these mail headers:
function mail_headers($from, $contentType = "text/plain") {
$headers = "From: ".mime_header_encode($from)."\n";
$headers .= 'Reply-To: '.mime_header_encode($from)."\n";
$headers .= 'MIME-Version: 1.0' ."\n";
$headers .= 'Content-Type: '.$contentType.'; charset=utf-8' ."\n";
$headers .= 'Content-Transfer-Encoding: 8bit'. "\n";
return $headers;
}
function mime_header_encode($text, $encoding = "utf-8") {
return "=?$encoding?Q?" . imap_8bit($text) . "?=";
}
It works good in my PC but not so good on production server. It doesn't recognize encoded string =?utf-8?Q?Website name <info@myshop.com>?=
as a valid email so it tries to make it better. The server will finally send an email with this part of header:
From: =?utf-8?Q?Website name <info@myshop.com>,
?=@hosting-domain.com
With this headers, email recipient see another strange sender (the string after comma). Can I make PHP not to touch my email string?
Thank you!