简体   繁体   English

PHP发送HTML电子邮件

[英]PHP Sending an html email

I am trying to figure out what the deal is with my php headers, I am trying to send an html style email and I keep getting the script tags with it and cant seem to figure out what is going on... Maybe you guys can help me. 我想弄清楚我的php标头有什么问题,我想发送html样式的电子邮件,并且不断获取脚本标签,似乎无法弄清楚到底是怎么回事...也许你们可以帮我。

    $this->headers = 'From: no-reply@***********.com\r\n';
    $this->headers .= 'CC: $this->ccList[\'Richard\']\r\n';
    $this->headers .= 'MIME-Version: 1.0 \r\n';
    $this->headers .= 'Content-Type: text/html; charset=ISO-8859-1\r\n';

The message looks like this, 消息看起来像这样,

    $this->message = '<html><body>
        <table rules="all" style="Border-Color: #666;" cellpadding="10">
        <tr style="background: #eee;"><td><strong>Dealer Code</strong></td><td style="background: #eee;">' . $dealer['dCode'] . '</td><tr>
        <tr><td><strong>Name: </strong></td><td>' . $dealer['name'] . '</td></tr>
        <tr><td><strong>Address: </strong></td><td>' . $dealer['address1'] . '</td>    </tr>
        <tr><td><strong>City: </strong></td><td>' . $dealer['dCity'] . '</td></tr>
        <tr><td><strong>State: </strong></td><td>' . $dealer['dState'] . '</td></tr>
        <tr><td><strong>Zip: </strong></td><td>' . $dealer['dZip'] . '</td></tr>
        <tr><td><strong>Status: </strong></td><td>' . $dealer['status'] . '</td></tr>
        </table>
        </body></html>
        <p>This message has been sent because this dealer has Logged In<br/>
            If the Dealer Completes An Order A different email will be<br>
            sent to you regarding that order.</p>';

Any Ideas? 有任何想法吗?

It looks like you're single quoting your strings and your \\r\\n are not receiving any translation in to real newline characters. 看来您是单引号,而您的\\ r \\ n没有收到任何转换为​​实际换行符的翻译。

Also, try rearranging your headers so that your mime version is first, then the content type 另外,请尝试重新排列标题,以便首先是您的哑剧版本,然后是内容类型

$this->headers = "MIME-Version: 1.0 \r\n";
$this->headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$this->headers .= "From: no-reply@***********.com\r\n";
$this->headers .= "CC: $this->ccList[\'Richard\']\r\n";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM