【问题标题】:pipe to program email script not working管道程序电子邮件脚本不起作用
【发布时间】:2017-03-25 11:29:52
【问题描述】:

我已插入以下链接来传送电子邮件。 链接:public_html/emailer.php 我在 public_html 文件夹中有脚本文件,我正在使用以下脚本: 它应该在目录中创建一个文件,但它不起作用。

#!/public_html/ -q
<?php
/* Read the message from STDIN */
$fd = fopen("php://stdin", "r");
$email = ""; // This will be the variable holding the data.
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);
/* Saves the data into a file */
$fdw = fopen("pipemail.txt", "w");
fwrite($fdw, $email);
fclose($fdw);
/* Script End */
?>

this is how i am setting pipe to program path

【问题讨论】:

  • 在什么情况下不起作用?
  • 它没有创建文件,这意味着脚本根本没有运行,或者我在脚本的第一行有错误。我不知道

标签: php email pipe


【解决方案1】:

这会起作用。

#!/usr/local/bin/php -q
<?php
  $fd = fopen("php://stdin","r");
  $email = "";
  while (!feof($fd)) {
      $email .= fread($fd,1024);
  }
  fclose($fd);
  /* Saves the data into a file */
  $fdw = fopen("pipemail.txt", "w");
  fwrite($fdw, $email);
  fclose($fdw);
?>

将代码放入服务器时,请确保它具有 unix 行 [\n] 结尾。 还要确保脚本有执行权限!

【讨论】:

  • 对不起,在哪里添加unix行?最后像这样 [\r]?
  • 首先尝试使用上面的代码。它已经有 Unix 行尾。
  • 不工作...如果我通过 url 运行脚本,它会创建一个文件,但是当我向我的域电子邮件之一发送电子邮件时,它不会运行脚本。跨度>
  • 告诉我你是如何通过管道传输到这个程序的。您需要指向确切的路径。
  • 我已将图片添加到问题中,请检查
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-10-19
  • 1970-01-01
  • 2011-08-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多