[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details

pipe to php change email string and then foward to new email address

Asked by pro2server in Application Servers, Networking Protocols, Developer Tools

Greetings : I am in hosted unix server with EXIM mail transfer agent. I need to pipe in cpanel (11) a php script
which (has a hashbang similar to your url

http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_24822194.html

On any incoming message want to delete and/or change
the string   abcdef   below

 Want to pipe it in cpanel (11) to a php script:
delete and/or change the string on the below
message-body on the incoming email (to my server)
and then foward it to a desired email adress
say myname@otherdomain.com

The message-body of the incoming is :  


[19/10 01:34] [9990100053] [] [incoming] abdcdf
x:(1 of 1) from all of us
yd:Best wishes for the Holydays.

----

Your above url has something similar (I think) what i am looking for.
If your below script (from above url) does what I want to do
(or another script you may suggest)-

I do not know where new string and old string would go?
 (for example, where my new string call it   SOLVED  .


Also where in the script would go myname@otherdomain.com (pls see above)  
---

Your above url has the following script "

line item -

1:00      #!/usr/bin/php -q
2:00      <?php
3:00      // read from stdin
4:00      $fd = fopen("php://stdin", "r");
5:00      $email = "";
6:00      while (!feof($fd)) {
7:00          $email .= fread($fd, 1024);
8:00      }
9:00      fclose($fd);
10:00      // handle email
11:00      $lines = explode("\n", $email);
12:00      // empty vars
13:00      $from = "";
14:00      $subject = "";
15:00      $headers = "";
16:00      $message = "";
17:00      $splittingheaders = true;
18:00      for ($i=0; $i < count($lines); $i++) {
19:00          if ($splittingheaders) {
20:00              // this is a header
21:00              $headers .= $lines[$i]."\n";
22:00              // look out for special headers
23:00              if (preg_match("/^Subject: (.*)/", $lines[$i], $matches)) {
24:00:00                  $subject = $matches[1];
25:00:00              }
26:00:00              if (preg_match("/^From: (.*)/", $lines[$i], $matches)) {
27:00:00                  $from = $matches[1];
28:00:00              }
29:00:00          } else {
30:00:00              // not a header, but message
31:00:00              $message .= $lines[$i]."\n";
32:00:00          }
33:00:00          if (trim($lines[$i])=="") {
34:00:00              // empty line, header section has ended
35:00:00              $splittingheaders = false;
36:00:00          }
37:00:00      }
38:00:00      mail($from, "Re:" . $subject, "Message received.");
39:00:00      ?>




Thanks
1:
php
[+][-]10/26/09 04:41 AM, ID: 25661228Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81 - Hierarchy / EE_QW_3_20080625