Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php脚本上的mail命令在从html调用时不起作用_Php_Linux_Email_Command - Fatal编程技术网

php脚本上的mail命令在从html调用时不起作用

php脚本上的mail命令在从html调用时不起作用,php,linux,email,command,Php,Linux,Email,Command,我开始在Centos 6.1 apache服务器上编写一个小型测试表单。它被设置为当前默认配置。基本网页是一个在Post上调用php脚本的HTML。从命令行运行脚本时,响应成功并立即发送电子邮件。另一方面,如果我使用html网页,它会调用PHP,传递变量,但最后不会执行mail命令 我包含了一个echo,以查看变量内容是否被放入消息变量中,消息变量确实如此。我认为这可能与SELinux的政策有关?我在这个论坛的另一篇帖子上读到过,但在那个例子中,它是为sendmail设置的。我没有在centos

我开始在Centos 6.1 apache服务器上编写一个小型测试表单。它被设置为当前默认配置。基本网页是一个在Post上调用php脚本的HTML。从命令行运行脚本时,响应成功并立即发送电子邮件。另一方面,如果我使用html网页,它会调用PHP,传递变量,但最后不会执行mail命令

我包含了一个echo,以查看变量内容是否被放入消息变量中,消息变量确实如此。我认为这可能与SELinux的政策有关?我在这个论坛的另一篇帖子上读到过,但在那个例子中,它是为sendmail设置的。我没有在centos服务器上安装或运行sendmail,但默认情况下postfix正在运行。是我读的论坛帖子吗

运行sestatus-b | grep sendmail时

它也被设置为httpd_can_sendmail off,就像在该线程中一样

如果我运行sestatus-b | grep后缀

我得到的唯一条目是allow\u postfix\u local\u write\u mail\u spool on

我应该设置引用线程上声明的相同sendmail selinux策略吗

这是php脚本内容:

$name = $_POST['yourname'];
$lastname = $_POST['yourlastname'];

$header = 'From: ' . $mail . " \r\n";
$header .= "X-Mailer: PHP/" . phpversion() . " \r\n";
$header .= "Mime-Version: 1.0 \r\n";
$header .= "Content-Type: text/plain";

$message = "this message was sent by " . $name . ",   " . $lastname . " \r\n";
$forperson = 'myemail@myemail.org';
$subject = 'new message';

echo $message;
mail($forperson, $subject, utf8_decode($message), $header);

提前感谢您的建议。

在这一天,83%的人中又有一个贡献者诞生了。对不起,伙计们,在这里输入的代码编辑中出现了mesage拼写错误。我将文本抄写到页面上的消息正文中。就在这里更正了。