gpt4 book ai didi

php - sendfax php 不工作,给出代码 255

转载 作者:行者123 更新时间:2023-12-04 19:35:11 24 4
gpt4 key购买 nike

我正在尝试使用 sendfax 传真,但它不起作用,当我回显我的 exec 语句时它工作正常......我的执行问题是什么?

$tmpfname = tempnam("/tmp", $_REQUEST['Email']);

$handle = fopen($tmpfname, "w");
fwrite($handle, $body);
fclose($handle);


exec('sendfax -n -d $to $tmpfname', $test2, $test3);
var_dump($test2);
echo $test3;
?>

我在页面上得到的响应是:
array(0) { } 255

谢谢你的帮助!

最佳答案

您正在使用 'single quote strings'其中do not have variable values interpolated .尝试更换:

exec('sendfax -n -d $to $tmpfname', $test2, $test3);

和:
exec("sendfax -n -d $to $tmpfname", $test2, $test3);

此外,您必须确定 $to也不是 $tmpfname包含任何 shell 元字符。就目前而言, foo;rm -rf /&@example.com 的电子邮件地址可能会删除您关心的一些文件。 (我认为使用 $_REQUEST['Email'] 作为文件名的一部分是一个坏主意。)

请务必阅读 notes在 PHP exec()文档页面。

关于php - sendfax php 不工作,给出代码 255,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8175218/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com