Hi Simon and others,

Really happy to see something moving about isEmail

For you isHostname I suggest to check tld

available real tld are
    // TLD source http://data.iana.org/TLD/tlds-alpha-by-domain.txt
    $a_tlds = @file('tlds-alpha-by-domains.txt');
   
ok this impose local file ( which can be updated by cron jobs or admin )

And in my case I check the hostname with checkdnsrr to see if there one
record or more.
(I've a special case for windows os with a system call to dig and/or
nslookup)

But as always this impose network connection, but for the dns is took
only 2 to 4 seconds fi there's not a plenty of resolver inside the web
server.

Checking about the domain part (without the tld) wouldn't be easy,
because differents rules applies to each tld authority.
For example in Switzerland your domain should be 26 max length, but now
they accept IDN domain (think to müller ) and the domain max length is 64.
...


I'm not really agree with your asynchrone checking. Because how to says
to a anonymous user behind is browser that's the email he entered is
some kind of wrong.

Before the massive usage of greylisting, i've used a network method to
directly speak with the mailers founds in DNS. To see if I've a mail to
this user
would be accepted. And it works very nice ! And 100% email are true.

But I've no time to adapt it to greylisting error message.

Hope to see your work next release :-))
Happy new year.


Simon R Jones wrote:
> Hi there,
>
> I've been taking a brief look at Zend_Filter::isEmail over the Xmas hol to
> see if I can tackle it and have a suggested starting point, which I've
> copied below. 
>
> I was going to add this to the Issue Tracker, but I've had some problems
> accessing it this morning. This issue also seems to have been reported by
> Andris Paikens.
>
> The method below splits up the email address and uses the existing test
> Zend_Filter::isHostname to match the domain (which I think may need checking
> against the RFC). 
>
> The local part of the email is then matched first against dot-atom
> characters, which should cover 99% of all email addresses. The RFC also
> states emails can also be in the quoted form or an obsolete form. Previous
> email checkers I've reviewed seem to create regexes to match all 3 possible
> formats, but since 99% of all email addresses will be covered by the
> standard dot-atom I think it's better to first check for that. Which I also
> think will be faster.
>
> You'll see from the code below if the dot-atom characters aren't matched
> further checks could be made against the quoted format and obselete ones -
> though I haven't done those yet. The current code below will work for most
> common emails, so with some testing could arguably be implemented now to
> provide some email testing functionality.
>
> --------------------------
>
>
> public static function isEmail($value)
> {
>     // Split email address up
>     if (preg_match('/^([EMAIL PROTECTED])@([EMAIL PROTECTED])$/', $value, 
> $matches)) {
>         $localPart = $matches[1];
>         $domain        = $matches[2];
>
>         // Match domain part (allow hostnames and IP addresses)
>         $domainResult = self::isHostname($domain, 3);
>
>         // First try to match the local part on dot-atom characters
>         // since this is the most common format
>         $localResult = false;
>
>         // Dot-atom characters
>         // ALPHA / DIGIT / and "!", "#", "$", "%", "&", "'", "*", "+",
>         // "-", "/", "=", "?", "^", "_", "`", "{", "|", "}", "~", "."
>         // Dot character "." must be surrounded by other non-dot characters
>         $dotAtom = '[a-zA-Z0-9\x21\x23\x24\x25\x26\x27\x2a\x2b\x2d\x2f\x3d';
>         $dotAtom .= '\x3f\x5e\x5f\x60\x7b\x7c\x7d\x7e\x2e]';
>
>         // TODO: speed test strpos instead of preg_match for dot in start
> and end of string
>         if ( (preg_match('/^' . $dotAtom . '+$/', $localPart)) &&
>         (!preg_match('/^\x2e/', $localPart)) && (!preg_match('/\x2e$/',
> $localPart)) ) {
>             $localResult = true;
>         }
>
>         // If not matched, try quoted string format
>         if (!$localResult) {
>             // TODO
>         }
>
>         // if not matched, try obsolete format
>         if (!$localResult) {
>             // TODO
>         }
>
>         if ($localResult && $domainResult) {
>             return true;
>         }
>     }
>     return $false;
> }
>     
> --------------------------
>
> There was also some mention of this method checking the network to see if
> the email address actually is valid. I am not sure if that is actually
> required, though I don't beleive this is the best place for that kind of
> check. 
>
> An email address tester should simply check the format, a separate network
> tool would be required to actually test for a valid email. Network checking
> would also impose a time delay so is probably best used asynchronously in a
> separate cron script.
>
> best wishes,
> Simon 
>       
>
>
>   


-- 

        Bruno Friedmann <[EMAIL PROTECTED]>

Ioda-Net Sàrl
        c/o RFV, H. Vauclair SA
        Rue de l'Avenir 12
        2800 Delémont - Switzerland
        Tél : ++41 32 435 7171
        Fax : ++41 32 435 7172
        gsm : ++41 78 802 6760
www.ioda-net.ch         Solutions informatiques et internet, coaching et 
relooking
www.cfcel.com           Centre de formation et de coaching en ligne


Reply via email to