943,675 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 8375
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Sep 20th, 2006
0

Email piping to script problem

Expand Post »
Hi everyone,

I have set the email piping to script in cpanel. Also in script i send a acknowledge mail to me to confirm whether the script works or not. But the script works fine and i have received the mail to my inbox. I got one more mail which indicates mail delivery system error. can anyone have solution for this. I really thanku very much if u give solution for this.

The error looks like given below


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/xxxx/public_html/xxxx/mail.php
generated by xxxxx.mydomain.com

The following text was generated during the delivery attempt:

------ pipe to |/home/xxxx/public_html/xxxxx/mail.php
generated by xxx@mydomain.com ------

PHP Warning: Zend Optimizer does not support this version of PHP - please upgrade to the latest version of Zend Optimizer in Unknown on line 0

------ This is a copy of the message, including all the headers. ------

Return-path: <xxxx@mydomain.com>
Received: from [61.247.255.207] (helo=system28)
by blackbox.networkoneit.com with smtp (Exim 4.52)
id 1GQ7pr-0008IO-HO
for xxx@mydomain.com; Wed, 20 Sep 2006 12:34:20 -0700
Message-ID: <015801c6dcea$bbaaaaa0$4e01a8c0@system28>
From: "Mahendran" <xxx@mydomain.com>
To: <xxx@mydomain.com>
Subject: hi
Date: Thu, 21 Sep 2006 00:56:51 +0530
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_0155_01C6DD18.D3350A20"
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000

This is a multi-part message in MIME format.

------=_NextPart_000_0155_01C6DD18.D3350A20
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable




------=_NextPart_000_0155_01C6DD18.D3350A20
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_0155_01C6DD18.D3350A20--
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
mahe4us is offline Offline
54 posts
since Sep 2006
Sep 20th, 2006
0

Re: Email piping to script problem

Hi mahe4us,

When you pipe to the php script, you must make sure that the php script does not send any output.

It looks like your php script is has the output:
PHP Warning: Zend Optimizer does not support this version of PHP - please upgrade to the latest version of Zend Optimizer in Unknown on line 0
Even output from an error like above will cause the Mail Delivery Software - Mail Transport Agent (MTA) - to assume that the returned output from the script is an error message, which it will report back to the sender of the email.

What you can do is try to suppress errors in your php using the ini_set() function or error_reporting() funciton.

You can also use output buffering. set ob_start() at the beginning of your script, then ob_get_contents() at the end of your script to retrieve all output (including errors). Then you can send this output somewhere else, like to an email for debugging, or write it to a text file. Then you can remove all the output the script produced using ob_clean();

eg:
[PHP]<?php

// start output buffering
ob_start();

// get your email from stdin
$email = file_get_contents('php://stdin');

// do stuff

// log your email to logfile
$fp = fopen('log.txt', 'r');
if ($fp) {
fwrite($fp, $email, strlen($email));
fclose();
}

// or send you a copy
mail('myemail@mydomain.com', 'email received', $email, 'from: phpscript@mydomain.com');

// clean the output
ob_end_flush();

?>[/PHP]

Another way to suppress headers is using the -q option or redirect the output to /dev/null which will suppress the output:

| php -q /home/xxxx/public_html/xxxx/mail.php

or


| php -q /home/xxxx/public_html/xxxx/mail.php >> /dev/null
Moderator
Reputation Points: 457
Solved Threads: 101
Nearly a Posting Virtuoso
digital-ether is offline Offline
1,250 posts
since Sep 2005
Sep 20th, 2006
0

Re: Email piping to script problem

HI digital-ether,

First I would give my thanks to you for your nice reply once again to me. I applied the error suppress methods in php script. But still the mail delivery failed message come with me. But the script works.
Also I used the -q in script path in cpanel

| php -q /home/xxxx/public_html/xxxx/mail.php >> /dev/null

This method also not stop the mail delivery message.

Iam using #!/usr/bin/php -q at start of the php script. Please suggest your ideas if any error i have made.
Thanks
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
mahe4us is offline Offline
54 posts
since Sep 2006
Sep 20th, 2006
0

Re: Email piping to script problem

Only advice I can give is to try differnt setups.

Try a setup like:

| php -q /home/xxxx/public_html/xxxx/mail.php
remove the: #!/usr/bin/php -q
And use phps ouput buffering. Start with ob_start() and end your script with ob_end_clean();

