【问题标题】:PHP Email Piping "can't exec" errorPHP 电子邮件管道“无法执行”错误
【发布时间】:2017-04-05 06:18:22
【问题描述】:

我正在开发一个需要将电子邮件传送到 php 脚本的应用程序,该脚本将读取入站电子邮件并根据内容进行处理。我已根据需要将文件夹和脚本设置为 chmod 755,并且该域的默认包罗万象电子邮件通过管道传输到脚本。这是基本的测试脚本:

#!/usr/local/bin/php
<?php
// ^ yes, that's the proper path to php
// read the email
$email = "";
$fp = fopen("php://stdin", "r");
while (!feof($fp)) {
    $email .= fread($fp, 1024);
}
fclose($fp);

// for testing put the email into a file on the server.
$t = microtime(true);
file_put_contents('/home/MYACCOUNT/public_html/THEDOMAIN.com/pipe/email-' . $t . '.txt', $email);

// email me a copy of the inbound email
$email = wordwrap($email, 70, "\r\n");
$to      = 'MYEMAIL@gmail.com';
$subject = 'You Sent a Test Email';
$headers = 'From: info@THEDOMAIN.com' . "\r\n" .
           'Reply-To: info@THEDOMAIN.com' . "\r\n" .
           'X-Mailer: PHP/' . phpversion();
return mail($to, $subject, $email, $headers);
?>

这是我得到的错误:

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

pipe to |/home/MYACCOUNT/public_html/THEDOMAIN.com/pipe/send-test.php
generated by test@THEDOMAIN.com
local delivery failed

The following text was generated during the delivery attempt:

------ pipe to |/home/MYACCOUNT/public_html/THEDOMAIN.com/pipe/send-test.php
generated by test@THEDOMAIN.com ------

Could not exec '/home/MYACCOUNT/public_html/THEDOMAIN.com/pipe/send-test.php'

Action: failed
Final-Recipient: rfc822;|/home/MYACCOUNT/public_html/THEDOMAIN.com/pipe/send-test.php
Status: 5.0.0

我有其他应用程序能够处理通过管道发送的电子邮件到脚本,所以我不知道可能会发生什么。任何帮助将不胜感激。谢谢!

【问题讨论】:

  • 你找到答案了吗?
  • 不,甚至没有提示。奇怪的是,进入我帐户的奇怪电子邮件会触发管道功能。不知道如何

标签: php email cpanel


【解决方案1】:

检查文件权限(及其目录)是否设置为 0755 并且文件应该是 ascii 格式而不是二进制文件

在 php 标签和 hashbang 之前/之后没有空格/换行符

【讨论】:

    猜你喜欢
    • 2012-04-02
    • 2023-03-08
    • 2011-04-02
    • 1970-01-01
    • 2020-10-19
    • 1970-01-01
    • 2012-02-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多