2010-05-29 96 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()函数成功并不意味着电子邮件曾经出现在你的前门。由于标题格式不正确或缺失,雅虎可能会拒绝它。