Hello all!
I'm trying to pipe email to a PHP script (I've read the thread at the following link http://forums.cpanel.net/showthread.php?t=50985).
In the beginning, I wasn't even getting an error message. NOTHING happened. I tried commenting out the function (and the call to it) and ran it at the command line. I got an error message that the command "myscript.php" could not be found. So I entered "/usr/local/bin/php myscript.php" (I had cd'd to the file's location) and got NO error message. STILL no email message. So I go back to CPanel and enter the full path to PHP after the pipe and the script name (with the full path). I eventually DO get a return email message telling me that the recipient could not be verified (this is WITH the function and the call to it uncommented).
PHP's mail function DOES work for me--my contact page uses it and I just recieved a msg via that page today.
Permissions for the file are set at 777 currently.
Server info (copy/pasted from cpanel):
I'm trying to pipe email to a PHP script (I've read the thread at the following link http://forums.cpanel.net/showthread.php?t=50985).
In the beginning, I wasn't even getting an error message. NOTHING happened. I tried commenting out the function (and the call to it) and ran it at the command line. I got an error message that the command "myscript.php" could not be found. So I entered "/usr/local/bin/php myscript.php" (I had cd'd to the file's location) and got NO error message. STILL no email message. So I go back to CPanel and enter the full path to PHP after the pipe and the script name (with the full path). I eventually DO get a return email message telling me that the recipient could not be verified (this is WITH the function and the call to it uncommented).
PHP's mail function DOES work for me--my contact page uses it and I just recieved a msg via that page today.
Permissions for the file are set at 777 currently.
Server info (copy/pasted from cpanel):
Operating system Linux
Service Status Click to View
Kernel version 2.4.21-47.0.1.ELsmp
Machine Type i686
Apache version 1.3.37 (Unix)
PHP version 5.1.6
cPanel Build 10.9.0-CURRENT 56
Theme cPanel X v2.6.0
cPanel Pro 1.0 (RC36)
PHP:
<?php
#!/usr/local/bin -q
$msg = "You Said: \r\n";
function mailRead($iKlimit = ""){
// Purpose:
// Reads piped mail from STDIN
//
// Arguements:
// $iKlimit (integer, ptional): specifies after how many kilobytes reading of mail should stop
// Defaults to 1024k if no value is specified
// A value of -1 will cause reading to continue until the entire message has been read
//
// Return value:
// A string containing the entire email, headers, body and all.
// Variable perparation
// Set default limit of 1024k if no limit has been specified
if ($iKlimit == "") {
$iKlimit = 1024;
}
// Error strings
$sErrorSTDINFail = "Error - failed to read mail from STDIN!";
// Attempt to connect to STDIN
$fp = fopen("php://stdin", "r");
// Failed to connect to STDIN? (shouldn't really happen)
if (!$fp) {
echo $sErrorSTDINFail;
exit();
}
// Create empty string for storing message
$sEmail = "";
// Read message up until limit (if any)
if ($iKlimit == -1) {
while (!feof($fp)) {
$sEmail .= fread($fp, 1024);
}
} else {
while (!feof($fp) && $i_limit < $iKlimit) {
$sEmail .= fread($fp, 1024);
$i_limit++;
}
}
// Close connection to STDIN
fclose($fp);
// Return message
return $sEmail;
}
$msg2 = mailRead();
$headers = "From: Pipe Test<[email protected]>\r\n";
mail("[email protected]", "PHP Pipe Test", $msg, $headers);
?>