Preg_Match to find valid email addresses in Mail Log
Posted: Sat Sep 04, 2010 11:20 am
Morning folks - been out of the devnetwork community for some time now, but glad to be back.
I've fallen a BIT out of touch with regular expressions and PHP in general, but am now back on the bandwagon. Need what I *hope* will be simple help to a problem I can't get my head around. I'm trying to find particular lines in a mail log text file. I've already got the file opened and read in to an array, but now need to find lines formatted in the following manner by valid email address:
I'd like to validate it by the email address in the to= field (if it's empty, I'd like to unset it's value in the array) and would like to find a way to validate the "dc57235831ca0d82c17d2fe292982ad2@randomname" which you'll note has no TLD.
Can someone help me out a bit?
Thanks for your time!
I've fallen a BIT out of touch with regular expressions and PHP in general, but am now back on the bandwagon. Need what I *hope* will be simple help to a problem I can't get my head around. I'm trying to find particular lines in a mail log text file. I've already got the file opened and read in to an array, but now need to find lines formatted in the following manner by valid email address:
Code: Select all
Sep 1 09:57:55 gpmail postfix/smtp[12622]: 093A116B10B: to=<randomtext82@hotmail.com>, relay=mx2.hotmail.com[65.54.188.110]:25, delay=0.85, delays=0.08/0.03/0.28/0.46, dsn=2.0.0, status=sent (250 <dc57235831ca0d82c17d2fe292982ad2@randomname> Queued mail for delivery)
Can someone help me out a bit?
Thanks for your time!