doufang1954 2014-06-18 11:53
浏览 31

Gmail应用程序显示错误的字体大小和颜色

I have the php/html code with tables. It looks perfectly OK in yahoo, gmail etc but looks so messed up with weird green colors and wrong varying font sizes when opened in gmail application on mobile phone only. Any idea how this can be fixed? the link below consists of 2 screenshots. The one on left is how it looks on all email accounts including gmail. and the one on right is how it looks on gmail application on iPhone.

Link for the screenshot

The code is as below:

<?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" ." " ."&pound;" .$_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>";
  • 写回答

1条回答 默认 最新

  • duankua3620 2014-07-02 13:07
    关注

    I'm not knowledgeable enough about PHP to give you any tips, but I see quite a few things wrong with the static HTML bits.

    <td style='text-align: center; text-align: middle; vertical-align: middle;      vertical-align: center'>
    

    Here, you've set the vertical align twice. vertical-align: center isn't valid and should be removed. I would also add min-width:595px to this style declaration.

    <table rules="all" style="border-color: #fff; font-family: Arial; width:595px; font-size:115%; background-color:#ffffff;" cellpadding="10"; position:relative; left:"20">
    

    Instead of border-color: #fff, just create the entire border. border: 3px solid #ffffff. You have position:relative; left:"20" outside of your style declaration, so they should be moved. Also, you'll need to add a unit for your left value and remove the semi-colon in cellpadding="10";.

    <td style='text-align: left; font-family: Arial; vertical-align: left;'>
    

    You cannot set vertical align to left.

    Also, when working in email, it is best to use the full, 6-character hex code. border: 0px solid can be replaced with border: 0. I would also suggest using absolute font sizes, rather than relative percentages.

    Once again, I don't know how solid your PHP is, but seeing how there's quite a few mistakes in your HTML/CSS, I suggest getting that sorted out and your email may behave a bit nicer.

    评论

报告相同问题?

悬赏问题

  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思