Sending HTML mail through PHP - strange rendering
I have a simple table:
<table cellpadding="0" cellspacing="0" style="width:600px">
<tr>
<td style="width:100px; padding:5px; border:1px solid #444">E-mail</td>
开发者_如何学JAVA<td style="width:500px; padding:5px; border:1px solid #444">ex@ex.com</td>
</tr>
<tr>
<td style="width:100px; padding:5px; border:1px solid #444">Message</td>
<td style="width:500px; padding:5px; border:1px solid #444">sometext</td>
</tr>
</table>
When I test it, it looks fine:
When I send it through PHP mail() function, it looks like this:
Why is that margin there?
Just in case, my mail() headers are:
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
The width of your table is 600px.
The width of the cells adds up as follows:
First cell: 1px border + 5px padding + 100px width + 5px padding + 1px border = 112px Second cell 1px border + 5px padding + 500px width + 5px padding + 1px border = 512px
Total width: 624px in a 600px width table.
This may not be the problem, but I bet it is not helping.
I suggest you correct this first and then see what happens.
did you by any chance insert \n\r between the rows in mail()?
Well, figured it out - the problem was that I did nl2br($message)
before sending.
($message contains the above HTML code)
But thank you all for participation!
精彩评论