HTML电子邮件打印不正确

时间:2014-04-09 18:35:28

标签: php html email

我编写了一封HTML电子邮件,旨在通过PHP发送给用户进行确认和公司地址,以便我们将其打印出来作为我们的记录。当我第一次开始它会打印一切都很好,包括第二页,如果订单足够大,但现在当我得到第二页时,它只说有一页,并在div的中间切断它。我写的旧表格打印两页就好了,所以我不认为我的设置有问题,我确定并选中了“打印所有页面”。我在Thunderbird和Outlook以及几个电子邮件服务中都试过这个,但没有成功。

这可能是页面布局或遗漏标签的问题我可能忽略了吗?我也包含了电子邮件代码。由于gmails缺乏对外部/内部样式表的支持,因此内联样式很重要。我故意省略了一些基本的标签,如身体和头部。

<div class="header">
    <div class="info" style="border: 1px black solid; border-radius: 20px; display: inline-block; font-family: Arial; font-weight:bold; color:black; width: 100%; padding: 0 7.5px;">
        <div class="left" style="float: left; clear: right; display: inline-block; font-size: 3em;">HD ' . ucfirst($_SESSION['sname']) . '</div>
        <div class="right" style="float: right; clear: right; display: inline-block; font-size: 3em;">' . $_SESSION['sdate'] .'</div>
        <div class="right" style="float: right; clear: left; display: inline-block; font-size: 1.53125em;">Placed by: ' . $_SESSION['name'] .'</div>
        <div class="left" style="float: left; clear: left; display: inline-block; font-size: 2.5em;">#' . $_SESSION['snumber'] . '</div>
        <div class="right" style="float: right; clear: right; display: inline-block; font-size: 1.53125em;">Pay by Scan</div>
    </div>

    <div class="instructions" style="border: 1px black solid; border-radius: 20px;">
        <div>Special Instructions: ' . $_SESSION['sinstruct'] .'</div>
    </div>
</div>

<div class="row" style="max-width: 612px; clear:both; font-size:12px; display: inline-block;">

    <div class="left" style="float: left; margin: 7.5px; padding:15px; border: 1px black solid; max-width: 300px;border-radius: 20px;">
        <h4 style="padding:0; margin:0; float: left; clear: right;">3.5" Herbs</h4><h4 style="padding:0; margin:0; top:0; right:25px; display:inline-block;float: right;">Qty</h4><br/>
        <div class="first" style="float: left; margin-right:5px; text-align:left;">' . $herb1_mail . '</div>
        <div class="second" style="float: right; margin-left:15px;">' . $herb1_quant . '</div>
        <div class="second" style="clear: both; float: right; margin-left:15px;">Total: ' . $_SESSION['total_1'] . '</div>

    </div>

    <div class="right" style="float: left; clear:right; margin: 7.5px; padding:15px; border: 1px black solid; max-width: 300px;border-radius: 20px; display:inline;">
        <h4 style="padding:0; margin:0; float: left; clear: right;">Qrt Herbs</h4><h4 style="padding:0; margin:0; top:0; right:25px; display:inline-block;float: right;">Qty</h4><br/>
        <div class="first" style="float: left; margin-right:5px; text-align:left;">' . $herb2_mail . '</div>
        <div class="second" style="float: right; margin-left:25px;">' . $herb2_quant . '</div>
        <div class="second" style="clear: both; float: right; margin-left:15px;">Total: ' . $_SESSION['total_2'] . '</div>
    </div>

</div>

