0

私は単純な電子メール関数を使用し、それは私のすべてのcssを台無しにします..それはラッパーdivではなくすべてのdivを上下に配置します..それを克服する方法はありますか?

 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の内側にある必要がありますが、外側にあります。メールを配信して、通常のページでテストする場合と同じようにレンダリングする方法はありますか?

追記:私の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>");
  }
  }
4

1 に答える 1

3

コードを W3C マークアップ バリデーターで実行しましたが、ここでアプローチを再検討する必要があるようです。

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

a 要素内にインライン要素を配置します (display: block; を適用したスパンなど)。違法なdivがあなたにいくつかの問題を引き起こしていることに(現時点で)喜んで賭けます。

電子メール クライアントは、Web ブラウザーのように HTML エラーを処理するようには設計されていないことを覚えておいてください。一部のクライアントのサポートは非​​常に優れていますが、他のクライアントはかなり遅れている可能性があります (私は Outlook 2007+ を見ています)。

テストした電子メール クライアントと問題を引き起こした電子メール クライアントについて言及していないため、マークアップを修正しても問題が解決しない場合は、もう少し情報を提供してください。

于 2012-05-21T15:20:51.083 に答える