need help in mail parsing - data from php pipe


I am creating a script and I need PHP pipe working

I am using this pipe code

[php]#!/usr/bin/php -q

<?php // read from stdin $fd = fopen("php://stdin", "r"); $email = ""; while (!feof($fd)) { $email .= fread($fd, 1024); } fclose($fd); ?>[/php]

I want to send retrieved result to mail()

[php]$to = ‘toemail’;
$subject = ‘Pipe test’;
$headers = ‘From: fromemail’ . “\r\n” .
‘Reply-To: fromemail’ . “\r\n” .
‘X-Mailer: PHP/’ . phpversion();
mail($to, $subject, $message, $headers);

Following is my test email data

[code]From myemail Tue Mar 20 02:30:01 2012
Received: from ([])
by sendemailhost with esmtps (TLSv1:RC4-SHA:128)
(Exim 4.69)
(envelope-from <myemail>)
id 1S9tW5-0007sd-4U
for senderemail; Tue, 20 Mar 2012 02:30:01 -0500
Received: by yenq4 with SMTP id q4so7759629yen.35
for <senderemail>; Tue, 20 Mar 2012 00:30:01 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;; s=20120113;
MIME-Version: 1.0
Received: by with SMTP id m69mr14905976yhk.128.1332228601074;
Tue, 20 Mar 2012 00:30:01 -0700 (PDT)
Received: by with HTTP; Tue, 20 Mar 2012 00:30:01 -0700 (PDT)
Date: Tue, 20 Mar 2012 13:00:01 +0530
Subject: test
From: me <myemail>
To: sales <senderemail>
Content-Type: multipart/alternative; boundary=20cf303f634686d2cf04bba7a450
X-Spam-Status: No, score=-2.4
X-Spam-Score: -23
X-Spam-Bar: –
X-Ham-Report: Spam detection software, running on the system “”, has
identified this incoming email as possible spam. The original message
has been attached to this so you can view it (if it isn’t spam) or label
similar future email. If you have any questions, see
the administrator of that system for details.
Content preview: test test […]
Content analysis details: (-2.4 points, 5.0 required)
pts rule name description
---- ---------------------- --------------------------------------------------
0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider
-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at, low
[ listed in]
-0.0 SPF_PASS SPF: sender matches SPF record
-1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1%
[score: 0.0000]
0.0 HTML_MESSAGE BODY: HTML included in message
0.2 AWL AWL: From: address is in the auto white-list
X-Spam-Flag: NO

Content-Type: text/plain; charset=UTF-8


Content-Type: text/html; charset=UTF-8



Thing is that when I get data in pipe… its full of junk/headers etc… I need pure content like body text, from email and subject…

How can I achieve this? Trust me I have searched Goolge for couple of days and I am almost mad… Really cant find the solution…

Please help


Well, the headers and other "junk’ are there for a reason. They are tracking tools for servers and the government. So, if you do not want to “forward” them, you would have to strip out what you want. That is easy enough with string functions. I would start with the “X-” headers… Good luck…