line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
8
|
|
|
8
|
|
122696
|
use strict; |
|
8
|
|
|
|
|
32
|
|
|
8
|
|
|
|
|
223
|
|
2
|
8
|
|
|
8
|
|
36
|
use warnings; |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
341
|
|
3
|
|
|
|
|
|
|
package Email::Sender::Util 1.500; |
4
|
|
|
|
|
|
|
# ABSTRACT: random stuff that makes Email::Sender go |
5
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
2613
|
use Email::Address; |
|
8
|
|
|
|
|
126988
|
|
|
8
|
|
|
|
|
339
|
|
7
|
8
|
|
|
8
|
|
927
|
use Email::Sender::Failure; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
237
|
|
8
|
8
|
|
|
8
|
|
1560
|
use Email::Sender::Failure::Permanent; |
|
8
|
|
|
|
|
25
|
|
|
8
|
|
|
|
|
200
|
|
9
|
8
|
|
|
8
|
|
1125
|
use Email::Sender::Failure::Temporary; |
|
8
|
|
|
|
|
20
|
|
|
8
|
|
|
|
|
231
|
|
10
|
8
|
|
|
8
|
|
44
|
use List::Util 1.45 (); |
|
8
|
|
|
|
|
386
|
|
|
8
|
|
|
|
|
175
|
|
11
|
8
|
|
|
8
|
|
40
|
use Module::Runtime qw(require_module); |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
72
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# This code will be used by Email::Sender::Simple. -- rjbs, 2008-12-04 |
14
|
|
|
|
|
|
|
sub _recipients_from_email { |
15
|
1
|
|
|
1
|
|
5
|
my ($self, $email) = @_; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my @to = List::Util::uniq( |
18
|
7
|
|
|
|
|
100
|
map { $_->address } |
19
|
4
|
|
|
|
|
905
|
map { Email::Address->parse($_) } |
20
|
1
|
|
|
|
|
3
|
map { $email->get_header($_) } |
|
3
|
|
|
|
|
145
|
|
21
|
|
|
|
|
|
|
qw(to cc bcc)); |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
22
|
return \@to; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _sender_from_email { |
27
|
1
|
|
|
1
|
|
283
|
my ($self, $email) = @_; |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
1422
|
my ($sender) = map { $_->address } |
30
|
1
|
|
|
|
|
5
|
map { Email::Address->parse($_) } |
|
1
|
|
|
|
|
96
|
|
31
|
|
|
|
|
|
|
scalar $email->get_header('from'); |
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
15
|
return $sender; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# It's probably reasonable to make this code publicker at some point, but for |
37
|
|
|
|
|
|
|
# now I don't want to deal with making a sane set of args. -- rjbs, 2008-12-09 |
38
|
|
|
|
|
|
|
sub _failure { |
39
|
7
|
|
|
7
|
|
9492
|
my ($self, $error, $smtp, @rest) = @_; |
40
|
|
|
|
|
|
|
|
41
|
7
|
|
|
|
|
13
|
my ($code, $message); |
42
|
7
|
100
|
|
|
|
13
|
if ($smtp) { |
43
|
6
|
|
|
|
|
14
|
$code = $smtp->code; |
44
|
6
|
|
|
|
|
12
|
$message = $smtp->message; |
45
|
6
|
50
|
|
|
|
17
|
$message = ! defined $message ? "(no SMTP error message)" |
|
|
50
|
|
|
|
|
|
46
|
|
|
|
|
|
|
: ! length $message ? "(empty SMTP error message)" |
47
|
|
|
|
|
|
|
: $message; |
48
|
|
|
|
|
|
|
|
49
|
6
|
100
|
66
|
|
|
26
|
$message = defined $error && length $error |
50
|
|
|
|
|
|
|
? "$error: $message" |
51
|
|
|
|
|
|
|
: $message; |
52
|
|
|
|
|
|
|
} else { |
53
|
1
|
|
|
|
|
2
|
$message = $error; |
54
|
1
|
50
|
|
|
|
3
|
$message = "(no error given)" unless defined $message; |
55
|
1
|
50
|
|
|
|
4
|
$message = "(empty error string)" unless length $message; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
7
|
100
|
|
|
|
25
|
my $error_class = ! $code ? 'Email::Sender::Failure' |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
59
|
|
|
|
|
|
|
: $code =~ /^4/ ? 'Email::Sender::Failure::Temporary' |
60
|
|
|
|
|
|
|
: $code =~ /^5/ ? 'Email::Sender::Failure::Permanent' |
61
|
|
|
|
|
|
|
: 'Email::Sender::Failure'; |
62
|
|
|
|
|
|
|
|
63
|
7
|
|
|
|
|
118
|
$error_class->new({ |
64
|
|
|
|
|
|
|
message => $message, |
65
|
|
|
|
|
|
|
code => $code, |
66
|
|
|
|
|
|
|
@rest, |
67
|
|
|
|
|
|
|
}); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
#pod =method easy_transport |
71
|
|
|
|
|
|
|
#pod |
72
|
|
|
|
|
|
|
#pod my $transport = Email::Sender::Util->easy_transport($class => \%arg); |
73
|
|
|
|
|
|
|
#pod |
74
|
|
|
|
|
|
|
#pod This takes the name of a transport class and a set of args to new. It returns |
75
|
|
|
|
|
|
|
#pod an Email::Sender::Transport object of that class. |
76
|
|
|
|
|
|
|
#pod |
77
|
|
|
|
|
|
|
#pod C<$class> is rewritten to C unless it starts |
78
|
|
|
|
|
|
|
#pod with an equals sign (C<=>) or contains a colon. The equals sign, if present, |
79
|
|
|
|
|
|
|
#pod will be removed. |
80
|
|
|
|
|
|
|
#pod |
81
|
|
|
|
|
|
|
#pod =cut |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub _rewrite_class { |
84
|
7
|
|
|
7
|
|
2426
|
my $transport_class = $_[1]; |
85
|
7
|
100
|
100
|
|
|
41
|
if ($transport_class !~ s/^=// and $transport_class !~ m{:}) { |
86
|
3
|
|
|
|
|
9
|
$transport_class = "Email::Sender::Transport::$transport_class"; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
7
|
|
|
|
|
24
|
return $transport_class; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub easy_transport { |
93
|
3
|
|
|
3
|
1
|
10
|
my ($self, $transport_class, $arg) = @_; |
94
|
|
|
|
|
|
|
|
95
|
3
|
|
|
|
|
8
|
$transport_class = $self->_rewrite_class($transport_class); |
96
|
|
|
|
|
|
|
|
97
|
3
|
|
|
|
|
14
|
require_module($transport_class); |
98
|
3
|
|
|
|
|
2004
|
return $transport_class->new($arg); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
__END__ |