From: Mike Campbell Date: 2003-01-27T11:32:16+09:00 Subject: Re: common regular expressions > > To be strictly pedantic, I don't think there is such a thing. > > Yes, there is actually. Email is a strict protocol, just like FTP and > others. However, there's so much flexibility in valid email addresses > that you probably want to stick to common email addresses. As another person noted, I wasn't saying you couldn't check for RFC-822 compliance, but rather that you can't, via a regex, determine if a mail address is valid; i.e., it'll get there. Here's the perl faq to which I was referring. this is a shortened version, which is a shame, as the one I recall from years gone by gave examples using %'s which could (IIRC) be legally parsed in more than 1 way, either, both, or neither being "valid". That may have been pre RFC-822 though, to be fair. ============= How do I check a valid email address? You can't. Remember that without sending mail to the address and seeing whether it bounces (and even then you face the halting problem), you cannot determine whether an email address is valid. Even if you apply the email header standard, you can have problems, because there are deliverable addresses that aren't RFC-822 (the mail header standard) compliant, and addresses that aren't deliverable which are. Many are tempted to try to eliminate many frequently-invalid email addresses with a simple regex, such as /^[\w.-]+\@([\w.-]\.)+\w+$/. However, this also throws out many valid ones, and says nothing about potential deliverability, so is not suggested. Instead, see the ${CPAN}/authors/Tom_Christiansen/scripts/ckaddr.gz program, which actually checks against the full RFC spec (well, modulo nested comments), looks for addresses you may not wish to accept email to (say, Bill Clinton or your postmaster), and then makes sure that the hostname given can be looked up in DNS. It's not fast, but it works. ========