• <tfoot id='3lopT'></tfoot>
  • <small id='3lopT'></small><noframes id='3lopT'>

          <bdo id='3lopT'></bdo><ul id='3lopT'></ul>

      1. <legend id='3lopT'><style id='3lopT'><dir id='3lopT'><q id='3lopT'></q></dir></style></legend>

        <i id='3lopT'><tr id='3lopT'><dt id='3lopT'><q id='3lopT'><span id='3lopT'><b id='3lopT'><form id='3lopT'><ins id='3lopT'></ins><ul id='3lopT'></ul><sub id='3lopT'></sub></form><legend id='3lopT'></legend><bdo id='3lopT'><pre id='3lopT'><center id='3lopT'></center></pre></bdo></b><th id='3lopT'></th></span></q></dt></tr></i><div id='3lopT'><tfoot id='3lopT'></tfoot><dl id='3lopT'><fieldset id='3lopT'></fieldset></dl></div>

        来自 PHP 的电子邮件已破坏主题标头编码

        时间:2023-10-04
        <legend id='bi0XH'><style id='bi0XH'><dir id='bi0XH'><q id='bi0XH'></q></dir></style></legend>
          <tfoot id='bi0XH'></tfoot>
            <bdo id='bi0XH'></bdo><ul id='bi0XH'></ul>

                <small id='bi0XH'></small><noframes id='bi0XH'>

              • <i id='bi0XH'><tr id='bi0XH'><dt id='bi0XH'><q id='bi0XH'><span id='bi0XH'><b id='bi0XH'><form id='bi0XH'><ins id='bi0XH'></ins><ul id='bi0XH'></ul><sub id='bi0XH'></sub></form><legend id='bi0XH'></legend><bdo id='bi0XH'><pre id='bi0XH'><center id='bi0XH'></center></pre></bdo></b><th id='bi0XH'></th></span></q></dt></tr></i><div id='bi0XH'><tfoot id='bi0XH'></tfoot><dl id='bi0XH'><fieldset id='bi0XH'></fieldset></dl></div>

                    <tbody id='bi0XH'></tbody>
                  本文介绍了来自 PHP 的电子邮件已破坏主题标头编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我的 PHP 脚本向用户发送电子邮件,当电子邮件到达他们的邮箱时,主题行 ($subject) 的末尾添加了类似 a^£ 的字符我的主题文本.这显然是编码问题.电子邮件内容本身没问题,只是主题行坏了.

                  My PHP script sends email to users and when the email arrives to their mailboxes, the subject line ($subject) has characters like a^£ added to the end of my subject text. This is obviously and encoding problem. The email message content itself is fine, just the subject line is broken.

                  我搜索了很多遍,但找不到如何正确编码我的主题.

                  I have searched all over but can’t find how to encode my subject properly.

                  这是我的标题.请注意,我将 Content-Typecharset=utf-8Content-Transfer-Encoding: 8bit 一起使用.

                  This is my header. Notice that I’m using Content-Type with charset=utf-8 and Content-Transfer-Encoding: 8bit.

                  //set all necessary headers
                  $headers = "From: $sender_name<$from>
                  ";
                  $headers .= "Reply-To: $sender_name<$from>
                  ";
                  $headers .= "X-Sender: $sender_name<$from>
                  ";
                  $headers .= "X-Mailer: PHP4
                  "; //mailer
                  $headers .= "X-Priority: 3
                  "; //1 UrgentMessage, 3 Normal
                  $headers .= "MIME-Version: 1.0
                  ";
                  $headers .= "X-MSMail-Priority: High
                  ";
                  $headers .= "Importance: 3
                  ";
                  $headers .= "Date: $date
                  ";
                  $headers .= "Delivered-to: $to
                  ";
                  $headers .= "Return-Path: $sender_name<$from>
                  ";
                  $headers .= "Envelope-from: $sender_name<$from>
                  ";
                  $headers .= "Content-Transfer-Encoding: 8bit
                  ";
                  $headers .= "Content-Type: text/plain; charset=UTF-8
                  ";
                  

                  推荐答案

                  更新 有关更实用和最新的答案,请查看 帕莱克的回答.

                  Update   For a more practical and up-to-date answer, have a look at Palec’s answer.

                  Content-Type 中指定的字符编码只描述了消息体的字符编码,而不描述消息头的字符编码.您需要使用编码字语法 使用 quoted-printable 编码 或 Base64 编码:

                  The specified character encoding in Content-Type does only describe the character encoding of the message body but not the header. You need to use the encoded-word syntax with either the quoted-printable encoding or the Base64 encoding:

                  encoded-word = "=?" charset "?" encoding "?" encoded-text "?="
                  

                  您可以将 imap_8bit 用于 quoted-printableem> 编码和 base64_encode 用于 Base64 编码:

                  You can use imap_8bit for the quoted-printable encoding and base64_encode for the Base64 encoding:

                  "Subject: =?UTF-8?B?".base64_encode($subject)."?="
                  "Subject: =?UTF-8?Q?".imap_8bit($subject)."?="
                  

                  这篇关于来自 PHP 的电子邮件已破坏主题标头编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  • <small id='bcmJi'></small><noframes id='bcmJi'>

                      <tbody id='bcmJi'></tbody>

                          <bdo id='bcmJi'></bdo><ul id='bcmJi'></ul>
                          <legend id='bcmJi'><style id='bcmJi'><dir id='bcmJi'><q id='bcmJi'></q></dir></style></legend>
                          <tfoot id='bcmJi'></tfoot>

                          <i id='bcmJi'><tr id='bcmJi'><dt id='bcmJi'><q id='bcmJi'><span id='bcmJi'><b id='bcmJi'><form id='bcmJi'><ins id='bcmJi'></ins><ul id='bcmJi'></ul><sub id='bcmJi'></sub></form><legend id='bcmJi'></legend><bdo id='bcmJi'><pre id='bcmJi'><center id='bcmJi'></center></pre></bdo></b><th id='bcmJi'></th></span></q></dt></tr></i><div id='bcmJi'><tfoot id='bcmJi'></tfoot><dl id='bcmJi'><fieldset id='bcmJi'></fieldset></dl></div>