Jump to content

Recommended Posts

Posted

Hello.

I've recently installed a PHP script, which works fine, to be executed when an e-mail comes.

Unfortunatelly when I send an e-mail to the address that was forwarded to the script, I get this error:

 

This message was created automatically by mail delivery software.

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

  pipe to |/home/fpetit/Tpersonal.php
    generated by federico@fpetit.heliohost.org

The following text was generated during the delivery attempt:

------ pipe to |/home/fpetit/Tpersonal.php
       generated by federico@fpetit.heliohost.org ------

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-zts-20060613/ixed.5.2.lin' - /usr/local/lib/php/extensions/no-debug-zts-20060613/ixed.5.2.lin: undefined symbol: executor_globals in Unknown on line 0
Error in argument 1, char 3: option not found 
Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>]
       php <file> [args...]
  -a               Run interactively
  -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>.

 

The script to be executed is:

 

#!/usr/bin/php -q
<?php
// read from stdin
$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(trim($lines[$i])=="") {
        // empty line, header section has ended
        $splittingheaders = false;
    }
    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";
    }
}
// $from1=strpos($from,'<')+1;
// $from2=strpos($from,'>',$from1);
// $from3=substr($from,$from1,$from2-$from1);
//Only for WLM
if (strpos(strtolower($from),'alert@mobile.live.com')!==false) {
    $message2=strpos($message,' ');
    $msncontact=substr($message,0,$message2);
    $cntpos=strpos($message,'):')+2;
        if (strpos(strtolower($msncontact),'[hotmail]')!==false) {
            $from='';
        } else {
            $message=$msncontact.substr($message,$cntpos);
            $from='WLM Alert';
        }
}
//Only for Y! Alert
if (strpos(strtolower($from),'y-alerts@reply.yahoo.com')!==false) {
    $from='Y!Alert';
}
// Insertamos PHPMailer
$subject='Hola';
$message='Este es el mensaje. Debe llegar a tu cuenta de Yahoo!';
$to      = 'federicopetit@yahoo.com.ar';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@personal.com.ar' . "\r\n" .
    'Reply-To: webmaster@personal.com.ar' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
return;
?>

 

As you can see I also included the hashbag at the beginning of the code. The script has 755 permission to be executed.

 

 

Thanks for your help

 

 

Posted

How much can you comment out before PHP throws the error? It seems the PHP is searching for an extension that we don't provide.

Posted
How much can you comment out before PHP throws the error? It seems the PHP is searching for an extension that we don't provide.

 

 

Well, the PHP is quite simple. It executes fine in your server. The problem comes when is executed by the piping method.

 

Posted

How do you know if it executes when you can't access it through the web in order to execute it? You've put the file in a directory inaccessible to Apache.

Posted
How do you know if it executes when you can't access it through the web in order to execute it? You've put the file in a directory inaccessible to Apache.

 

:) I executed in the WWW directory, the I moved it to the root. That's not the point.

Posted

I fear it might be. Try placing it back into the public_html directory and then pointing your pipe towards it there. If that doesn't work, place it in the public_html/cgi-bin directory and let me know if that works.

Posted
I fear it might be. Try placing it back into the public_html directory and then pointing your pipe towards it there. If that doesn't work, place it in the public_html/cgi-bin directory and let me know if that works.

 

 

Well, I don't know what happened, but all of a sudden it started working!. It seems there was huge delay with your SMTP server.

 

I also noticed that I can use PHPMailer, which is good for my application.

 

Anyway, I still receiving the bouncing e-mails.

The files are in the HOME directory.

Posted

The bouncing emails are automatically replied to the sender. I suggest you add a bogus reply-to header.

 

but all of a sudden it started working!
I recompiled Apache/PHP yesterday - that's probably what did it.
Posted
The bouncing emails are automatically replied to the sender. I suggest you add a bogus reply-to header.

 

but all of a sudden it started working!
I recompiled Apache/PHP yesterday - that's probably what did it.

 

 

Well :rolleyes: Thanks!

 

I don't know what a bogus reply is.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...