简体   繁体   中英

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.

    $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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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