本文介绍了Windows上的PHP mail():没有错误,未发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在调试一个基于Elgg的网站(我没有开发),我想直接从本地开发计算机(WinXP)发送电子邮件。我正在使用Apache 2.2.11和PHP 5.3.0运行WAMP

I'm currently trying to debug an Elgg-based website (I didn't develop it) and I would like to send the emails directly from local development machine (WinXP). I'm running WAMP with Apache 2.2.11 and PHP 5.3.0

经过一番搜索,我遇到的最简单的解决方案是使用,以通过SMTP将其转发到我的GMail / Google应用程序帐户,然后进行发送。问题是我没有任何错误,但是没有发送电子邮件。

After some searching, the simplest solution that I've come across is using fake sendmail to forward it to my GMail/Google apps account via SMTP and let it do the sending. The problem is that I get no errors whatsoever, but the email isn't being sent.

这是我所做的:


  • 将sendmail.exe和sendmail.ini复制到WAMP中的子文件夹

  • 通过sendmail.ini对其进行配置(配置设置正常)

  • 编辑php.ini以将路径添加到sendmail.exe

    sendmail_path = C:\Program Files\wamp\bin \sendmail\sendmail.exe -t

  • 注释掉了php.ini中的Windows SMTP设置

    ; SMTP =本地主机

    ; smtp_port = 25

    ; sendmail_from = [email protected]

    ; mail.force_extra_parameters =

  • Copied the sendmail.exe and sendmail.ini to a subfolder in WAMP
  • Configured it via sendmail.ini (the configuration settings are ok)
  • Edited php.ini to add the path to sendmail.exe
    sendmail_path = "C:\Program Files\wamp\bin\sendmail\sendmail.exe -t"
  • Commented out the windows SMTP settings in php.ini
    ; SMTP = localhost
    ; smtp_port = 25
    ; sendmail_from = [email protected]
    ; mail.force_extra_parameters =

mail.log文件显示以下内容:

The mail.log file shows the following:

mail() on [C:\Program Files\wamp\www\mail.php:9]: To: xxx --
Headers: From: xxx  Reply-To: xxx  X-Mailer: PHP/5.3.0

我的猜测是问题是默认Windows选项(用于指定服务器而不是sendmail实用程序)未被覆盖。在 phpinfo()中,我仍然得到 SMTP->本地主机 smtp_port-> 25 个选项,即使我发表了评论。

My guess is that the problem is that the default Windows option (to specify the server and not the sendmail utility) is not overriden. In phpinfo() I still get the SMTP -> localhost and smtp_port -> 25 options, even though I commented them.

如果有人设法解决了这个问题,我将非常感谢您的帮助。我认为,使用伪造的sendmail比在计算机上安装邮件服务器要简单得多。

If anyone managed to get this working, I'd really appreciate some help. In my opinion, using fake sendmail is a lot simpler than installing a mail server on your machine.

谢谢!

聚苯乙烯请不要推荐PHPMailer之类的东西,因为我必须使用mail()函数。这就是Elgg的工作方式。

P.S. Please don't suggest PHPMailer and the like, because I have to use the mail() function. That's how Elgg works.

推荐答案

我最终使它开始工作。问题在于路径(用于sendmail)。它在版本5.3.0中已修复,但手册中没有相关信息。

I've gotten it to work eventually. The problem was that PHP had a bug in parsing .ini files with spaces in the path (for sendmail). It was fixed in version 5.3.0, but the manual had no info on this.

因此,是的,可以在Windows:D上将sendmail与PHP一起使用。

So, yes, it is possible to use sendmail with PHP on Windows :D.

谢谢大家的时间!

这篇关于Windows上的PHP mail():没有错误,未发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-09 13:12