<div class="row" style="max-width: 612px; clear:both; font-size:12px; display: inline-block;">

    <div class="left" style="float: left; clear: left; margin: 7.5px; padding:15px; border: 1px black solid; max-width: 300px;border-radius: 20px;">
        <h4 style="padding:0; margin:0; float: left; clear: right;">Pak Veggies</h4><h4 style="padding:0; margin:0; top:0; right:25px; display:inline-block;float: right;">Qty</h4><br/>
        <div class="first" style="float: left; margin-right:5px; text-align:left;">' . $veg1_mail . '</div>
        <div class="second" style="float: right; clear:right; margin-left:25px;">' . $veg1_quant . '</div>
        <div class="second" style="clear: both; float: right; margin-left:15px; display: inline-block;">Total: ' . $_SESSION['total_3'] . '</div>
    </div>

    <div class="right" style="float: left; clear:right; margin: 7.5px; padding:15px; border: 1px black solid; max-width: 300px; border-radius: 20px; display:inline;">
        <h4 style="padding:0; margin:0; float: left; clear: right;">4" Veggies</h4><h4 style="padding:0; margin:0; top:0; right:25px; display:inline-block;float: right;">Qty</h4><br/>
        <div class="first" style="float: left; margin-right:5px; text-align:left;">' . $veg2_mail . '</div>
        <div class="second" style="float: right; margin-left:25px;">' . $veg2_quant . '</div>
        <div class="second" style="clear: both; float: right; margin-left:15px;">Total: ' . $_SESSION['total_4'] . '</div>
    </div>

</div>

<div class="row" style="max-width: 612px; clear:both; font-size:12px; display: inline-block;">

    <div class="left" style="float: left; clear: left; margin: 7.5px; padding:15px; border: 1px black solid; max-width: 300px; border-radius: 20px;">
        <h4 style="padding:0; margin:0; float: left; clear: right;">Gal Veggies</h4><h4 style="padding:0; margin:0; top:0; right:25px; display:inline-block;float: right;">Qty</h4><br/>
        <div class="first" style="float: left; margin-right:5px; text-align:left;">' . $veg3_mail . '</div>
        <div class="second" style="float: right; margin-left:25px;">' . $veg3_quant . '</div>
        <div class="second" style="clear: both; float: right; margin-left:15px;">Total: ' . $_SESSION['total_5'] . '</div>
    </div>

    <div class="right" style="float: left; clear:right; margin: 7.5px; padding:15px; border: 1px black solid; max-width: 300px; border-radius: 20px; display:inline;">
        <h4 style="padding:0; margin:0; float: left; clear: right;">Gal Herbs</h4><h4 style="padding:0; margin:0; top:0; right:25px; display:inline-block;float: right;">Qty</h4><br/>
        <div class="first" style="float: left; margin-right: 5px; text-align:left;">' . $herb3_mail . '</div>
        <div class="second" style="float: right; margin-left:25px;">' . $herb3_quant . '</div>
        <div class="second" style="clear: both; float: right; margin-left:15px;">Total: ' . $_SESSION['total_6'] . '</div>
    </div>

</div>

<div class="row" style="max-width:612px;clear:both; font-size:12px; display: inline-block;">

    <div class="left" style="float: left; clear: right; margin: 7.5px; padding:15px; border: 1px black solid; max-width: 300px; border-radius: 20px;">
        <h4 style="padding:0; margin:0; float: left; clear: right;">2 Gal Veggies</h4><h4 style="padding:0; margin:0; top:0; right:25px; display:inline-block;float: right;">Qty</h4><br/>
        <div class="first" style="float: left; text-align:left;">' . $veg4_mail . '</div>
        <div class="second" style=" float: right; margin-left:25px;">' . $veg4_quant . '</div>
        <div class="second" style="clear: both; float: right; margin-left:15px;">Total: ' . $_SESSION['total_7'] . '</div>
    </div>

</div>

1 个答案:

答案 0 :(得分:0)

根据我对Outlook的体验(每个客户端/操作系统可能会有所不同),打印页面会随时随地打破。这由您的打印机/页面设置控制。然后,它会在最大页面高度之上找到的第一个地点打破您的电子邮件。

它可能会在两个表之间选择一个部分,但是强制它不在某个地方中断的唯一方法是使用高度超过该部分的图像。