我一直在尝试让PHP发送邮件超过一个月。我正在从000webhost,它工作正常,我的朋友的服务器。PHP邮件返回true(邮件接受发送),但邮件不发送
发送邮件PHP代码是:
$subject = $u.", your infomation";
$message = "Your password is ".$p;
$from = "[email protected]";
$headers = "From:" . $from;
if(mail($e,$subject,$message,$headers))
$_SESSI ON['message']="message sent";
else $_SESSION['message']="error";
在php.ini sendmail的路径是 “/ usr/sbin目录/ sendmail的-t -i”
等/ hosts:
000.000.000.000 inspiron-1000 inspiron-1000.
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
和mail.log:
Jun 9 22:05:07 inspiron-1000 sendmail[24552]: r5A357t5024552: from=www-data, size=144, class=0, nrcpts=1, msgid=<[email protected]>, [email protected]
Jun 9 22:05:07 inspiron-1000 sm-mta[24553]: r5A357A8024553: from=<[email protected]>, size=367, class=0, nrcpts=1, msgid=<[email protected]>, proto=ESMTP, daemon=MTA-v4, relay=ip6-localhost [127.0.0.1]
Jun 9 22:05:08 inspiron-1000 sendmail[24552]: r5A357t5024552: [email protected], ctladdr=www-data (33/33), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=30144, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (r5A357A8024553 Message accepted for delivery)
这是MAILQ: MSP队列状态...
/var/spool/mqueue-client is empty
Total requests: 0
MTA Queue status...
/var/spool/mqueue (5 requests)
-----Q-ID----- --Size-- -----Q-Time----- ------------Sender/Recipient-----------
r5M3LmZV023863* 19 Fri Jun 21 22:21 <[email protected]>
<[email protected]>
r5M3HicX023780* 19 Fri Jun 21 22:17 <[email protected]>
<[email protected]>
r5M3BSDF023465 19 Fri Jun 21 22:11 <[email protected]>
(Deferred: Connection timed out with alt4.gmail-smtp-in.l.goo)
<[email protected]>
r5M36Tjx023175 19 Fri Jun 21 22:06 <[email protected]>
(Deferred: Connection timed out with alt4.gmail-smtp-in.l.goo)
<[email protected]>
r5M33YQf023137* 19 Fri Jun 21 22:03 <[email protected]>
(Deferred: Connection timed out with alt4.gmail-smtp-in.l.goo)
<[email protected]>
Total requests: 5
我增加了MAILQ info – TAAPSogeking
正如您所看到的,您尝试发送的消息正在排队并超时。这可能意味着防火墙阻止了与alt4.gmail-smtp-in.l.goo的连接。再次检查这些日志,并检查sendmail是否配置为向外部发送(它可能已经设置为仅供内部使用)。您也可以尝试[通过telnet连接到该服务器](http://drewsymo.com/how-to/smtp-telnet-example-commands-examples-for-smtp-telnet-testing/),如果失败,这是一个防火墙/连接问题。 – SpenserJ
所以这个问题肯定在sendmail而不是主机? – TAAPSogeking