in reply to Mail::CheckUser inconsistent results

Q1. Do you get similar results?

Kinda sorta , see below

Q2. Why am I getting inconsistent results?

Networks are networks, they're inconsistent by nature

Or maybe old module needs TLC? Bug #106606 for Mail-CheckUser: Missing code checks in check_user_on_host

I'm guessing probably a timeout occurs or the domain check is skipped the times you get validation

Q3. Can you suggest a better way of doing this check? (Basically I want to at least check the syntax of the address and that the domain exists, and I want a result within a second.)

I might give Email::Valid a try

#!/usr/bin/perl -- BEGIN{$Mail::CheckUser::Skip_SMTP_Checks = 1}; use strict; use warnings; use Mail::CheckUser qw/ check_email last_check /; use Email::Valid; for (qw/ a@b.com a@abczz123ffz.com /){ for my $i (0..9){ print "$_ -> "; my $tt = time; #~ Alpha($_); Omega($_); print " ", time-$tt, "\n"; } } sub Omega { my $ev = Email::Valid->new( -mxcheck => 1, ); if ( $ev->address( "$_" ) ){ print "OK"; }else{ print "NOT OK ", $ev->details ; } } sub Alpha { if ( check_email($_)){ print "OK" }else{ print last_check()->{reason}; } } __END__ a@b.com -> DNS failure: NXDOMAIN 0.293894052505493 a@b.com -> DNS failure: NXDOMAIN 0.206084966659546 a@b.com -> DNS failure: NXDOMAIN 0.219376087188721 a@b.com -> DNS failure: NXDOMAIN 0.218585014343262 a@b.com -> DNS failure: NXDOMAIN 0.249444961547852 a@b.com -> DNS failure: NXDOMAIN 0.250465869903564 a@b.com -> DNS failure: NXDOMAIN 0.249492883682251 a@b.com -> DNS failure: NXDOMAIN 0.249480009078979 a@b.com -> DNS failure: NXDOMAIN 0.249181985855103 a@b.com -> DNS failure: NXDOMAIN 0.251276016235352 a@abczz123ffz.com -> DNS failure: NXDOMAIN 0.251024007797241 a@abczz123ffz.com -> DNS failure: NXDOMAIN 0.248931884765625 a@abczz123ffz.com -> DNS failure: NXDOMAIN 0.250422954559326 a@abczz123ffz.com -> DNS failure: NXDOMAIN 0.249350070953369 a@abczz123ffz.com -> DNS failure: NXDOMAIN 0.250164985656738 a@abczz123ffz.com -> DNS failure: NXDOMAIN 0.251390933990479 a@abczz123ffz.com -> DNS failure: NXDOMAIN 0.248254060745239 a@abczz123ffz.com -> DNS failure: NXDOMAIN 0.281542062759399 a@abczz123ffz.com -> DNS failure: NXDOMAIN 0.240454912185669 a@abczz123ffz.com -> DNS failure: NXDOMAIN 0.254595994949341 a@b.com -> NOT OK mxcheck 0.291569948196411 a@b.com -> NOT OK mxcheck 0.208410024642944 a@b.com -> NOT OK mxcheck 0.219083070755005 a@b.com -> NOT OK mxcheck 0.218981981277466 a@b.com -> NOT OK mxcheck 0.24937891960144 a@b.com -> NOT OK mxcheck 0.249850988388062 a@b.com -> NOT OK mxcheck 0.328232049942017 a@b.com -> NOT OK mxcheck 0.250256061553955 a@b.com -> NOT OK mxcheck 0.265328884124756 a@b.com -> NOT OK mxcheck 0.247688055038452 a@abczz123ffz.com -> NOT OK mxcheck 0.392891883850098 a@abczz123ffz.com -> NOT OK mxcheck 0.250204086303711 a@abczz123ffz.com -> NOT OK mxcheck 0.249541044235229 a@abczz123ffz.com -> NOT OK mxcheck 0.453320026397705 a@abczz123ffz.com -> NOT OK mxcheck 0.218268156051636 a@abczz123ffz.com -> NOT OK mxcheck 0.218549966812134 a@abczz123ffz.com -> NOT OK mxcheck 0.250627994537354 a@abczz123ffz.com -> NOT OK mxcheck 0.312192916870117 a@abczz123ffz.com -> NOT OK mxcheck 0.234641075134277 a@abczz123ffz.com -> NOT OK mxcheck 0.250532865524292

Replies are listed 'Best First'.
Re^2: Mail::CheckUser inconsistent results
by tel2 (Pilgrim) on Aug 26, 2015 at 07:55 UTC
    Awesome answer, Anonymous Monk!

    Thanks very much for all that.

    But I don't see any inconsistent results with your code. Some of that output was from Mail::CheckUser, right?

    tel2

      Hi again Anonymous Monk.

      Your output looks doubled.  Did you run it twice - once with Alpha($_) uncommented and once with Omega($_) uncommented, or what?

      Strangely, today when I run my one liners on my webhost I seem to be getting 100% positive (i.e. wrong) results, regardless of the domain, as long as the address syntax is correct.  For example:

      $ echo "a@abczz123ffz.com" | perl -MMail::CheckUser=check_email,last_check -ne 'BEGIN{$Mail::CheckUser::Skip_SMTP_Checks = 1};chomp;for $i (0..9){print "$_ -> ";if (check_email($_)){print "OK\n"}else{print last_check()->{reason}."\n"}}'
      a@abczz123ffz.com -> OK
      a@abczz123ffz.com -> OK
      a@abczz123ffz.com -> OK
      a@abczz123ffz.com -> OK
      a@abczz123ffz.com -> OK
      a@abczz123ffz.com -> OK
      a@abczz123ffz.com -> OK
      a@abczz123ffz.com -> OK
      a@abczz123ffz.com -> OK
      a@abczz123ffz.com -> OK
      
      Just tried it on a different host and the results are 100% negative (i.e. correct).  Any ideas?  If I take this up with the webhost, what should I say?

      Thanks.

        Your output looks doubled. Did you run it twice - once with Alpha($_) uncommented and once with Omega($_) uncommented, or what?

        Yes I did , its why the output is slightly different format each time

        Just tried it on a different host and the results are 100% negative (i.e. correct). Any ideas?

        Just the same ones :) Try adding this and see what you get

        use Mail::CheckUser qw/ check_email last_check /; BEGIN{ $Mail::CheckUser::Skip_SMTP_Checks = 1; $Mail::CheckUser::Treat_Timeout_As_Fail = 1; $Mail::CheckUser::Debug = 1; }

        or maybe look inside :) look at what its doing ... so i do that and I try I get

        So this mean my local DNS server is telling me those adresses don't really exist

        Maybe your DNS server is lying to you , it happens, DNS hijacking