Is your php running as a CGI or Apache module?
Moderator
Reputation Points: 457
Solved Threads: 101
Nearly a Posting Virtuoso
digital-ether is offline Offline
1,250 posts
since Sep 2005
Sep 20th, 2006
0

Re: Email piping to script problem

Hi Digita-ether,

I removed the #!/usr/bin/php -q in scrip. Also I uses the ob_start() and ob_end_clean(). For your reference I Paste my script below.

-----------------------------------
<?php
// start output buffering
ob_start();
// 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 ($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('mydomain@mydomain.com', 'email received', $email, 'from: Server');
// clean the output
ob_end_clean();
?>
----------------------
I think my server is running php through apache module. But iam not sure because i dont know how to find it.
Thanks..
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
mahe4us is offline Offline
54 posts
since Sep 2006
Sep 21st, 2006
0

Re: Email piping to script problem

Take a look at your phpinfo().
(create a file with <?php phpinfo(); ?> and view it online).

Then look for "Server API" right at the top. It should be "CGI" or "Apache" etc.
Moderator
Reputation Points: 457
Solved Threads: 101
Nearly a Posting Virtuoso
digital-ether is offline Offline
1,250 posts
since Sep 2005
Sep 21st, 2006
0

Re: Email piping to script problem

Hi Digital-ether,

I have seen Server API by using phpinfo() in my server. I looked the page online and it denoted as "apache".
Thanku..
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
mahe4us is offline Offline
54 posts
since Sep 2006
Sep 21st, 2006
0

Re: Email piping to script problem

Click to Expand / Collapse  Quote originally posted by mahe4us ...
Hi Digital-ether,

I have seen Server API by using phpinfo() in my server. I looked the page online and it denoted as "apache".
Thanku..
Looks like you're running php as an apache module.
Is your php script actualy being run? If it is you should get the email from:

[PHP]mail('mydomain@mydomain.com', 'email received', $email, 'from: Server');[/PHP]

Also, has the mailer-daemon notification email changed since you removed the shebang line or added the php buffering functions?
could you post the email from the mailer-daemon (failure notification) if its changed..
Moderator
Reputation Points: 457
Solved Threads: 101
Nearly a Posting Virtuoso
digital-ether is offline Offline
1,250 posts
since Sep 2005
Sep 22nd, 2006
0

Re: Email piping to script problem

Hi Digital-ether,

I have tried all the options. I have used the script with and without shebang code and buffering actions. All the way the mailer daemon notification arrived. Iam sure that the script works fine. But the bounce mail also comes to me with an error indicating.
PHP Warning: Zend Optimizer does not support this version of PHP - please upgrade to the latest version of Zend Optimizer in Unknown on line 0
Iam also tried very much but still Iam not get any solution for this...
Thanku
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
mahe4us is offline Offline
54 posts
since Sep 2006
Sep 22nd, 2006
0

Re: Email piping to script problem

Click to Expand / Collapse  Quote originally posted by mahe4us ...
Hi Digital-ether,

I have tried all the options. I have used the script with and without shebang code and buffering actions. All the way the mailer daemon notification arrived. Iam sure that the script works fine. But the bounce mail also comes to me with an error indicating.
PHP Warning: Zend Optimizer does not support this version of PHP - please upgrade to the latest version of Zend Optimizer in Unknown on line 0
Iam also tried very much but still Iam not get any solution for this...
Thanku
Looks like your only fix for this is to upgrade the Zend Optimizer to support the php version you're using.

This error is being generated on line 0, which means that the output is sent before buffering starts with ob_start();
I did some tests and it doesn't seem to matter what you put in the email pipe in Cpanel.
If you place the -q option or even redirect output to /dev/null, it still will send a mailer-daemon notification back to the sender if the script creates output. This may be server dependant, MTA dependant? I dont know..

If you're on a rented server you'll have to ask your hosting to upgrade Zend Optimizer.

If you can't upgrade Zend Optimizer for some reason, you can turn off error reporting in php.ini.
Using the function error_reporting(0); (at runtime) in side your php code won't work (just like ob_start()) because the error is generated before your php is even run.

Otherwise you may have to pipe the email to a perl script or something else that doesn't create ouput.
Moderator
Reputation Points: 457
Solved Threads: 101
Nearly a Posting Virtuoso
digital-ether is offline Offline
1,250 posts
since Sep 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Problem with php / sql UPDATE returns error !!
Next Thread in PHP Forum Timeline: update sql table with php





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC