Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在电子邮件主题[PHP]中包含html标记_Php_Html_Sendmail_Phpmailer - Fatal编程技术网

在电子邮件主题[PHP]中包含html标记

在电子邮件主题[PHP]中包含html标记,php,html,sendmail,phpmailer,Php,Html,Sendmail,Phpmailer,使用标题,html标记将在邮件内容/正文中解析,但是如果我们想在邮件主题中包含一些html标记,该怎么办呢。有什么办法解决这个问题吗?即使您在邮件主题中添加了html标记,邮件客户端也不会将其呈现为html 根据电子邮件RFC,电子邮件主题不能有内容类型 来自rfc 3.1.2。标题字段的结构 展开字段后,可以将其视为由字段名、冒号(“:”)和字段正文组成,并以回车/换行符终止。字段名必须由可打印的ASCII字符组成(即值介于33.和126.之间的字符,十进制,冒号除外)。字段正文可以由除CR或

使用标题,html标记将在邮件内容/正文中解析,但是如果我们想在邮件主题中包含一些html标记,该怎么办呢。有什么办法解决这个问题吗?即使您在邮件主题中添加了html标记,邮件客户端也不会将其呈现为html

根据电子邮件RFC,电子邮件主题不能有内容类型

来自rfc

3.1.2。标题字段的结构
展开字段后,可以将其视为由字段名、冒号(“:”)和字段正文组成,并以回车/换行符终止。字段名必须由可打印的ASCII字符组成(即值介于33.和126.之间的字符,十进制,冒号除外)。字段正文可以由除CR或LF之外的任何ASCII字符组成。(虽然CR和/或LF可能出现在实际文本中,但通过展开字段的操作将其删除。)
标题的某些字段体可以根据某些系统可能希望解析的内部语法进行解释。这些字段称为“结构化字段”。示例包括包含日期和地址的字段。其他字段,如“主题”和“评论”,被简单地视为文本字符串。
注:
任何具有定义为非简单字段的字段体的字段都将被视为结构化字段。
字段名、非结构化字段体和结构化字段体都由各自独立的“词法”分析器进行扫描。
3.1.3. 非结构场体
对于某些字段,例如“Subject”和“Comments”,假设没有结构,它们被简单地视为s,就像在消息体中一样。折叠规则适用于这些字段,因此占用多行的字段体必须具有至少一个LWSP字符缩进的第二行和连续行。


有些电子邮件应用程序呈现html,有些不呈现……但没有电子邮件应用程序呈现主题行中的html。不要发布无法回答问题的无法解释的随机代码,尤其是当这是一个长期过时的示例时。
3.1.2. STRUCTURE OF HEADER FIELDS

Once a field has been unfolded, it may be viewed as being composed of a field-name followed by a colon (":"), followed by a field-body, and terminated by a carriage-return/line-feed. The field-name must be composed of printable ASCII characters (i.e., characters that have values between 33. and 126., decimal, except colon). The field-body may be composed of any ASCII characters, except CR or LF. (While CR and/or LF may be present in the actual text, they are removed by the action of unfolding the field.)
Certain field-bodies of headers may be interpreted according to an internal syntax that some systems may wish to parse. These fields are called "structured fields". Examples include fields containing dates and addresses. Other fields, such as "Subject" and "Comments", are regarded simply as strings of text.

Note:

Any field which has a field-body that is defined as other than simply <text> is to be treated as a structured field.
Field-names, unstructured field bodies and structured field bodies each are scanned by their own, independent "lexical" analyzers.

3.1.3. UNSTRUCTURED FIELD BODIES

For some fields, such as "Subject" and "Comments", no structuring is assumed, and they are treated simply as <text>s, as in the message body. Rules of folding apply to these fields, so that such field bodies which occupy several lines must therefore have the second and successive lines indented by at least one LWSP-char.
<?php 

    require_once('phpmailer/class.phpmailer.php');

     $   = $_POST[];
     $   = $_POST[];
     $   = $_POST[];
     $   = $_POST[];

   $mail = new PHPMailer();
   $mail->CharSet =  "utf-8";
   $mail->IsSMTP();
   $mail->SMTPAuth = true;
   $mail->Username = "example@example.com";
   $mail->Password = "";
   $mail->SMTPSecure = "ssl";  
   $mail->Host = "smtp.gmail.com";
   $mail->Port = "465";

   $mail->setFrom('emailaddress','name');
   $mail->AddAddress('email address', 'name');


   $mail->Subject  =  'Example';
   $mail->IsHTML(true);
   ob_start();
   ?>
    <html>
    <head>
    <title></title>

    </head>
    <body>

    </body>
    </html>
 <?php
     $mail->Body    = ob_get_clean();
       if($mail->Send())
         {
          header('');
         }
        else
         {
       echo "Mail Error - >".$mail->ErrorInfo;
         }

?>