我正在开发一个应用程序,该应用程序需要将电子邮件发送到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 = '[email protected]';
$subject = 'You Sent a Test Email';
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\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 [email protected]
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 [email protected] ------
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
我还有其他能够处理通过管道将电子邮件发送到脚本的应用程序,所以我对可能发生的事情不知所措。任何帮助将不胜感激。谢谢!
检查文件权限(及其目录)设置为0755,并且文件应为ascii格式,而不是二进制文件
在php标签和hashbang之前/之后没有空格/换行符>>