发送电子邮件失败.具有 PHP 函数


sending email fails.. with php function

我有有效的电子邮件方法:

   <?php
     $to = "eddy2012@gmail.com";
     $subject = "Hi!";
    $body=email_template('http://zzzzedapps.com/app_dl.php?app_id=34', $app_pic, $app_name);
    echo $body;
     $headers = 'From: info@zzzzedapps.com' . "'r'n" .
        'Reply-To: info@zzzzedapps.com' . "'r'n" .
        'X-Mailer: PHP/' . phpversion();
     if (mail($to, $subject, $body,$headers)) {
       echo("<p>Message successfully sent!</p>");
      } else {
       echo("<p>Message delivery failed...</p>");
      }
     ?>

但是当我使用此函数设置正文变量时..:

   function email_template($app_link, $img_link, $app_name){
       $message='
            <html xmlns="http://www.w3.org/1999/xhtml">
            <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            </head>
            <body>
      <div id="pic" style="position:relative; text-align:center; margin:0px auto;width:320px; height: 480px;">
       <a href="http://zzzzedapps.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://zzzzedapps.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 zzzzedApps.com</a>
        </div>
       <img src="http://zzzzedapps.com/email/images/zzzzedAppEmail.jpg"/>
    </div>
       </body>
   </html>';
  return $message;
}

它无法传递电子邮件。

此操作失败:

$body=email_template('http://zzzzedapps.com/app_dl.php?app_id=34', $app_pic, $app_name);

虽然身体呼应成功?

我在哪里有错误......我该如何克服它?

您正在使用 php 的 mail 函数发送 html 邮件,请查看手册,特别是:

// To send HTML mail, the Content-type header must be set

在示例 #4 中。

我也很确定你需要摆脱doctype.