电子邮件中的HTML表格

时间:2012-12-24 12:42:26

标签: php html html-table html-email

我制作了以下电子邮件模板, 而不是以表格形式显示数据;它显示了电子邮件正文中的完整Html代码。请帮我解决这个问题。

 <table style="font-family: Lucida Sans Unicode, Lucida Grande, Sans-Serif; font-size: 12px; background: #fff; margin: 45px; width: 480px; border-collapse: collapse; text-align: left;" summary="Website Uptime Statistics">
<thead>
    <tr>
        <th style="font-size: 14px; font-weight: normal; color: #039; padding: 10px 8px; border-bottom: 2px solid #6678b1;" scope="col">#S.No.</th>
        <th style="font-size: 14px; font-weight: normal; color: #039; padding: 10px 8px; border-bottom: 2px solid #6678b1;" scope="col">Website</th>
        <th style="font-size: 14px; font-weight: normal; color: #039; padding: 10px 8px; border-bottom: 2px solid #6678b1;" scope="col">Status</th>
    </tr>
</thead>
<tbody>


    <tr>
        <td style="border-bottom: 1px solid #ccc; color: #669; padding: 6px 8px;">1</td>
        <td style="border-bottom: 1px solid #ccc; color: #669; padding: 6px 8px;">http://google.com</td>
        <td style="border-bottom: 1px solid #ccc; color: #669; padding: 6px 8px;">Up</td>
    </tr>
    <tr>
        <td style="border-bottom: 1px solid #ccc; color: #009; padding: 6px 8px;">2</td>
        <td style="border-bottom: 1px solid #ccc; color: #009; padding: 6px 8px;">http://google.com</td>
        <td style="border-bottom: 1px solid #ccc; color: #009; padding: 6px 8px;">Down</td>
    </tr>
    <tr>
        <td style="border-bottom: 1px solid #ccc; color: #669; padding: 6px 8px;">$300</td>
        <td style="border-bottom: 1px solid #ccc; color: #669; padding: 6px 8px;">$300</td>
        <td style="border-bottom: 1px solid #ccc; color: #669; padding: 6px 8px;">$300</td>
    </tr>




</tbody>
</table>

2 个答案:

答案 0 :(得分:1)

您是否设置了电子邮件的内容类型,以便接收电子邮件应用程序知道它包含HTML并因此可以正确显示?

Content-Type: text/html; charset=UTF-8

答案 1 :(得分:-3)

$html = '';
$html .= ' <table style="font-family: Lucida Sans Unicode, Lucida Grande, Sans-Serif; font-size: 12px; background: #fff; margin: 45px; width: 480px; border-collapse: collapse; text-align: left;" summary="Website Uptime Statistics"><thead>';
.....
echo $html;

试试这个