line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::SMTP::Verify::ResultSet; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
18
|
use Moose; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
43
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.03'; # VERSION |
6
|
|
|
|
|
|
|
# ABSTRACT: resultset for Net::SMTP::Verify checks |
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
21026
|
use Net::SMTP::Verify::Result; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
144
|
|
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
3565
|
use Data::Dumper; |
|
3
|
|
|
|
|
20906
|
|
|
3
|
|
|
|
|
210
|
|
11
|
3
|
|
|
3
|
|
21
|
use JSON; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
48
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has 'results' => ( |
15
|
|
|
|
|
|
|
is => 'ro', isa => 'HashRef[Net::SMTP::Verify::Result]', lazy => 1, |
16
|
|
|
|
|
|
|
default => sub { {} }, |
17
|
|
|
|
|
|
|
traits => [ 'Hash' ], |
18
|
|
|
|
|
|
|
handles => { |
19
|
|
|
|
|
|
|
'recipient' => 'get', |
20
|
|
|
|
|
|
|
'recipients' => 'keys', |
21
|
|
|
|
|
|
|
'entries' => 'values', |
22
|
|
|
|
|
|
|
'count' => 'count', |
23
|
|
|
|
|
|
|
}, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# install shortcuts |
27
|
|
|
|
|
|
|
*rcpt = \&recipient; |
28
|
|
|
|
|
|
|
*rcpts = \&recipients; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub add_result { |
32
|
12
|
|
|
12
|
1
|
39
|
my ( $self, $result ) = @_; |
33
|
12
|
|
|
|
|
739
|
$self->results->{$result->address} = $result; |
34
|
12
|
|
|
|
|
38
|
return; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub set { |
39
|
24
|
|
|
24
|
1
|
397
|
my ( $self, $rcpts, $field, @params ) = @_; |
40
|
24
|
100
|
|
|
|
107
|
if( ! ref $rcpts ) { |
41
|
18
|
|
|
|
|
59
|
$rcpts = [ $rcpts ]; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
24
|
|
|
|
|
152
|
foreach my $rcpt ( @$rcpts ) { |
45
|
36
|
|
|
|
|
2480
|
my $result = $self->rcpt( $rcpt ); |
46
|
36
|
100
|
|
|
|
111
|
if( ! defined $result ) { |
47
|
12
|
|
|
|
|
117
|
$result = Net::SMTP::Verify::Result->new( |
48
|
|
|
|
|
|
|
address => $rcpt, |
49
|
|
|
|
|
|
|
); |
50
|
12
|
|
|
|
|
24047
|
$self->add_result( $result ); |
51
|
|
|
|
|
|
|
} |
52
|
36
|
|
|
|
|
1901
|
$result->$field( @params ); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
24
|
|
|
|
|
226
|
return; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub dump { |
60
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
61
|
0
|
|
|
|
|
0
|
print Dumper $self->entries; |
62
|
0
|
|
|
|
|
0
|
return; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub dump_json { |
67
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
68
|
0
|
|
|
|
|
0
|
foreach my $rcpt ( $self->entries ) { |
69
|
0
|
|
|
|
|
0
|
print to_json { %$rcpt }, { |
70
|
|
|
|
|
|
|
pretty => 1, |
71
|
|
|
|
|
|
|
}; |
72
|
|
|
|
|
|
|
} |
73
|
0
|
|
|
|
|
0
|
return; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub print_text { |
78
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
0
|
foreach my $rcpt ( $self->entries ) { |
81
|
0
|
|
|
|
|
0
|
print $rcpt->{'address'}.":\n"; |
82
|
0
|
|
|
|
|
0
|
foreach my $field ( keys %$rcpt ) { |
83
|
0
|
0
|
|
|
|
0
|
if( $field eq 'address') { |
84
|
0
|
|
|
|
|
0
|
next; |
85
|
|
|
|
|
|
|
} |
86
|
0
|
|
|
|
|
0
|
print " $field: ".$rcpt->{$field}."\n"; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
0
|
return; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub is_all_success { |
95
|
4
|
|
|
4
|
1
|
2077
|
my $self = shift; |
96
|
|
|
|
|
|
|
|
97
|
4
|
|
|
|
|
286
|
foreach my $rcpt ( $self->entries ) { |
98
|
9
|
100
|
|
|
|
51
|
if( ! $rcpt->is_success ) { |
99
|
2
|
|
|
|
|
15
|
return 0; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
2
|
|
|
|
|
31
|
return 1; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub successfull_rcpts { |
108
|
3
|
|
|
3
|
1
|
193
|
return grep { $_->is_success } shift->entries; |
|
9
|
|
|
|
|
37
|
|
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
*success_rcpts = \&successfull_rcpts; |
111
|
|
|
|
|
|
|
sub error_rcpts { |
112
|
0
|
|
|
0
|
1
|
0
|
return grep { $_->is_error } shift->entries; |
|
0
|
|
|
|
|
0
|
|
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
sub temp_error_rcpts { |
115
|
0
|
|
|
0
|
1
|
0
|
return grep { $_->is_temp_error } shift->entries; |
|
0
|
|
|
|
|
0
|
|
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
sub perm_error_rcpts { |
118
|
2
|
|
|
2
|
1
|
135
|
return grep { $_->is_perm_error } shift->entries; |
|
6
|
|
|
|
|
33
|
|
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
__END__ |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=pod |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=encoding UTF-8 |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 NAME |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Net::SMTP::Verify::ResultSet - resultset for Net::SMTP::Verify checks |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 VERSION |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
version 1.03 |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 SYNOPSIS |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
$rs = Net::SMTP::Verify::ResultSet->new; |
140
|
|
|
|
|
|
|
$rs->set( [ |
141
|
|
|
|
|
|
|
'rcpt@domain.de', |
142
|
|
|
|
|
|
|
'rcpt2@domain.de', |
143
|
|
|
|
|
|
|
], 'smtp_code', 200); |
144
|
|
|
|
|
|
|
$rs->print_text; |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 DESCRIPTION |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This class will hold a set of Net::SMTP::Verify::Result objects. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head2 results |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
A HashRef holding the Net::SMTP::Verify::Result objects. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 METHODS |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head2 recipient( $rcpt ), rcpt( $rcpt ) |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Get the result for address $rcpt. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head2 recipients(), rcpts() |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Get all recipient addresses in the resultset. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head2 entries() |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Returns a list of all Net::SMTP::Verify::Result objects. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head2 count() |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Returns the number of result objects. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head2 add_result( $result ) |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Adds a single $result object to the resultset. |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head2 set( $rcpt, $field, $params ) |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
If theres no result for $rcpt in the resultset it will create an result object |
181
|
|
|
|
|
|
|
for the address. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Then it will call the accessor $field with @params. |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
If $rcpt is a array reference instead of a scalar it will do that for |
186
|
|
|
|
|
|
|
every address listed in the array. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head2 dump() |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
Output all results with Data::Dumper. |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=head2 dump_json() |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Output all results as JSON. |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head2 print_text() |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Output all results as text. |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head2 is_all_success() |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Returns true if all object are success. |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=head2 successfull_rcpts(), success_rcpts() |
205
|
|
|
|
|
|
|
=head2 error_rcpts() |
206
|
|
|
|
|
|
|
=head2 temp_error_rcpts() |
207
|
|
|
|
|
|
|
=head2 perm_error_rcpts() |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
Returns all successfull|error|temp_error|perm_error result objects. |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head1 AUTHOR |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
Markus Benning <ich@markusbenning.de> |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
This software is Copyright (c) 2015 by Markus Benning <ich@markusbenning.de>. |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
This is free software, licensed under: |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
The GNU General Public License, Version 2, June 1991 |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=cut |