2012-05-21 62 views
0

我使用一个简单的电子邮件功能,它搅乱了我的所有css ..它把所有的div一个在另一个下面而不是在包装div .. 有没有办法克服它?PHP的邮件功能混乱我的电子邮件css

function email_template($app_link, $img_link, $app_name){ 
     $message='<html> 
     <head> 

    <title>Purchase Successful!</title> 
     </head> 
      <body> 

     <div id="pic" style="position:relative; text-align:center; margin:0px auto;width:320px; height: 480px;"> 
     <a href="http://1111111111111edapps.com"> 
     <div id="logo" style="position:absolute; width:130px; height:35px; z-index:99999;top:5;"> 
     </div> 
     </a> 
     <div id="clickHere" style=" position:absolute;width:320px;height:50px;z-index:99999;top:60px;text-align: center;"> 
      <span id="clickHereText" style="font-size:140%; color:white;"> <a href="'.$app_link.'" style="color:yellow">Click Here</a> to Download<br/> 
       your phonemate app 
       </span> 
     </div> 

     <div id="appImg" style="position:absolute;width:50px; height:50px;z-index:99999; left:50px;top:210px;"> 
      <img src="http://1111111111111edapps.com/'.$img_link.'" width="53px" height="53px"/> 
     </div> 
     <div id="appLabel" style="position:absolute; width:50px; height:10px; z-index:99999; text-align: center; left:50px; top:260px;"> 
      <span style="color:white; font-size: 50%;">'.$app_name.'</span> 
     </div> 

     <div id="downloadLink" style="position:absolute; width:320px; height:30px; z-index:99999; bottom:0px; text-align: center;"> 
      <a href="'.$app_link.'" style="color:yellow">Download our app on 1111111111111edApps.com</a> 
     </div> 
     <img src="http://1111111111111edapps.com/email/images/1111111111111edAppEmail.jpg"/> 
    </div> 
     </body> 
    </html>'; 

    return $message; 


} 

电子邮件功能的工作原理..但div的应该是..pic div..but他们外面..里面有没有提供电子邮件,并将它呈现的一样,当一种方法,我在常规页面上测试它?

额外注:我的PHP:

 $to = /*TO EMAIL ADDRESS*/""; 
$subject = "Hi!"; 
$body=email_template('http://1111111111111edapps.com/app_dl.php?app_id=34', $app_pic, $app_name); 
echo $body; 
$headers = 'MIME-Version: 1.0' . "\r\n"; 
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
if (mail($to, $subject, $body,$headers)) { 
    echo("<p>Message successfully sent!</p>"); 
    } else { 
    echo("<p>Message delivery failed...</p>"); 
    } 
    } 
+1

点击这里==删除电子邮件或离开我的书中的网站 –

+2

请尝试看看这里http://www.campaignmonitor.com/css/,以确保它不是收件人的电子邮件程序。一般浮动和绝对不工作。在很多情况下,表格对于网站来说都是不满的,但它们仍然是html电子邮件的发展方向。 – scott

+4

我不做很多邮件开发,但上次我做的“最佳做法”似乎是将所有的CSS与'style'属性内联,而不是尝试使用样式块或链接的样式表......建议使用表格复杂的事情。 – prodigitalson

回答

3

我跑你的代码通过W3C标记验证,它似乎是你可能需要在这里重新考虑你的方法:

<a href="http://1111111111111edapps.com"> 
<div id="logo" style="position:absolute; width:130px; height:35px; z-index:99999;top:5;"> 
</div> 
</a> 

将内嵌元素内部的元素(例如带有display:block的跨度;应用)。我愿意下注(此时此刻),非法部门正在给你造成一些问题。请记住,电子邮件客户端并非设计用于处理HTML错误以及Web浏览器,虽然某些客户端的支持非常好,但其他客户端却可能落后很多(我在看你,Outlook 2007+ )。

您没有提及您测试过哪些电子邮件客户端以及哪些给您提供了问题,因此如果更正您的标记不能解决问题,请多给我们一些信息。

+0

我在谷歌和雅虎上测试过,我们的建议不起作用 –

+0

On谷歌和雅虎在哪些浏览器?基于浏览器的邮件应用程序,如Hotmail,GMail和雅虎(更不用说Excite和其他人)在删除所有样式和重写它直到它看起来没有像你的目的是什么?它在Thunderbird,Apple Mail,Outlook等中的外观如何?本文可能会帮助你:http://www.sitepoint.com/code-html-email-newsletters/ – nealio82

相关问题