File Coverage

blib/lib/WebService/VerifyEmail.pm
Criterion Covered Total %
statement 14 22 63.6
branch 0 2 0.0
condition n/a
subroutine 5 7 71.4
pod 0 2 0.0
total 19 33 57.5


line stmt bran cond sub pod time code
1             package WebService::VerifyEmail;
2             $WebService::VerifyEmail::VERSION = '0.03';
3 1     1   685 use 5.006;
  1         3  
4 1     1   772 use Moo;
  1         14491  
  1         5  
5 1     1   2429 use Net::HTTP::Tiny qw(http_get);
  1         6851  
  1         68  
6 1     1   6 use JSON qw(decode_json);
  1         2  
  1         8  
7 1     1   689 use WebService::VerifyEmail::Response;
  1         4  
  1         196  
8              
9             has username => (is => 'ro');
10             has password => (is => 'ro');
11              
12             sub email_ok
13             {
14 0     0 0   my $self = shift;
15 0           my $email_address = shift;
16 0           my $response = $self->check_email($email_address);
17              
18 0 0         return $response->verify_status eq '1' ? 1 : 0;
19             }
20              
21             sub check_email
22             {
23 0     0 0   my $self = shift;
24 0           my $email_address = shift;
25              
26 0           my $url = sprintf("http://api.verify-email.org/api.php?usr=%s&pwd=%s&check=%s",
27             $self->username,
28             $self->password,
29             $email_address);
30 0           return WebService::VerifyEmail::Response->new( decode_json( http_get($url) ) );
31             }
32              
33             1;
34              
35             =head1 NAME
36              
37             WebService::VerifyEmail - check validity of an email address using verify-email.org
38              
39             =head1 SYNOPSIS
40              
41             use WebService::VerifyEmail;
42            
43             my $verifier = WebService::VerifyEmail->new(
44             username => $username,
45             password => $password,
46             );
47            
48             print "Email is ", $verifier->email_ok($email)
49             ? 'GOOD'
50             : 'BAD', "\n";
51              
52             =head1 DESCRIPTION
53              
54             WebService::VerifyEmail is an interface to the service at
55             L which is used to check
56             whether an email address is bad.
57              
58             The simplest way to use this module is the example given in the SYNOPSIS above.
59             The module also provides a C method, which returns an object
60             with more information:
61              
62             $response = $verifier->check_email($email);
63             if ($response->verify_status) {
64             print "$email is GOOD\n";
65             } else {
66             print "$email is BAD:\n",
67             " auth status: ", $response->authentication_status, "\n",
68             " limit status: ", $response->limit_status, "\n",
69             " limit desc: ", $response->limit_desc, "\n",
70             " verify desc: ", $response->verify_status_desc, "\n";
71             }
72              
73             The C field is B<1> if the email address is good,
74             and C<0> if the email address is bad (caveat: see L).
75             I'm not sure about the other fields at the moment, but when I've had
76             clarification, I'll update this documentation :-)
77              
78             verify-email.org is a commercial service: there is a free level,
79             but you can only check a small number of email addresses with that.
80             You'll have to pay if you want to check any serious
81             number of email addresses.
82              
83             =head1 KNOWN BUGS
84              
85             You can get false positives from the service: an email address can
86             be reported as good, but then when you try and send email to it, you get a bounce.
87             That's just the reality of the email infrastructure.
88              
89             =head1 SEE ALSO
90              
91             The following modules provide some form of checking of email addresses,
92             from basic format checks upwards.
93              
94             L, L, L, L,
95             L, L, L, L.
96              
97             =head1 REPOSITORY
98              
99             L
100              
101             =head1 AUTHOR
102              
103             Neil Bowers Eneilb@cpan.orgE
104              
105             =head1 COPYRIGHT AND LICENSE
106              
107             This software is copyright (c) 2013 by Neil Bowers .
108              
109             This is free software; you can redistribute it and/or modify it under
110             the same terms as the Perl 5 programming language system itself.
111              
112