PHP mail will not send from Windows Server 2008

三世轮回 提交于 2020-01-11 10:12:11

问题


I have two servers. One (linux) will send mail fine using the script below. The second (windows server 2008) sends nothing.

<?php mail ( "nobody@email.com", "Contact Us Form", "This is an email from your site", "From: nobody@email.com" )
?>

回答1:


mail() works very different on linux and windows.

  • On Linux it pipes your mail to the sendmail binary, which does all the work
  • On windows it actually needs to act as an MTA to pass the mail off to another application.

On windows your best bet is to set the SMTP information so PHP can hand off the mail to another server which will take care of final delivery.

http://ca2.php.net/manual/en/mail.configuration.php#ini.smtp

That done (and your webserver restarted to allow the change to take affect) if you're still unable to send mail check the logs for both PHP and the specified MTA to see where things are breaking down.




回答2:


Check your PHP.ini You can also override these with the ini_set function at the script level (I think).

[mail function]
; For Win32 only.
SMTP = xxx.xxx.xxx.xxx
smtp_port = xx


来源:https://stackoverflow.com/questions/5585445/php-mail-will-not-send-from-windows-server-2008

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!