2012-02-06 184 views
0
   $subject = "QA details were obtained"; 
       $body = " 
     email Info 
     "; 
     $headers = implode("\r\n", array(
      "MIME-Version: 1.0", 
      "Content-type: text/html; charset=windows-1255", 
      "From: [email protected]" 
     )); 




       if (mail($customer_email, $subject, $body,$headers)) { 
        echo "<p>Message successfully sent!</p>"; 


       } 

基本上,电子邮件被打印为成功发送。但是在我的电子邮件,我没有得到任何电子邮件..不能用PHP发送电子邮件

PS。我发送邮件到自己,所以变量是:

$customer_email = [my-email-address] 
+0

在机器上配置了邮件吗?你有没有检查你的邮件服务器的日志和这台机器的邮件日志? – 2012-02-06 11:03:30

+0

我该怎么做/?我正在使用雅虎。我有yahoos邮件。我没有得到消息.. – 2012-02-06 11:04:42

+0

你有没有在垃圾邮件箱中检查你的邮件? – 2012-02-06 11:05:33

回答

-1

你应该用引号标记:

$customer_email = "[email protected]"; 
+1

这是不相关的elvenbyte – 2012-02-06 11:26:19

+0

我不这么认为,在第一条消息中,在编辑问题之前,您有$ customer_email = [email protected],这是错误的。如果您有这样的邮件地址,您将永远不会使用mail()函数发送邮件。也许这不是一个完美的答案,但我不认为这是一个减号,但我无法做任何事情,所以做你想做的。 – elvenbyte 2012-02-06 12:16:00

1

页眉需要以CRLF分隔(回车&换行):

$headers = "MIME-Version: 1.0\r\n"; 
$headers .= "Content-type: text/html; charset=windows-1255\r\n"; 
$headers .= "From: [email protected]\r\n"; 

或(更易读)

$headers = implode("\r\n", array(
    "MIME-Version: 1.0", 
    "Content-type: text/html; charset=windows-1255", 
    "From: [email protected]" 
)); 

否则,所有标题将被解释为单个无效标题,并可能导致邮件未被发送。

+0

嗯......谢谢,我现在就试试吧 – 2012-02-06 11:16:42

+0

还是不会发 – 2012-02-06 11:19:32