How can I test email piping?

202 Views Asked by At

Apologies if this question is too broad, but I don't see how to troubleshoot this issue.

I have a forwarder set up in cPanel from an email address to |/home/cffcdbfd/script.php.

That script contains this code:

#! /usr/bin/php -q
<?php

$fd = fopen("php://stdin", "r");
$raw = "";
while ( !feof($fd) ) {
    $raw .= fread($fd, 1024);
}
fclose($fd);

mail("[email protected]", "This is a test message", $raw);
?>

(The script and its directory have permissions 0755.)

When I forward an email to the email address set up, I don't receive anything at [email protected]. This happens even if the code is just the mail function (with something static instead of $raw).

How can I test that the email is reaching the PHP script? I see a trace option in cPanel, but I'm not sure if it's relevant, or how to use it.

Update

I'm not sure about #! /usr/bin/php -q. I copied this from an online code snippet but I can't find any of these folders in my structure.

0

There are 0 best solutions below