我使用包含 Apache 2.4.2、PHP 5.4.5 和 MySQL 5.5 的 XAMPP 1.8.0 升级了我的本地服务器。
我通过运行 MercuryMail 使用 PHP mail() 函数发送邮件,但收件箱中没有收到电子邮件。
当我使用 Mozilla Thunderbird 进行测试时,可以发送邮件。并且 mail() 函数似乎没有发出任何错误。
我检查了我的 XAMPP 安装路径 D:\xampp\php 中的 php.ini。我在下面看到了这个
[mail function]
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
; SMTP = localhost
; smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
; sendmail_from = postmaster@localhost
; XAMPP IMPORTANT NOTE (1): If XAMPP is installed in a base directory with spaces (e.g. c:\program filesD:\xampp) fakemail and mailtodisk do not work correctly.
; XAMPP IMPORTANT NOTE (2): In this case please copy the sendmail or mailtodisk folder in your root folder (e.g. C:\sendmail) and use this for sendmail_path.
; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder)
; sendmail_path = "\"D:\xampp\sendmail\sendmail.exe\" -t"
; XAMPP: Comment out this if you want to work with mailToDisk, It writes all mails in the D:\xampp\mailoutput folder
; sendmail_path = "D:\xampp\mailtodisk\mailtodisk.exe"
我调整了 SMTP 设置的一些组合。
我注释掉了主机和端口
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
SMTP = localhost
smtp_port = 25
我注释掉了sendmail_path,但是没有用。无法发送邮件。
; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder)
sendmail_path = "\"D:\xampp\sendmail\sendmail.exe\" -t"
再次,我注释掉了另一个 sendmail_path 以使用 mailToDisk
; XAMPP: Comment out this if you want to work with mailToDisk, It writes all mails in the D:\xampp\mailoutput folder
sendmail_path = "D:\xampp\mailtodisk\mailtodisk.exe"
它似乎有效,但收件箱中没有收到邮件。在 D:\xampp\mailoutput
中找不到任何内容在 php 邮件日志 (D:\xampp\php\logs\php_mail.log) 中,我发现了几行日志,可能表示邮件正在发送。
mail() on [D:\xampp\htdocs\....:127]: To: sithu@localhost.com -- Headers: MIME-Version: 1.0 Content-type: text/html; charset=text/html Return-Path:Sithu <stk@localhost.com> From: Sithu <stk@localhost.com> Reply-To: Sithu <stk@localhost.com>
mail() on [D:\xampp\htdocs\....:127]: To: test@localhost.com -- Headers: MIME-Version: 1.0 Content-type: text/html; charset=text/html Return-Path:admin@localhost.com From: admin@localhost.com Reply-To: admin@localhost.com
mail() on [D:\xampp\htdocs\....:127]: To: test@localhost.com -- Headers: MIME-Version: 1.0 Content-type: text/html; charset=text/html Return-Path:Members <admin@localhost.com> From: Members <admin@localhost.com> Reply-To: Members <admin@localhost.com>
我也尝试注释掉 sendmail_from,但没有成功。
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = postmaster@localhost
我还缺少任何配置吗?
[编辑]
Mercury 邮件服务器正在运行。
每当我更新 php.ini 时,我都会重新启动 Apache 服务器。
最佳答案
我只需要配置D:\xampp\sendmail\sendmail.ini 默认情况下,它包含行
smtp_server=mail.mydomain.com
我不得不把它改成
smtp_server=localhost
老版本的XAMPP不需要配置。
D:\xampp\php\php.ini中[邮件功能]
的正确配置是
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
SMTP = 127.0.0.1
smtp_port = 25
; XAMPP IMPORTANT NOTE (1): If XAMPP is installed in a base directory with spaces (e.g. c:\program filesD:\xampp) fakemail and mailtodisk do not work correctly.
; XAMPP IMPORTANT NOTE (2): In this case please copy the sendmail or mailtodisk folder in your root folder (e.g. C:\sendmail) and use this for sendmail_path.
; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder)
sendmail_path = "\"D:\xampp\sendmail\sendmail.exe\" -t"
; XAMPP: Comment out this if you want to work with mailToDisk, It writes all mails in the D:\xampp\mailoutput folder
; sendmail_path = "D:\xampp\mailtodisk\mailtodisk.exe"
现在,我在收件箱中收到邮件。请注意,“D:\xampp\”是我的XAMPP安装路径。
关于php - XAMPP 1.8.0、MercuryMail 和 mail() 在收件箱中没有收到邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13100659/