Fw: [PHP] Re: Regular expression
| From: | Syed Ghouse | Date: | Wed, 30 Jun 2004 11:15:02 +0000 |
| Subject: | Fw: [PHP] Re: Regular expression | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-189287@lists.php.net to get a copy of this message | ||
----- Original Message -----
From: "Syed Ghouse" <syed@jinis.com>
To: <redeye@erisx.de>
Sent: Wednesday, June 30, 2004 PM 04:43
Subject: Re: [PHP] Re: Regular expression
> Thanks Aiden for ur help
>
> i used ur code and i got
>
> name as Red Wingate<redeye@erisx.de
> and no email.
>
> So pls correct the code and send me such that i get name and email
> separately.
>
> Regards
> syed
>
> ----- Original Message -----
> From: "Red Wingate" <redeye@erisx.de>
> To: <php-general@lists.php.net>
> Sent: Wednesday, June 30, 2004 PM 04:27
> Subject: [PHP] Re: Regular expression
>
>
> > If you still like to gather the information without using any tools:
> >
> > $email = explode( "\n" , $mailText );
> >
> > foreach ( $email AS $emailLine ) {
> > $emailLine = trim( $emailLine );
> >
> > if ( strtoupper ( substr( $emailLine , 0 , 4 ) ) == 'FROM' ) {
> > preg_match( '#^from\s*:\s*([^>]+)(<([^>]+)>)?#si' ,$emailLine
> ,$parts );
> > break ;
> > }
> > }
> >
> > $name = $parts[1] ;
> > $email = $parts[3] ;
> >
> > But you should consider the following:
> >
> > FROM: Red Wingate <redeye@erisx.de>
> > FROM: Red Wingate
> > FROM: redeye@erisx.de
> > .....
> >
> > Which makes working like this a pita.
> >
> > -- red
> >
> > > I suggest not using a regex.
> > >
> > > There are better tools for parsing an email, for example "formail".
> > >
> > > $email =
formail -x Return-Path;
> > >
> > > See google.com for more information
> > >
> > > Regards,
> > > Aidan
> > >
> > >
> > > "Syed Ghouse" <syed@jinis.com> wrote in message
> > > news:00d701c45e83$9a662a50$495aa8c0@jinis.com...
> > > Hi All
> > >
> > > will anyone give me a solution to get the name and email address of
> sender
> > > from the mail text below using regular expression.
> > >
> > > The result shud get
> > > name as syed ghouse
> > > and
> > > email as syed@jinis.com
> > >
> > > --- Mail text start ---
> > >
> > > Return-Path: <avijayanand@sdmimd.com>
> > > Delivered-To: syed@sdmimd.com
> > > Received: (qmail 25523 invoked by uid 508); 19 Jun 2004 06:23:25 -0000
> > > Received: from localhost (HELO 192.168.90.8) (127.0.0.1)
> > > by mail.jinis.com with SMTP; 19 Jun 2004 06:23:25 -0000
> > > Received: from 192.168.90.20 (proxying for 192.168.90.85)
> > > (SquirrelMail authenticated user vijayanand@sdmimd.com)
> > > by 192.168.90.8 with HTTP;
> > > Sat, 19 Jun 2004 11:53:25 +0530 (IST)
> > > Message-ID: <4875.192.168.90.20.1087626205.squirrel@192.168.90.8>
> > > Date: Sat, 19 Jun 2004 11:53:25 +0530 (IST)
> > > Subject: test
> > >
> > > From : 'syed ghouse' <syed@jinis.com>
> > >
> > > To: vijayanand@sdmimd.com
> > > Cc: syed@sdmimd.com,sss@sdmimd.com
> > > User-Agent: SquirrelMail/1.4.2
> > > MIME-Version: 1.0
> > > Content-Type: text/plain;charset=iso-8859-1
> > > Content-Transfer-Encoding: 8bit
> > > X-Priority: 3
> > > Importance: Normal
> > >
> > > test mail ignore
> > >
> > > --- Mail text end ---
> > >
> > >
> > > Regards
> > >
> > > Syed
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>