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

查看:148
本文介绍了更新到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.

Webserver:XAMPP 1.7.3

Webserver: XAMPP 1.7.3

我使用这段代码来测试 mail() function:

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:fatal: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

在您的终端执行以下操作:

Do the following at your terminal:

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-on-os-x-mountain-lion

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

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