PHP的邮件()命令行而不是Apache的作品 [英] PHP mail() works from command line but not apache
问题描述
我试图找出为什么在PHP邮件功能时,通过Web浏览器调用(即Apache的)失败,但我可以使用运行在命令行相同的脚本
I'm trying to figure out why the mail function in PHP fails when called via web browser (i.e. apache), but I can run the same script from the command line using
PHP -f mailtest.php
php -f mailtest.php
这是我的客户的Fedora服务器中的一个,所以我不完全神交,但我确实有根访问应该我需要改变任何东西。
This is one of my client's Fedora servers, so I don't grok it completely, but I do have root access should I need to change anything.
在php.ini中的:
from php.ini:
sendmail_path = / usr / sbin目录/ sendmail的-t -i
sendmail_path = /usr/sbin/sendmail -t -i
不知道这可能无所谓,但/ usr / sbin目录/ sendmail的是一个符号链接到/ etc /替代品/ MTA,这是一个符号链接回/usr/sbin/sendmail.sendmail。 FWIW apache用户确实有(直接在命令行测试的sendmail)的sendmail运行许可。
Not sure if this could matter, but /usr/sbin/sendmail is a symlink to /etc/alternatives/mta, which is a symlink back to /usr/sbin/sendmail.sendmail. FWIW the apache user does have permission to run sendmail (tested sendmail directly from the command line).
OS: Fedora Core 7 Linux (kernel 2.6.23.17)
Apache: 2.2.8
PHP: 5.2.6
在这里任何帮助将大大AP preciated!
Any help here will be greatly appreciated!
推荐答案
我发现这个问题。 SELinux的是preventing阿帕奇从能够使用sendmail。要诊断,我用
I found the problem. SELinux was preventing apache from being able to use sendmail. To diagnose, I used
$ sestatus -b | grep sendmail
httpd_can_sendmail off
然后真正解决问题:
Then to actually fix the problem:
$ restorecon /usr/sbin/sendmail
$ setsebool -P httpd_can_sendmail 1
了解更多关于它这里 。
Read more about it here.
这篇关于PHP的邮件()命令行而不是Apache的作品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!