php邮件无法正常工作

时间:2010-10-12 15:43:40

标签: php

php邮件无效。没有错误消息。 php.ini上显示错误,显示E_ALL也开启。

<?php
 $to = "test@abc.com";
 $subject = "Hi!";
 $body = "Hi,\n\nHow are you?";

$headers = 'From: test@abc.com' . "\r\n" .
    'Reply-To: test@abc.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

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

 ?>

2 个答案:

答案 0 :(得分:2)

首先,检查mail()

的返回值
$sent = mail($to, $subject, $body, $headers);
if (!$sent) {
    // there was some error in the message itself, our MTA rejected it or there's an error in MTA's config
} else {
    // message was accepted for delivery
}

其次,检查PHP's e-mail settings(请注意,在Linux服务器上sendmail_path是相关的,而在Windows服务器上SMTPsmtp_port)尝试发送电子邮件与其他应用程序一起邮寄。

第三,根据您使用的SMTP服务器,检查其日志中是否有任何警告或错误(例如,无法联系目标服务器,未连接到网络等)。

第四,如果你已经确定邮件已成功离开你的网络,那就交叉你的手指并希望最好。说真的,从那时起你就没有什么可以为你的电子邮件做的了 - 如果它没有交付,你就无能为力了。

稍微上查看these tips,增加您的邮件不会被标记为垃圾邮件的可能性

答案 1 :(得分:2)

非常感谢你的回复。这真的很有帮助。这是一个许可问题

drwxrwx --- 2 smmsp smmsp 4096 10月12日12:00 / var / spool / clientmqueue /

更改为

drwxrwx --- 2 apache smmsp 4096 10月12日12:56 / var / spool / clientmqueue /

它有效!

相关问题