【问题标题】:Table does not show row and column borders in email sent using PHP mail表格不显示使用 PHP 邮件发送的电子邮件中的行和列边框
【发布时间】:2025-12-01 04:35:01
【问题描述】:

我正在使用 PHP 发送网页内容的邮件。我在页面中有一个表格。 我的表格在使用 PHP 邮件发送的电子邮件中未显示行和列边框。 它不会读取电子邮件中的 CSS。 这是我的代码:

<div id="table_email" style="width:800px;margin-left:50px; text-align: left;">
    <table class="table1">
        <tr>
            <th>Description</th>
            <th colspan="2">Amount</th>
        </tr>
        <tr>
            <td>(A)Package Cost</td>
            <td>';$formatedMessag .= $inv[0].'</td>
        </tr>
        <tr>
            <td>(B) Insurance </td>
            <td>';$formatedMessag .= $inv[1].'</td>
        </tr>
        <tr>
            <td>(C)Flight / Train</td>
            <td>';$formatedMessag .= $inv[2].'</td>
        </tr>
        <tr>
            <td>Add : &emsp;Service Tax 3% on Rs.(a+b)</td>
            <td>';$formatedMessag .=$inv[5].'</td>
        </tr>
        <tr>
            <td>Add : &emsp;Educational Cess 2% On 3% </td>
            <td>';$formatedMessag .= $inv[6].'</td>
        </tr>
        <tr>
            <td>Add : &emsp;Secondary& Higher Education Cess 1% on 3% </td>
            <td>';$formatedMessag .= $inv[7].'</td>
        </tr>
        <tr style=" font-weight: bold;font-size: 12px;background-color:seashell;">
            <td>Total Payable Amount</td>
            <td>';$formatedMessag .='INR ' . $inv[9].'</td>
        </tr>
        ';$formatedMessag .='
    </table>
</div>

这是我的 CSS:

.table1{
    width: 990px;
    margin-left: 5px;
    border: 1px solid #CDCDCD;
}
.table1 th{
    background: none repeat scroll 0 0 #EEEEEE;
    padding: 10px;
    font-size: 11px;
    color: #777777;
    border: 1px solid #CDCDCD;
}
.table1 tr{
    padding: 10px;
    font-size: 11px;
    height: 30px;
    border: 1px solid #CDCDCD;
}
.table1 tr td:first-child{
    font-weight: bold;
    text-align: left;
    border: 1px solid #CDCDCD;
}
.table1 td{
    padding-left: 3px;
    border: 1px solid #CDCDCD;
    color: #333333;
}

【问题讨论】:

  • 你是这样发送的吗?还是你用 和 等标签包围它?此外,在发送电子邮件时,您应该将 CSS 放在 HTML
    标签

标签: php css html-table border html-email


【解决方案1】:

这是因为当您发送邮件时它无法访问样式类, 而不是这个&lt;table class="table1"&gt; 使用内联css,如:

<table style='width: 990px; etc;'>.

【讨论】: