I've trying to send an email in utf-8
encoding using a PHP mail() func. And there's some issues with this. Such as:
Content-Type:
text/plain; charset=us-ascii
. This behavior is not depending of
sending a header Content-Type: text/plain; charset=UTF-8
utf-8
chars that encoded according to
RFC2047 then I receive a double encoded subject like this Subject:
=?us-ascii?Q?=3D=3FUTF-8=3FB=3Fw5HClsORwpfDkcKU=3F=3D?=
.
Instead of expected Subject: =?UTF-8?B?w5HClsORwpfDkcKU?=
Example:
$subject = 'іїє';
$body = 'іїє';
$headers = "Content-Type: text/plain; charset=UTF-8\r\n"
. "MIME-Version: 1.0\r\n";
mail('some-address@gmail.com', mb_encode_mimeheader($subject, 'UTF-8', 'B'), $body, $headers);
Here is the part of received headers:
Subject: =?us-ascii?Q?=3D=3FUTF-8=3FB=3Fw5HClsORwpfDkcKU=3F=3D?=
User-Agent: Heirloom mailx 12.5 6/20/10
MIME-Version: 1.0
Content-Type: application/octet-stream
Content-Transfer-Encoding: 8bit
С–С—С”
As MTA on server is installed postfix. As a client using gmail
Email is a very archaic, outdated, and difficult technology. This is especially true with character encoding. I would suggest using a library, such as PHPMailer. If you insist upon doing this from scratch, the true answer will go beyond the scope of your question. Browsers, clients, and much more complicate this issue. I can't tell you the cause of your issue, but the solution is PHPMailer.