[UPHPU] Email Scrubbing and Validation

Scott Morris scottmorris at suseblog.com
Wed May 7 17:04:15 MDT 2008


All,

I spent a large part of my day looking for two functions.  One to take 
all of the invalid characters out of an email address, and one to 
validate an email address.  The trick is that I wanted them to be as 
accurate as possible.  The username part of the address has different 
illegal characters than the domain part.  I needed something to act 
appropriately.  Secondly, I needed a function that would tell me whether 
an email address was valid taking the same principle into account.  I 
ended up with a solution for each that appears to be very solid.  In any 
case, with all of the tests that I put it through, these are the two 
solutions that performed better than the others.  I did not write the 
monstrous regex in the validator function.  For anyone who wants to 
scrub or validate email addresses, I offer this.  For anyone who can 
improve it, I'm all ears.  Have a good one, everyone.

Scott


More information about the UPHPU mailing list