【发布时间】: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
我有其他应用程序能够处理通过管道发送的电子邮件到脚本,所以我不知道可能会发生什么。任何帮助将不胜感激。谢谢!
【问题讨论】:
-
你找到答案了吗?
-
不,甚至没有提示。奇怪的是,进入我帐户的奇怪电子邮件会触发管道功能。不知道如何