line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Filter::DisposableEmail;
|
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
29263
|
use Mouse;
|
|
3
|
|
|
|
|
108394
|
|
|
3
|
|
|
|
|
17
|
|
4
|
3
|
|
|
3
|
|
4764
|
use MouseX::Params::Validate;
|
|
3
|
|
|
|
|
1073766
|
|
|
3
|
|
|
|
|
29
|
|
5
|
3
|
|
|
3
|
|
1416
|
use Mouse::Util::TypeConstraints;
|
|
3
|
|
|
|
|
14
|
|
|
3
|
|
|
|
|
33
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
272
|
use Carp;
|
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
219
|
|
8
|
3
|
|
|
3
|
|
3476
|
use Readonly;
|
|
3
|
|
|
|
|
9949
|
|
|
3
|
|
|
|
|
170
|
|
9
|
3
|
|
|
3
|
|
3479
|
use Data::Dumper;
|
|
3
|
|
|
|
|
24667
|
|
|
3
|
|
|
|
|
232
|
|
10
|
|
|
|
|
|
|
|
11
|
3
|
|
|
3
|
|
3516
|
use JSON;
|
|
3
|
|
|
|
|
44332
|
|
|
3
|
|
|
|
|
18
|
|
12
|
3
|
|
|
3
|
|
3905
|
use LWP::UserAgent;
|
|
3
|
|
|
|
|
158365
|
|
|
3
|
|
|
|
|
117
|
|
13
|
3
|
|
|
3
|
|
2889
|
use HTTP::Request::Common;
|
|
3
|
|
|
|
|
7061
|
|
|
3
|
|
|
|
|
232
|
|
14
|
3
|
|
|
3
|
|
2715
|
use Data::Validate::Email qw(is_email is_email_rfc822);
|
|
3
|
|
|
|
|
132171
|
|
|
3
|
|
|
|
|
1561
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NAME
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Filter::DisposableEmail - Interface to the DEAfilter RESTful API.
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 VERSION
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Version 0.02
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
our $VERSION = '0.02';
|
27
|
|
|
|
|
|
|
Readonly my $BASE_URL => 'http://www.deafilter.com/classes/DeaFilter.php';
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
This module helps you filter Disposable Email Addresses. It uses DEAfilter RESTful API and no
|
32
|
|
|
|
|
|
|
guarantee is provided by any means.
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 CONSTRUCTOR
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
The only parameter that is required is the API key. You can get one here:
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
http://www.deafilter.com/register.php
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
use strict; use warnings;
|
41
|
|
|
|
|
|
|
use Filter::DisposableEmail;
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my ($key, $filter);
|
44
|
|
|
|
|
|
|
$key = 'Your_API_Key';
|
45
|
|
|
|
|
|
|
$filter = Filter::DisposableEmail->new($key);
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
#or
|
48
|
|
|
|
|
|
|
$filter = Filter::DisposableEmail->new(key => $key);
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
type 'Email' => where { is_email($_) && is_email_rfc822($_) };
|
53
|
|
|
|
|
|
|
has 'key' => (is => 'ro', isa => 'Str', required => 1);
|
54
|
|
|
|
|
|
|
has 'browser' => (is => 'rw', isa => 'LWP::UserAgent', default => sub { return LWP::UserAgent->new(agent => 'Mozilla/5.0'); });
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
around BUILDARGS => sub
|
57
|
|
|
|
|
|
|
{
|
58
|
|
|
|
|
|
|
my $orig = shift;
|
59
|
|
|
|
|
|
|
my $class = shift;
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
if (@_ == 1 && !ref $_[0])
|
62
|
|
|
|
|
|
|
{
|
63
|
|
|
|
|
|
|
return $class->$orig(key => $_[0]);
|
64
|
|
|
|
|
|
|
}
|
65
|
|
|
|
|
|
|
else
|
66
|
|
|
|
|
|
|
{
|
67
|
|
|
|
|
|
|
return $class->$orig(@_);
|
68
|
|
|
|
|
|
|
}
|
69
|
|
|
|
|
|
|
};
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 METHOD
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 isDisposable()
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Return 1/0 depending whether the given email address is disposable or not. This simply rely on
|
76
|
|
|
|
|
|
|
DEAfilter API functionality. Because of it's nature, you may sometimes get false alarm.
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
use strict; use warnings;
|
79
|
|
|
|
|
|
|
use Filter::DisposableEmail;
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my $key = 'Your_API_Key';
|
82
|
|
|
|
|
|
|
my $filter = Filter::DisposableEmail->new($key);
|
83
|
|
|
|
|
|
|
print "Yes it is.\n" if $filter->isDisposable(email => 'bill@microsoft.com');
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub isDisposable
|
88
|
|
|
|
|
|
|
{
|
89
|
1
|
|
|
1
|
1
|
3462
|
my $self = shift;
|
90
|
1
|
|
|
|
|
12
|
my %param = validated_hash(\@_,
|
91
|
|
|
|
|
|
|
'email' => { isa => 'Email' },
|
92
|
|
|
|
|
|
|
MX_PARAMS_VALIDATE_NO_CACHE => 1);
|
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
my ($browser, $response, $content);
|
95
|
0
|
|
|
|
|
|
$browser = $self->browser;
|
96
|
0
|
|
|
|
|
|
$browser->env_proxy;
|
97
|
0
|
|
|
|
|
|
$response = $browser->request(POST $BASE_URL, [mail => $param{email}, key => $self->key]);
|
98
|
0
|
0
|
|
|
|
|
croak("ERROR: Couldn't fetch data [$BASE_URL]:[".$response->status_line."]\n")
|
99
|
|
|
|
|
|
|
unless $response->is_success;
|
100
|
0
|
|
|
|
|
|
$content = $response->content;
|
101
|
0
|
0
|
|
|
|
|
croak("ERROR: No data found.\n") unless defined $content;
|
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
$content = from_json($content);
|
104
|
0
|
0
|
0
|
|
|
|
return (defined($content) && exists($content->{status}) && ($content->{status} =~ /^ok$/i))
|
105
|
|
|
|
|
|
|
?
|
106
|
|
|
|
|
|
|
(1):(0);
|
107
|
|
|
|
|
|
|
}
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 AUTHOR
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Mohammad S Anwar, C<< >>
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 BUGS
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or
|
116
|
|
|
|
|
|
|
through the web interface at L.
|
117
|
|
|
|
|
|
|
I will be notified and then you'll automatically be notified of progress on your bug as I make
|
118
|
|
|
|
|
|
|
changes.
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 SUPPORT
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command.
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
perldoc Filter::DisposableEmail
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
You can also look for information at:
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=over 4
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
L
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
L
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item * CPAN Ratings
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
L
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item * Search CPAN
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
L
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=back
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under the terms of
|
151
|
|
|
|
|
|
|
either: the GNU General Public License as published by the Free Software Foundation; or the
|
152
|
|
|
|
|
|
|
Artistic License.
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information.
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
DEAFilter API itself is distributed under the terms of the Gnu GPLv3 licence.
|
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head1 DISCLAIMER
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
161
|
|
|
|
|
|
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=cut
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable;
|
166
|
3
|
|
|
3
|
|
31
|
no Mouse; # Keywords are removed from the Filter::DisposableEmail package
|
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
29
|
|
167
|
3
|
|
|
3
|
|
354
|
no Mouse::Util::TypeConstraints;
|
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
23
|
|
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
1; # End of Filter::DisposableEmail
|