我有php/html代码与表。它在雅虎,gmail等网站上看起来很好,但在手机上打开gmail应用程序时,它看起来很乱,奇怪的绿色和错误的字体大小。知道怎么解决这个问题吗?下面的链接由两张截图组成。左边的是它在包括gmail在内的所有电子邮件帐户上的外观。右边是iPhone上gmail应用的样子
截图链接
代码如下:
<?php
// Fixes the encoding to uf8
function fixEncoding($in_str)
{
$cur_encoding = mb_detect_encoding($in_str) ;
if($cur_encoding == "UTF-8" && mb_check_encoding($in_str,"UTF-8"))
return $in_str;
else
return utf8_encode($in_str);
} // fixEncoding
?>
<?php
require_once('class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer();
$body = '<html><body>';
$body .= '<table rules="all" style="border-color: #fff; font-family: Arial; width:595px; height:108px; font-size:115%; background-color:#ffffff;" cellpadding="10">';
$body .= "<tr><td style='text-align: center; text-align: middle; vertical-align: middle; vertical-align: center'>
<img style='border: 0px solid ; 'src='http://www.magentastorage.co.uk/mobile/images/emailheader.jpg'></a> </td></tr>";
$body .= '</table>';
$body .= '<table rules="all" style="border-color: #fff; font-family: Arial; width:595px; font-size:115%; background-color:#ffffff;" cellpadding="10"; position:relative; left:"20">';
$body .= "<tr><td style= 'padding-left:21px;'>Dear " .$_GET["name"] ."," . "</td></tr>";
$body .= "<tr><td style= 'padding-left:21px;'>Thank you for visiting our website and contacting us about your storage requirements. Below is a summary of your storage quotation: </td></tr>";
$body .= "<tr> <td style='text-align: left; font-family: Arial; vertical-align: left;'>
<img style='border: 0px solid ; ' src='http://www.magentastorage.co.uk/mobile/images/emailrequirements.png'> </td></tr>";
$body .= '</table>';
$body .= '<table rules="all" style="border-color: #fff; font-family: Arial; width:470px; font-size:115%; background-color:#ffffff;" cellpadding="10">';
$body .= "<tr>";
$body .= "<td style= 'padding-left:21px;'>Unit Size:</td>";
$body .= "<td>";
$body .= $_GET["unitsize"];
$body .= "</td>";
$body .= "<td></td>";
$body .= "</tr>";
$body .= '</table>';
$body .= '<table rules="all" style="border-color: #fff; font-family: Arial; width:595px; font-size:115%; background-color:#ffffff;" cellpadding="10">';
$body .= "<tr> <td style='text-align: left; font-family: Arial; vertical-align: left;'>
<img style='border: 0px solid ; '
src='http://www.magentastorage.co.uk/mobile/images/emailquotation.png'> </td></tr>";
$body .= "<tr><td style= 'padding-left:21px;'>" ."Weekly rental is" ." " ."£" .$_GET["price"] ." " ."</td> </tr>";
$body .= "<tr><td style= 'padding-left:21px;'>This quote includes VAT, insurance cover for up to" ." " ."£" .$_GET["insurance"] ." " ."and a padlock to secure your storage unit</td></tr>";
$body .= "<tr><td style= 'padding-left:21px;'>" ."<strong>" ."**4 WEEKS FREE STORAGE**" ."</strong>" ."</td>";
$body .= "<tr><td style= 'padding-left:21px;'>Simply pay for 4 weeks storage when you move in and we'll give you an extra 4 weeks storage completely free!</td></tr>";
$body .= "<tr><td style= 'padding-left:21px;'>Kind Regards, </td></tr>";
$body .= "<tr><td style= 'padding-left:21px;'>Store Manager </td></tr>";
$body .= "</table>";
$body .= "</body></html>";
我对PHP没有足够的了解,无法给您任何提示,但是我发现静态HTML位有相当多的错误。
<td style='text-align: center; text-align: middle; vertical-align: middle; vertical-align: center'>
在这里,您已经设置了两次垂直对齐。vertical-align: center
无效,应删除。我还将min-width:595px
添加到这个样式声明中。
<table rules="all" style="border-color: #fff; font-family: Arial; width:595px; font-size:115%; background-color:#ffffff;" cellpadding="10"; position:relative; left:"20">
代替border-color: #fff
,只是创建整个边界。border: 3px solid #ffffff
。在样式声明之外有position:relative; left:"20"
,所以应该移动它们。此外,您需要为left
值添加一个单位,并删除cellpadding="10";
中的分号。
<td style='text-align: left; font-family: Arial; vertical-align: left;'>
不能设置垂直对齐为左。
此外,当在电子邮件中工作时,最好使用完整的6个字符的十六进制代码。border: 0px solid
可以替换为border: 0
。我还建议使用绝对字体大小,而不是相对百分比。
再一次,我不知道你的PHP有多可靠,但看到你的HTML/CSS中有相当多的错误,我建议把它们整理出来,你的电子邮件可能会表现得更好。