mail() blacklisted for email forward to pipe (but works in browser)

Status
Not open for further replies.

mcarroll

New Member
Messages
4
Reaction score
0
Points
0
Hi,

I'm having problems forwarding email to a pipe. The email is returned to the sender with the error message:

------ pipe to |/home/mcarroll/public_html/forwardMail.php
generated by mofo@mofo.x10hosting.com ------

ALERT - function within blacklist called: mail() (attacker 'REMOTE_ADDR not set', file '/home/mcarroll/public_html/forwardMail.php', line 53)
X-Powered-By: PHP/5.2.6
Content-type: text/html
However I do have intermediate level php enabled for my account and when I try emailing myself from a php script opened in my browser it works just fine

$send = mail($to, $subject, $body, $headers);
Is the mail forward script somehow not picking up that my account has permission to use mail() ?

The mail forward script is something I copied from these forums

Code:
#!/usr/bin/php
<?php
$fd = fopen("php://stdin", "r");
$email = "";

while (!feof($fd))
{
   $email .= fread($fd, 1024);
}
fclose($fd);

// handle email

$lines = explode("\n", $email);

// empty vars
$from = "";
$subject = "";
$headers = "";
$message = "";
$splittingheaders = true;

for ($i=0; $i < count($lines); $i++)
{
   if ($splittingheaders)
   {
      // this is a header
      $headers .= $lines[$i]."\n";
      // look out for special headers
      if (preg_match("/^Subject: (.*)/", $lines[$i], $matches))
      {
         $subject = $matches[1];
      }
      if (preg_match("/^From: (.*)/", $lines[$i], $matches))
      {
         $from = $matches[1];
      }
   }
   else
   {
      // not a header, but message
      $message .= $lines[$i]."\n";
   }

   if (trim($lines[$i])=="")
   {
      // empty line, header section has ended
      $splittingheaders = false;
   }

}

mail("myUserName@hotmail.com", $subject, $message, $headers);

?>
I also tried changing the first line of the script to "#!/usr/bin/php -q"


Any help would be greatly appreciated!
 

Christopher

Retired
Messages
14,659
Reaction score
8
Points
0
Moved to level two support
If I understand it correctly, it isn't able to get the user's IP so it blocks you from using the mail function.
 

Corey

I Break Things
Staff member
Messages
34,551
Reaction score
204
Points
63
Shebang needs to be /usr/bin/php-cron

-Corey
 
Status
Not open for further replies.
Top