php mail()返回false,但不在命令行 [英] php mail() returning false, but not in command line

查看:167
本文介绍了php mail()返回false,但不在命令行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在查看stackoverflow和许多其他网站的想法,但迄今没有任何工作,我需要更多的直接帮助。

I've been looking around on stackoverflow and many other websites for ideas, but nothing has worked so far and I need more direct help.

我有一个专门的Ubuntu服务器(9.04 jaunty)和我正在运行几个PHP网站,与apache2。我的问题是mail()函数已停止工作。自从一段时间以来,我一直在使用PEAR邮件队列大多数电子邮件,所以我不确定邮件()停止工作,但我仍然需要一个OpenCart设置,其他一些事情,但mail()不管我做什么,不断返回假。即使这个简单的代码也不起作用:

I have a dedicated Ubuntu Server (9.04 jaunty) and I'm running several PHP websites there, with apache2. My problem is that the mail() function has stopped working. Since a while back I've been using PEAR Mail Queue for most emails, so I'm not sure exactly when mail() stopped working, but I still need it for an OpenCart setup, among a few other things, but mail() keeps return false no matter what I do. Even this simple code won't work:

<?php
mail('mail@example.com','test','test');
?>

所以,我一直在看php.ini中的Sendmail设置,当我在命令行中运行它时,可以正常运行,并发送电子邮件:

So, I've been looking at the Sendmail-settings in php.ini which all check out, and when I run this in the command line, it works fine and sends me an email:

# sendmail
mail@example.com
test message

所以我以为可能是php本身有一个问题,所以我尝试以下命令:

So I thought it might be php itself that has a problem, so I try the following command:

# php -r "mail('mail@example.com','test','test');"

它也发送电子邮件没有任何问题!那怎么可能呢?我开始认为这可能是某种权限问题,也许www数据在运行脚本时有一些问题。仍然不确定,因为我甚至不能运行这个脚本:

And it also sends the email without any problems! So what could it be? I started thinking it might be some sort of permission problem, that maybe www-data had some issues with running the script. Still not sure about this, because I can't even run this script:

<?php
echo exec('whoami');
?>

它也返回false!我已经运行 visudo 命令,并添加以下行,以防万一:

It also returns false! I've run the visudo command and added the following line just in case:

www-data ALL=(ALL) ALL

我已将文件的用户和组所有者从 root:root www-data:www-data ,但仍然没有!

And I've changed the user and group owners of the files from root:root to www-data:www-data but still nothing!

我还可以尝试什么?一定有的!任何人都可以帮助我吗?

What else can I try? There must be someting! Can anyone help me?

推荐答案

命令行和网络服务器不会共享相同的php.ini!检查在命令行和服务器模块中使用哪个php.ini。

Commandline and webserver don't share the same php.ini! Check which php.ini is used on commandline and in the server module.

这篇关于php mail()返回false,但不在命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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