Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

RegEx email Help Needed

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

RegEx email Help Needed

Postby jnuneznyc » Sat May 24, 2003 9:46 pm

I am attempting to write a php script the will read the email box of my newsletter's account for any unsubscribe and rejected. I currently do this by hand but as the list grows, I want to automate it.

I have the Regular Expression to extract the email address from the email header.

eregi( "From\: ([^\n\"]+)", $qryHeaders, $email);
This works if the From line is:
From: johndoe@domain.com
but it doesn't work for:
From: John Doe johndoe@domain.com
or
From: John Doe <johndoe@domain.com>

Any suggestions?
jnuneznyc
New php-forum User
New php-forum User
 
Posts: 3
Joined: Sat May 24, 2003 9:38 pm

Postby Joan Garnet » Sun May 25, 2003 9:09 am

just split it into an array with explode and do your eregi with the index you want.

an example:

Code: Select all
$my_string = "From: John Doe johndoe@domain.com";
$my_split = explode ( " " , $my_string );
$useful_part = $my_split [3];


bye!
User avatar
Joan Garnet
Moderator
Moderator
 
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars

Postby jnuneznyc » Tue May 27, 2003 7:39 pm

Hey Joan,

The string is an email header which contains all the transmission information of a standard email.

I felt that one eregi is faster (CPU Cycles) than splitting the string by \n {newline} and then checking for the from: line and then splitting the string by " " and then getting the array value with the @ so I can unsub it from the list.

I just need to really learn Regular Expression but I don't have the time right now to right News Headlines... let alone the entire story...LOL
jnuneznyc
New php-forum User
New php-forum User
 
Posts: 3
Joined: Sat May 24, 2003 9:38 pm

Postby mike » Thu May 29, 2003 2:16 pm

You can also use: strstr()

eg: strstr($email, $qryHeaders);
User avatar
mike
New php-forum User
New php-forum User
 
Posts: 73
Joined: Sun May 04, 2003 4:26 am
Location: Athens


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot], Google Feedfetcher and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.