没有用php发送电子邮件

时间:2012-02-06 11:01:14

标签: php email

             $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: mail@example.com"
        ));




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


                 }

基本上,电子邮件正在打印成功发送..但在我的电子邮件中我没有收到任何电子邮件..

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

$customer_email = [my-email-address]

2 个答案:

答案 0 :(得分:1)

标题需要由CRLF分隔(回车和换行):

$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=windows-1255\r\n";
$headers .= "From: mail@example.com\r\n";

或(更容易阅读)

$headers = implode("\r\n", array(
  "MIME-Version: 1.0",
  "Content-type: text/html; charset=windows-1255",
  "From: mail@example.com"
));

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

答案 1 :(得分:-1)

你应该使用引号:

$customer_email = "makovetskiyd@yahoo.com";