【问题标题】:gmail still shows html tags with php mail(); [closed]gmail 仍然显示带有 php mail() 的 html 标签; [关闭]
【发布时间】:2015-01-29 13:01:42
【问题描述】:

我在这个网站和 php.net 网站上查找了我应该使用我的 php mail() 函数发送哪些标签才能正确发送 html 邮件。不知何故,我的 gmail 仍然显示 html 标签。我在这方面做错了什么?

$to = "$email";
        $subject = "order placed";
        $from = "noreply@snorgytees.tk";
        $message = "

        Hi, '{$_SESSION['naam']}';
        <html>
        <head>
        </head>
        <body>
        <table>
                <tr>

                <td>$Artikelnaam></td>
                <td>$maat</td>
                <td>$hoeveelheid</td>
                <td>$$echteprijs</td>
                <td>Total: $$totaalprijs;
            <br><br>Total including VAT: $$prijs_btw</td>
                </tr>

        </table>
        </body>
        </html>
        ";  
        $headers  = 'MIME-Version: 1.0' . "\r\n";
        $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
        $headers .= 'To: $_POST["email"]' . "\r\n";
        $headers .= 'From: noreply@snorgytees.tk' . "\r\n";
        mail($to, $subject, $from, $message, $headers);

【问题讨论】:

  • &lt;html&gt; 之前的最重要的文本使其无效。使用查看源代码查看 Gmail 收到的内容。然后停止使用mail() 函数。使用 PHPMailer/SwiftMailer。这也将迫使您修复未解析的 $_POST 电子邮件地址。
  • 您还需要删除$headers .= 'To: $_POST["email"]' . "\r\n";,因为mail() 中的第一个参数是“To:”

标签: php html email sendmail


【解决方案1】:

大约一周前我遇到了同样的问题,这个问题帮我解决了。 gmail does not render html in email

【讨论】:

  • 啊,你的意思是我发布了一个接受的答案的问题;-) 我记得那个;那是大的。我很高兴它也对你有所帮助;-)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-06-09
  • 2021-12-31
  • 1970-01-01
  • 2011-07-25
  • 2022-11-29
相关资源
最近更新 更多