doucheng1884 2011-11-22 19:16
浏览 9
已采纳

Php Mail()没有发送任何电子邮件? [重复]

This question already has an answer here:

I have a mail function

 $to = "fahad@somewhere.com";
 $subject = "Voucher Number: ".$voucher;
     $message = '<html><body>';
     $message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
     $message .= "<tr style='background: #eee;'><td><strong>Voucher#:</strong> </td><td>" . strip_tags($voucher) . "</td></tr>";
     $message .= "<tr><td><strong>Name:</strong> </td><td>" . strip_tags($name) . "</td></tr>";
     $message .= "<tr><td><strong>Phone Number:</strong> </td><td>" . strip_tags($product) . "</td></tr>";
      $message .= "<tr><td><strong>Email:</strong> </td><td>" . strip_tags($email) . "</td></tr>";


//set content-type
$headers = "MIME-Version: 1.0" . "
";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "
";

// More headers
$headers .= 'From: <livingdeal@overstock-king.com>' . "
";
$headers .= 'cc:'. $email . "
";

mail($to,$subject,$message,$headers);

For some reason I'm not getting any mail sent at all. The service is hosted so i'm not running it from localhost, and even when I write

if (mail(....))
{ echo "success";
}
else { echo "failed"; }

I always get success, so my suspicion is that it is a problem on the server end. If php mail goes from port 25 is there any way to change the port to a different one in the script? or would it be in php.ini.

Also, would I be able to use a different server (that has a different domain) to send the mail without redirecting the use to that other webpage? I guess in other words can I connect to an smtp server through a php script before sending the mail?

</div>
  • 写回答

2条回答 默认 最新

  • duanjing7651 2011-11-22 19:33
    关注

    Mail() doesn't send mail, it submits it to the server's mail daemon for sending. If it returns true, that merely means that it was successfully submitted to the queue.

    You need to look at the logs of your mail daemon to determine if the messages are in the queue, if they were actually sent, and if not, what error messages were logged when the message failed to send.

    BTW, the machine is running a mail daemon, right?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
  • ¥30 ppOCRLabel导出识别结果失败
  • ¥15 Centos7 / PETGEM