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条)

报告相同问题?

悬赏问题

  • ¥15 ats2837 spi2从机的代码
  • ¥200 wsl2 vllm qwen1.5部署问题
  • ¥100 有偿求数字经济对经贸的影响机制的一个数学模型,弄不出来已经快要碎掉了
  • ¥15 这个公式写进SIMULINK中的function模块的代码中应该是什么样的
  • ¥15 数学建模数学建模需要
  • ¥15 已知许多点位,想通过高斯分布来随机选择固定数量的点位怎么改
  • ¥20 nao机器人语音识别问题
  • ¥15 怎么生成确定数目的泊松点过程
  • ¥15 layui数据表格多次重载的数据覆盖问题
  • ¥15 python点云生成mesh精度不够怎么办