簡體   English   中英

PHP電子郵件管道“無法執行”錯誤

[英]PHP Email Piping “can't exec” error

我正在開發一個應用程序,需要將電子郵件通過管道傳輸到 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

我有其他應用程序能夠處理通過管道發送到腳本的電子郵件,所以我對可能發生的事情一無所知。 任何幫助將不勝感激。 謝謝!

檢查文件權限(及其目錄)是否設置為 0755 並且文件應為 ascii 格式而不是二進制

在 php 標簽和 hashbang 之前/之后沒有空格/換行符

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM