更新到 OSX Mountain Lion 后 PHP mail() 不再有效 [英] PHP mail() no longer works after update to OSX Mountain Lion

查看:20
本文介绍了更新到 OSX Mountain Lion 后 PHP mail() 不再有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我昨天刚刚将 OS X 更新到 Mountain Lion,但是 php 函数 mail() 不再起作用了.

I just updated OS X to Mountain Lion yesterday, but the php function mail() does not work anymore.

更新前,PHP mail() 函数运行良好,Apple 邮件运行良好.更新后,Apple 邮件可以正常工作,但是 PHP mail() 函数不起作用.

Before updating, the PHP mail() function worked fine, Apple mail works fine. After updating, Apple mail works fine, but PHP mail() function DOES NOT work.

网络服务器:XAMPP 1.7.3

Webserver: XAMPP 1.7.3

我用这段代码来测试mail()函数:

I use this code to test the mail() function:

if (mail($to, $object, $content, "From: ". $from)) 
{ 
    echo 'send '; 
} 
else 
{ 
    echo "not send"; 
}

显示:不发送

我有什么需要改变的吗?比如 php.ini 还是别的什么?

Anything I have to change? such as the php.ini or something else?

提前致谢.

推荐答案

终于找到了解决方案.查看error_log(/Applications/XAMPP/xamppfiles/logs/error_log)后,出现错误:sendmail:致命:chdir/Library/Server/Mail/Data/spool:没有这样的文件或目录

Finally I found the solution. After looking at the error_log (/Applications/XAMPP/xamppfiles/logs/error_log), there is an error: sendmail: fatal: chdir /Library/Server/Mail/Data/spool: No such file or directory

在终端执行以下操作:

sudo mkdir -p /Library/Server/Mail/Data/spool
sudo /usr/sbin/postfix set-permissions
sudo /usr/sbin/postfix start

然后 php mail() 工作!

Then the php mail() works!

参考:https://apple.stackexchange.com/questions/54051/sendmail-os-x-mountain-lion 上的错误

这篇关于更新到 OSX Mountain Lion 后 PHP mail() 不再有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