Ask your hosting what the path to the PHP interpreter is. It probably isn't at /usr/bin/php
Like I mentioned before, it is better to use:
| /usr/bin/php /home/user/public_html/pipe/email_pipe.php >> /home/user/pipe/pipe_error.txt 2>&1
That way you dont need the shebang, and you don't need to make the file /home/user/public_html/pipe/email_pipe.php executable.
Just make sure the path to the interpreter is correct.
You can also test this by running the command from within PHP.
Get the text for a sample email message.
eg:
$email = '
To: user@example.com
From: "example.com" <test@example.com>
Subject: This is a test email
Message-ID: <blablalba@example.com>
X-Priority: 3
X-Mailer: PHPMailer [version 1.72]
MIME-Version: 1.0
Content-Type: text/plain
Hi Jim,
Example text, example text etc.
';
You can then feed this to your php script in the same way the MTA would. I've written a function to do this:
/**
* Start a child process, and write input to it's STDIN
* @return Array An array with the format array(stdout=>'', stderr=>'', return=>'').
*
* stdout - Standard Output from child process
* stderr - Standard Error from child process
* return - Return code of child process
*
* @param $cmd String
* @param $input String[optional]
*/
function childProcess($cmd, $input = '') {
$pipe_descriptions = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("pipe", "w") // stderr is a pipe that the child …