Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: use Email::Valid offline

by davido (Cardinal)
on Mar 09, 2020 at 16:14 UTC ( #11114014=note: print w/replies, xml ) Need Help??


in reply to use Email::Valid offline

I haven't been able to replicate this behavior. I tried the following:

First, I shut off all network connections and ran this code:

my $address = Email::Valid->address(-address => 'foo@example.com', -mx +check => 0, -tldcheck => 0, -fudge => 0); use Data::Dumper; warn Dumper $address;

I did not block. Next I added $Email::Valid::Debug = 1; at the top of my script, and saw no debug output. Next I ran the same but with -mxcheck => 1. With that setting I did block (my network was off) and saw this output: using Net::DNS for dns query. Turning the network back on, I got a clean response but with that same debug. My next step was to override the Net::DNS::Resolver::new sub and the Net::DNS::mx sub so that they would warn if invoked. With -mxcheck => 0 I got no warning. With -mxcheck => 1 I got the warning indicating I was hitting Net::DNS code.

Finally I spewed %INC with -mxcheck set false. Unfortunately Net::DNS does get loaded even if the check is turned off. But with no network I never blocked.

In the POD for Email::Valid it mentioned that you can set $Email::Valid::Resolver->tcp_timeout($seconds) and $Email::Valid::Resolver->udp_timeout($seconds) to set how many seconds you're willing to wait on the network. If you continue to find a way to get blocking behavior despite turning off the external checks, set that number really low. However, in my own testing with the network turned off, those two method calls didn't seem to do what was needed; I still got blocking behavior.

One more thing: I looked at Net::Domain::TLD and saw that it does not seem to hit the network. So you could probably enable -tldcheck => 1 without blocking.


Dave

Replies are listed 'Best First'.
Re^2: use Email::Valid offline
by IB2017 (Pilgrim) on Mar 09, 2020 at 16:38 UTC

    Thank you for your reply.

    I always get "unresolvable name: at C:/Strawberry/perl/vendor/lib/Email/Valid.pm line 41.", no matter what I try. Even setting $Email::Valid::Resolver = 1 makes no difference, as if no option is read by the module.

    Email::Valid is up-to-date, Perl is v5.28.1

      Re-check my post: $Email::Valid::Resolver = 1 was incorrect. As far as I can tell $Email::Valid::Resolver->tcp_timeout($seconds) is correct, though doesn't seem strong enough. I apologize for the confusion.

      What version of Email::Valid and Net::DNS are you using? Line 41 of Email::Valid in the version currently available on CPAN doesn't contain code that should trigger that message.


      Dave

        Net::DNS is 1.19. Note that I am having problems updating to the latest which is 1.21. Need to understand why.

        Email::Valid is 1.202, alas up to date

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11114014]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2020-08-14 06:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which rocket would you take to Mars?










    Results (75 votes). Check out past polls.

    Notices?