in reply to Email Validation, Round 2

For my opinion, the e-mail regexp is most useful in a "yes we can do this" sort of way. For real world apps I'd use Email::Valid. It correctly validates an e-mail address, and does something this regex can't....verifing that the target domain exists.

/\/\averick
perl -l -e "eval pack('h*','072796e6470272f2c5f2c5166756279636b672');"

Replies are listed 'Best First'.
Re: Re: Email Validation, Round 2
by legLess (Hermit) on Aug 24, 2001 at 23:01 UTC
    You know that Email::Valid uses this same regex, right? It's a nice piece of Perl, but even the module's own POD says:
    Please note that there is no way to determine whether an address is deliverable without attempting delivery (for details, see perlfaq 9).
    Of course, as I said in my other comment, validity and deliverability are two different things, and sometimes you only need one.
    --
    man with no legs, inc.
      If you read the pod a little more carefully, you'll spot this:
      mxcheck ( <TRUE>|<FALSE> ) Specifies whether addresses passed to address() should be checked for a valid DNS entry. The default is false.
      and this:
      If an error is encountered, an exception is raised. This is really only possible when performing DNS queries. Trap any exceptions by wrapping the call in an eval block: eval { $addr = Email::Valid->address( -address => 'maurice@hevanet.com +', -mxcheck => 1 ); }; warn "an error was encountered: $@" if $@;
      I said that Email::Valid will "verify that the target domain exists", not that the email address is ultimately deliverable.

      /\/\averick
      perl -l -e "eval pack('h*','072796e6470272f2c5f2c5166756279636b672');"

        this is what i include in anything
        that needs email validation
        hope its of use
        notice the use of mxcheck!
        use Email::Valid; sub emailvalidate { my $evalid= Email::Valid->address( -address =>$_[0],-mxcheck => 1) ? ' +yes' : 'no'; return $evalid; }
        back in the day we didnt have no old school
        I agree, and I did read the POD carefully. My point was orthogonal to yours, not in opposition to it. (My unstated point was that verifiying the target domain, while a nice and clever feature, is not likely to be very helpful. With all the "typo-squatting" these days, it won't even catch most typos.)

        My last sentence was just an acknowledgement that people use Email::Valid for different purposes, and not all of these purposes necessitate deliverability checking.
        --
        man with no legs, inc.