2010-05-29 42 views
0

我已經寫了一個代碼發送郵件在雅虎或gmail.Mail發送在Gmail上,但我沒有看到任何郵件在雅虎郵件。並在Gmail中,我看到所有的HTML內容與消息。 這裏是我的代碼...郵件功能不工作雅虎郵件編號

  $headers = "From: \"".$from_name."\" <".$from_email.">\n"; 
    $headers .= "To: \"".$to_name."\" <".$to_email.">\n"; 
    $headers .= "Return-Path: <".$from_email.">\n"; 
    $headers .= "MIME-Version: 1.0\n"; 
    $headers .= "Content-Type: text/HTML; charset=ISO-8859-1\n"; 

          // message 
      $message = ' 
      <html> 
      <head> 
       <title>Registration</title> 
      </head> 
      <body>    
       <table><tr> 
        <td> <a href="#'> Click Here To Activate Your account</a> 
        Thanks To visit site.com 
        </td> 
       </tr> 
       </table> 
      </body> 
      </html>'; 

      if(mail('', $subject, $message, $headers)) 
       echo "successfully register !! please check your mail and clik on confirmation link"; 
+0

歡迎來到SO。請指定您嘗試從哪個服務器發送的內容,特別是您用作'from_email'的內容。 – 2010-05-29 19:19:59

回答

0
$to = $to_email; 
    $headers = "From: \"".$from_name."\" <".$from_email.">\n"; 
    $headers .= "To: \"".$to_name."\" <".$to_email.">\n"; 
    $headers .= "Return-Path: <".$from_email.">\n"; 
    $headers .= "MIME-Version: 1.0\n"; 
    $headers .= "Content-Type: text/HTML; charset=ISO-8859-1\n"; 

$message = <<<EOD 
<html> 
      <head> 
       <title>Registration</title> 
      </head> 
      <body>    
       <table><tr> 
        <td> <a href="#'> Click Here To Activate Your account</a> 
        Thanks To visit site.com 
        </td> 
       </tr> 
       </table> 
      </body> 
      </html> 
EOD; 

if(mail($to, $subject, $message, $headers)) 
       echo "successfully register !! please check your mail and clik on confirmation link"; 

嘗試,而不是你的消息字符串

0

您可能需要使用類似PHPMailer而不是試圖自己建立一個MIME消息這一點。它隱藏了設置標題的所有醜陋的工作,以及所做的只是提供內容。

在任何情況下,假設您正確構建了郵件,是否檢查了郵件服務器的外發日誌以查看郵件是否嘗試訪問Yahoo的郵件交換器?僅僅因爲PHP中的mail()函數成功並不意味着電子郵件曾經出現在你的前門。由於標題格式不正確或缺失,雅虎可能會拒絕它。