Forum Moderators: coopster

Message Too Old, No Replies

Trying to pipe email to php script

         

erikcw

6:07 pm on Aug 24, 2005 (gmt 0)

10+ Year Member



Hi all,

I am trying to setup an email pipe script.

I found this example at [evolt.org...]


#!/usr/bin/php
<?php
// script chmoded to 755
// alias: test@domain.com: ¦/home/erik/404pipe.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 ($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;
}
}

?>

The problem I am running into is that exim keeps bouncing messages back


Mail Delivery System
<Mailer-Daemon@host.net>
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/erik/404pipe.php
generated by test@domain.com

The following text was generated during the delivery attempt:

------ pipe to ¦/home/erik/404pipe.php
generated by test@domain.com ------

Content-type: text/html
X-Powered-By: PHP/4.3.10

Mail headers yada yada...

The mail is acctually processed by the script just fine (I have it setup to mail() some of the content back to me for testing purposes.

Any ideas on how I can get rid of this error?

Thanks!

jatar_k

4:34 pm on Aug 26, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I don't really get what the error is telling you.

It looks like the mail program is having issues though not php per se. Any more info that might help narrow it down?

erikcw

7:07 pm on Aug 28, 2005 (gmt 0)

10+ Year Member



I have other pipe scripts setup that don't create bounce errors.

Here is a full bounce:


Delivered-To: #*$!xxxxxxx@gmail.com
Received: by 10.54.35.65 with SMTP id i65cs17895wri;
Sat, 27 Aug 2005 08:01:45 -0700 (PDT)
Received: by 10.54.158.5 with SMTP id g5mr1190119wre;
Sat, 27 Aug 2005 08:01:45 -0700 (PDT)
Return-Path: <>
Received: from athena.ixxxxx.net (vps.xxxxx.net [207.58.xxxx])
by mx.gmail.com with ESMTP id 15si1644046wrl.2005.08.27.08.01.43;
Sat, 27 Aug 2005 08:01:45 -0700 (PDT)
Received-SPF: pass (gmail.com: domain of designates 207.58.132.148 as permitted sender)
Received: from mailnull by athena.xxxxxxx.net with local (Exim 4.50)
id 1E92Bj-00039y-1W
for nobody@athena.xxxxx.net; Sat, 27 Aug 2005 11:01:43 -0400
X-Failed-Recipients: test@exxxxxxm.com
Auto-Submitted: auto-generated
From: Mail Delivery System <Mailer-Daemon@athena.xxxxs.net>
To: nobody@athena.xxxxxx.net
Subject: Mail delivery failed: returning message to sender
Message-Id: <E1E92Bj-00039y-1W@athena.xxxxx.net>
Date: Sat, 27 Aug 2005 11:01:43 -0400
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - athena.xxxxxx.net
X-AntiAbuse: Original Domain - athena.xxxxxxxx.net
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain -
X-Source:
X-Source-Args:
X-Source-Dir:

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 ¦/usr/local/bin/php -c /usr/local/lib -q -f /home/erik/404pipe.php
generated by test@xxxxxxxx.com
(ultimately generated from 404alert@xxxxxxxxxx.com)

The following text was generated during the delivery attempt:

------ pipe to ¦/usr/local/bin/php -c /usr/local/lib -q -f /home/erik/404pipe.php
generated by test@xxxxxxxxx.com
(ultimately generated from 404alert@xxxxx.com) ------

Error in query: INSERT INTO `log` (`user`, `request`, `ip`, `agent`, `referer`, `rdto`, `source`, `timestamp`) VALUES ('User', 'http://xxxx.xxxxxxxxx.com/favicon.ico', '24.149.153.86', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050223 Firefox/1.0.1', ' [207.58.000.000:2087...] '', 'email', NOW()). Duplicate entry '127' for key 1
------ This is a copy of the message, including all the headers. ------

Return-path: <nobody@athena.xxxx.net>
Received: from erik by athena.xxxxx.net with local-bsmtp (Exim 4.50)
id 1E92Bi-00037a-87
for 404alert@xxxxxxxxxx.com; Sat, 27 Aug 2005 11:01:42 -0400
Received: from nobody by athena.xxxxx.net with local (Exim 4.50)
id 1E92Bh-00033R-Sq
for 404alert@xxxxxxxxxx.com; Sat, 27 Aug 2005 11:01:42 -0400
To: 404alert@erixxxxxxxxx.com
Subject: 404 error at 100-xxxxxxx.com
From: alert404@100-xxxxxxxxxxxxx.com
Message-Id: <E1E92Bh-00033R-Sq@athena.xxxx.net>
Date: Sat, 27 Aug 2005 11:01:41 -0400
X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on athena.ikesys.net
X-Spam-Status: No, score=-5.7 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,
NORMAL_HTTP_TO_IP,NO_REAL_NAME,WEIRD_PORT autolearn=ham version=3.0.4
X-Spam-Level:

Date: 08-27-2005[11:01:41]
User request for: [100-xxxxxxxxxxxxx.com...] was not found!
IP address: 24.149.153.00
Browser: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050223 Firefox/1.0.1
Referred by: [207.58.000.000:2087...]

Error Code: 404

jatar_k

4:52 pm on Aug 29, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



and the accounts that it is trying to send to actually exist?

this just looks weird to me
pipe to ¦/usr/local/bin/php -c /usr/local/lib -q -f /home/erik/404pipe.php

404pipe? is that where it is trying to send it or where it is ending up?

erikcw

6:14 pm on Aug 29, 2005 (gmt 0)

10+ Year Member



404pipe.php is the final destination. (the contents of the script are included in my first post).

The script is being executed by the pipe correctly. But this bounce keeps happening. So it appears that the script is setup correctly in that it is proccessing correcly on the php end. My thought is that the php script is either returning something in standard output or something in exim isn't configured correctly...

Ant thoughts?
Erik