2012-05-21 58 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

相關問題