PHPMailer:IsHTML是真的,但失败了

时间:2017-11-04 18:33:29

标签: phpmailer

我有这段代码:

$ mail-> Host = gethostbyname(' tls://'。$ dados [1] - > US_ENVIO_SMTP);

    $mail->Port = $dados[1]->US_ENVIO_PORTA;
    $mail->Username = $dados[1]->US_ENVIO_EMAIL;
    $mail->Password = $dados[1]->US_ENVIO_SENHA; 
    $mail->SetFrom($dados[1]->US_ENVIO_EMAIL, $dados[1]->US_NOME); 
    $mail->AddReplyTo($dados[1]->US_ENVIO_EMAIL, $dados[1]->US_NOME); 
    $mail->Subject = $this->input->post('EM_ASSUNTO'); //Assunto do e-mail.
    $mail->Body = $css.$this->input->post("EM_DESCRICAO")."<br>".$this->input->post("EM_CONTEUDO");
    $mail->IsHTML(true);

我在$ mail-&gt;中做了什么正文设置了CSS和HTML。

问题:

Gmail正在接收以下所有代码:

    <!--[if IE]><html xmlns="http://www.w3.org/1999/xhtml" class="ie-browser" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"><![endif]--><!--[if !IE]><!--><!--<![endif]--> <!--[if gte mso 9]><xml> 96 </xml><![endif]--> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="width=device-width"> <!--[if !mso]><!--><meta http-equiv="X-UA-Compatible" content="IE=edge"><!--<![endif]--> <title>E-mail template 1</title> <style type="text/css" id="media-query"> body { margin: 0; padding: 0; } table, tr, td { vertical-align: top; border-collapse: collapse; } .ie-browser table, .mso-container table { table-layout: fixed; } * { line-height: inherit; } a[x-apple-data-detectors=true] { color: inherit !important; text-decoration: none !important; } [owa] .img-container div, [owa] .img-container button { display: block !important; } [owa] .fullwidth button { width: 100% !important; } .ie-browser .col, [owa] .block-grid .col { display: table-cell; float: none !important; vertical-align: top; } .ie-browser .num12, .ie-browser .block-grid, [owa] .num12, [owa] .block-grid { width: 500px !important; } .ExternalClass, .ExternalClass p, .ExternalClass span, .ExternalClass font, .ExternalClass td, .ExternalClass div { line-height: 100%; } .ie-browser .mixed-two-up .num4, [owa] .mixed-two-up .num4 { width: 164px !important; } .ie-browser .mixed-two-up .num8, [owa] .mixed-two-up .num8 { width: 328px !important; } .ie-browser .block-grid.two-up .col, [owa] .block-grid.two-up .col { width: 250px !important; } .ie-browser .block-grid.three-up .col, [owa] .block-grid.three-up .col { width: 166px !important; } .ie-browser .block-grid.four-up .col, [owa] .block-grid.four-up .col { width: 125px !important; } .ie-browser .block-grid.five-up .col, [owa] .block-grid.five-up .col { width: 100px !important; } .ie-browser .block-grid.six-up .col, [owa] .block-grid.six-up .col { width: 83px !important; } .ie-browser .block-grid.seven-up .col, [owa] .block-grid.seven-up .col { width: 71px !important; } .ie-browser .block-grid.eight-up .col, [owa] .block-grid.eight-up .col { width: 62px !important; } .ie-browser .block-grid.nine-up .col, [owa] .block-grid.nine-up .col { width: 55px !important; } .ie-browser .block-grid.ten-up .col, [owa] .block-grid.ten-up .col { width: 50px !important; } .ie-browser .block-grid.eleven-up .col, [owa] .block-grid.eleven-up .col { width: 45px !important; } .ie-browser .block-grid.twelve-up .col, [owa] .block-grid.twelve-up .col { width: 41px !important; } @media only screen and (min-width: 520px) { .block-grid { width: 500px !important; } .block-grid .col { display: table-cell; Float: none !important; vertical-align: top; } .block-grid .col.num12 { width: 500px !important; } .block-grid.mixed-two-up .col.num4 { width: 164px !important; } .block-grid.mixed-two-up .col.num8 { width: 328px !important; } .block-grid.two-up .col { width: 250px !important; } .block-grid.three-up .col { width: 166px !important; } .block-grid.four-up .col { width: 125px !important; } .block-grid.five-up .col { width: 100px !important; } .block-grid.six-up .col { width: 83px !important; } .block-grid.seven-up .col { width: 71px !important; } .block-grid.eight-up .col { width: 62px !important; } .block-grid.nine-up .col { width: 55px !important; } .block-grid.ten-up .col { width: 50px !important; } .block-grid.eleven-up .col { width: 45px !important; } .block-grid.twelve-up .col { width: 41px !important; } } @media (max-width: 520px) { .block-grid, .col { min-width: 320px !important; max-width: 100% !important; } .block-grid { width: calc(100% - 40px) !important; } .col { width: 100% !important; } .col > div { margin: 0 auto; } img.fullwidth { max-width: 100% !important; } } </style> <!--[if mso]> <body class="mso-container" style="background-color:#FFFFFF;"> <![endif]--> <!--[if !mso]><!--> <!--<![endif]-->
<!--[if (mso)|(IE)]>
<![endif]-->
<!--[if (mso)|(IE)]>
<![endif]--> <!--[if (mso)|(IE)]>   <![endif]-->
<!--[if (!mso)&(!IE)]><!-->
<!--<![endif]-->
<!--[if mso]>
<![endif]--> Image <!--[if mso]>
<![endif]-->
<!--[if (!mso)&(!IE)]><!-->
<!--<![endif]-->
<!--[if (mso)|(IE)]>    <![endif]-->
<!--[if (!mso)&(!IE)]><!-->
<!--<![endif]--> <!--[if mso]>
<![endif]-->
(51) 9991-2580
<!--[if mso]>
<![endif]--> <!--[if (!mso)&(!IE)]><!-->
<!--<![endif]-->
<!--[if (mso)|(IE)]>
<![endif]-->
<!--[if (mso)|(IE)]>
<![endif]--> <!--[if (mso)|(IE)]>   <![endif]-->
<!--[if (!mso)&(!IE)]><!-->
<!--<![endif]-->   <!--[if (!mso)&(!IE)]><!-->
<!--<![endif]-->
<!--[if (mso)|(IE)]>

有人有这个问题吗?

1 个答案:

答案 0 :(得分:0)

问题在于身体:

$body = $this->input->post('html_field');

可以使用以下方法修复:

$body = $_POST['html_field'];

如果您使用Codeigniter或类似功能,也可以为您提供帮助。