PHP发送html电子邮件

时间:2014-07-28 16:13:32

标签: php html email

我试图找出与我的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';

消息看起来像这样,

    $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>';

任何想法?

1 个答案:

答案 0 :(得分:0)

您似乎单引引字符串并且\ r \ n未收到任何真实换行符的翻译。

另外,请尝试重新排列标题,以便首先使用mime版本,然后再添加内容类型

$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";