PHP mail: 为什么总是不成功呢?

作者:半瓶墨水   链接:http://www.2maomao.com/blog/php-mail-fails/

明明wordpress里面也是直接调用的mail函数,我稍微改了地址,也调用一下

后来发现我调用的就总是出错(调用结果直接返回false),不知道为啥呢?

  1. $msg = "E-MAIL SENT FROM WWW SITE\n";
  2. $msg .= "Sender's E-Mail:\t$_POST[sender_email]\n";
  3. $msg .= "Message:\t$_POST[message]\n";
  4. $to = "maoimao@gmail.com";
  5. $subject = "Web Site Feedback";
  6. $header  = "MIME-Version: 1.0\n";
  7. $header .= "Content-Type: text/plain; charset=\"utf-8\"\n";
  8. $header .= "From:" . $_POST[sender_name] . "<" . $_POST[sender_email]. ">\n";
  9.  
  10. if (@mail($to, $subject, $msg, $header)) {
  11.     echo "<h2>Hey " . $_POST[sender_name] . ",</h2><p>thanks for your message! I'll get back to you as soon as possible.</p>";
  12. } else
  13. {
  14.     echo "Oooops...something wrong with the mail script or mail server...";
  15.     exit;
  16. }
  17. ?>

Update: 今天再试就可以了,估计是bluehost.com邮件服务器本身的问题

留下回复