File Coverage

blib/lib/WebService/VerifyEmail.pm
Criterion Covered Total %
statement 15 23 65.2
branch 0 2 0.0
condition n/a
subroutine 5 7 71.4
pod 0 2 0.0
total 20 34 58.8


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