当没有指定标题时,Sendmail不能从本地PHP工作

我无法让我的本地XAMPP服务器通过我的远程SMTP服务器发送电子邮件。

PHP中,如果我把:

$headers = "From: [email protected]\r\n"; mail('[email protected]', 'test', '', $headers); 

然后这工作。 但是,如果我不指定标题,即:

 mail('[email protected]', 'test', ''); 

然后这失败了。 sendmail.log文件说:

 smtpstatus=554 smtpmsg='554 Message refused.' errormsg='the server did not accept the mail' exitcode=EX_UNAVAILABLE 

我试着在我的php.ini中更改我的sendmail命令:

 sendmail_path = "C:/xampp/sendmail/sendmail.exe -t -f [email protected]" 

但是这也行不通。

感谢任何帮助,丹。

PS。 这是在窗户上。

从PHP邮件()文档:

发送邮件时,邮件必须包含From头。 这可以使用additional_headers参数来设置,或者可以在php.ini中设置默认值。

至于你的sendmail命令行,我相信-f指令和地址需要在一起。 即:

[email protected]

和平,汤姆