need help in mail parsing - data from php pipe


#1

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);
[/php]

Following is my test email data

[code]From myemail Tue Mar 20 02:30:01 2012
Received: from mail-yx0-f176.google.com ([209.85.213.176])
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;
d=gmail.com; s=20120113;
h=mime-version:date:message-id:subject:from:to:content-type;
bh=3TfodJhE6vcmh3A7tmfsi3FUWz9rLhzVBL+XIJUVLbI=;
b=mgjS3ifnmrxKvL6O0pvmX3W5P+4pvorLTmm1txKm0cWRwq4xYNUyNPJobGbEWPB48j
BQQtDjpVuvTexlh8Mz8/nFWhjJlBb8wQmduMhwPgJfiIYdBFsyEcD3gfrt+GLqGnssNb
kJLGO68tQb/Cw8AQ7qmsZYwJgQ1lMmJwRpwzf4B8JVVRxbeNX6zpe+nTRpJ6r5Xn4LBW
QDj2F1tkR7hpDtD+QboGcWwKyPYzDfHuJObunovt9leW7SItuDAGNZDHJl7fefoqCdSb
4nNfUtiVPr/6q4TJ6kBgispkzVkJQqCGJqoES7sLHm4hdicUy52DpIHHWsiO5y+5+8RU
MU9Q==
MIME-Version: 1.0
Received: by 10.236.156.233 with SMTP id m69mr14905976yhk.128.1332228601074;
Tue, 20 Mar 2012 00:30:01 -0700 (PDT)
Received: by 10.100.32.12 with HTTP; Tue, 20 Mar 2012 00:30:01 -0700 (PDT)
Date: Tue, 20 Mar 2012 13:00:01 +0530
Message-ID: CACY2Cvio11GvwAkQCpMjcGNDNsW8vmRCGSU0k0uWC2FYgac2kA@mail.gmail.com
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 “corp.rivalhost.com”, 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
(dotcommakers[at]gmail.com)
-0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low
trust
[209.85.213.176 listed in list.dnswl.org]
-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

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

test

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

test

–20cf303f634686d2cf04bba7a450–[/code]

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


#2

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…