PHP mail() no longer works after update to OSX Mountain Lion(更新到 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() 不再有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:更新到 OSX Mountain Lion 后 PHP mail() 不再有效
基础教程推荐
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何替换eregi() 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
