2015-02-06 67 views
0

我正在寫一個php腳本來管理我的CPanel中的前進郵件。我在網上找到了這個劇本;我試圖解析電子郵件,然後發送回自己進行測試,但它而不是返回此錯誤:PHP電子郵件管道錯誤

The following text was generated during the delivery attempt: 

------ pipe to |/home1/<account>/pipe.php 
generated by [email protected] ------ 

Error in argument 1, char 3: option not found < 
Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>] 
php <file> [args...] 
-a Run interactively 
-b <address:port>|<port> Bind Path for external FASTCGI Server mode 
-C Do not chdir to the script's directory 
-c <path>|<file> Look for php.ini file in this directory 
-n No php.ini file will be used 
-d foo[=bar] Define INI entry foo with value 'bar' 
-e Generate extended information for debugger/profiler 
-f <file> Parse <file>. Implies `-q' 
-h This help 
-i PHP information 
-l Syntax check only (lint) 
-m Show compiled in modules 
-q Quiet-mode. Suppress HTTP Header output. 
-s Display colour syntax highlighted source. 
-v Version number 
-w Display source with stripped comments and whitespace. 
-z <file> Load Zend extension <file>. 
-T <count> Measure execution time of script repeated <count> times. 

------ This is a copy of the message, including all the headers. ------ 

的腳本如下:

#!/usr/bin/php -q 
<? 
$fd = fopen("php://stdin", "r"); 
$email = ""; 
while (!feof($fd)) { 
    $email .= fread($fd, 1024); 
} 
fclose($fd); 

//split the string into array of strings, each of the string represents a single line, received 
$lines = explode("\n", $email_content); 

// initialize variable which will assigned later on 
$from = ""; 
$subject = ""; 
$headers = ""; 
$message = ""; 
$is_header = true; 

//loop through each line 
for ($i = 0; $i < count($lines); $i++) { 
    if ($is_header) { 
     // hear information. instead of main message body, all other information are here. 
     $headers .= $lines[$i]."\n"; 

     // Split out the subject portion 
     if (preg_match("/^Subject: (.*)/", $lines[$i], $matches)) { 
      $subject = $matches[1]; 
     } 
     //Split out the sender information portion 
     if (preg_match("/^From: (.*)/", $lines[$i], $matches)) { 
      $from = $matches[1]; 
     } 
    } else { 
     // content/main message body information 
     $message .= $lines[$i]."\n"; 
    } 
    if (trim($lines[$i])=="") { 
     // empty line, header section has ended 
     $is_header = false; 
    } 
} 

mail("[email protected]", $subject, '"' . $message . . "\n\n\n" . $email . '"'); 

的PHP文件的權限是755 。

回答

0

你試圖改變你的第二行

<?php 

也確保有第一行沒有多餘的空格