line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dancer::Plugin::EmailSender; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Dancer::Plugin::EmailSender::VERSION = '0.002'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
#ABSTRACT: Easily use Email::Sender from Dancer |
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
278061
|
use Carp qw{croak}; |
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
258
|
|
8
|
2
|
|
|
2
|
|
1978
|
use Dancer ':syntax'; |
|
2
|
|
|
|
|
366729
|
|
|
2
|
|
|
|
|
11
|
|
9
|
2
|
|
|
2
|
|
2425
|
use Dancer::Plugin; |
|
2
|
|
|
|
|
3172
|
|
|
2
|
|
|
|
|
149
|
|
10
|
2
|
|
|
2
|
|
2051
|
use Email::MIME; |
|
2
|
|
|
|
|
119186
|
|
|
2
|
|
|
|
|
41
|
|
11
|
2
|
|
|
2
|
|
1647
|
use Email::Sender::Simple qw{sendmail}; |
|
2
|
|
|
|
|
367171
|
|
|
2
|
|
|
|
|
18
|
|
12
|
2
|
|
|
2
|
|
3599
|
use Module::Load 'load'; |
|
2
|
|
|
|
|
2524
|
|
|
2
|
|
|
|
|
16
|
|
13
|
2
|
|
|
2
|
|
205
|
use Scalar::Util 'blessed'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
146
|
|
14
|
2
|
|
|
2
|
|
961
|
use Test::More import => ['!pass']; |
|
2
|
|
|
|
|
17160
|
|
|
2
|
|
|
|
|
32
|
|
15
|
2
|
|
|
2
|
|
1142
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
55
|
|
16
|
2
|
|
|
2
|
|
28
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1305
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
register sendemail => sub { |
20
|
10
|
100
|
|
10
|
|
36424
|
my ($args) = @_ or croak 'You must pass me information on what to send'; |
21
|
9
|
100
|
|
|
|
190
|
ref $args eq "HASH" or croak 'You must pass me a hashref to describe the email'; |
22
|
|
|
|
|
|
|
|
23
|
8
|
|
|
|
|
35
|
my $config = plugin_setting; |
24
|
|
|
|
|
|
|
|
25
|
8
|
|
|
|
|
158
|
my $email; |
26
|
|
|
|
|
|
|
|
27
|
8
|
100
|
|
|
|
27
|
if ($args->{email}) { |
28
|
1
|
|
|
|
|
9
|
$email = Email::Abstract->new ($args->{email}); |
29
|
|
|
|
|
|
|
} else { |
30
|
7
|
50
|
|
|
|
13
|
my $headers = {%{ref $config->{headers} eq 'HASH' ? $config->{headers} : {}}, %{ref $args->{headers} eq 'HASH' ? $args->{headers} : {}}, From => $args->{from}, To => join ",", ref $args->{to} eq 'ARRAY' ? @{$args->{to}} : ()}; |
|
7
|
100
|
|
|
|
39
|
|
|
7
|
100
|
|
|
|
56
|
|
|
4
|
|
|
|
|
23
|
|
31
|
7
|
|
|
|
|
20
|
$email = Email::Abstract->new (Email::MIME->create (header_str => [%{$headers}], body => $args->{body})); |
|
7
|
|
|
|
|
70
|
|
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
8
|
50
|
|
|
|
7088
|
croak 'Could not extract or construct an email from our parameters' unless ($email); |
35
|
|
|
|
|
|
|
|
36
|
8
|
|
|
|
|
19
|
my $params = {}; |
37
|
8
|
100
|
100
|
|
|
52
|
($params->{from} = $args->{'envelope-from'}) or $email->get_header ('from') or croak 'You must tell me who the email is from'; |
38
|
7
|
100
|
100
|
|
|
256
|
($params->{to} = $args->{'envelope-to'}) or $email->get_header ('to') or croak 'You must tell me to whom to send the email'; |
39
|
|
|
|
|
|
|
|
40
|
5
|
50
|
66
|
|
|
292
|
if (blessed $args->{transport}) { |
|
|
100
|
|
|
|
|
|
41
|
0
|
|
|
|
|
0
|
$params->{transport} = $args->{transport}; |
42
|
|
|
|
|
|
|
} elsif (!defined $args->{transport} and blessed $config->{transport}) { |
43
|
4
|
|
|
|
|
9
|
$params->{transport} = $config->{transport}; |
44
|
|
|
|
|
|
|
} else { |
45
|
1
|
50
|
|
|
|
4
|
my $transport = {%{ref $config->{transport} eq 'HASH' ? $config->{transport} : {}}, %{ref $args->{transport} eq 'HASH' ? $args->{transport} : {}}}; |
|
1
|
50
|
|
|
|
9
|
|
|
1
|
|
|
|
|
9
|
|
46
|
1
|
50
|
|
|
|
7
|
if (my $choice = delete $transport->{class}) { |
47
|
1
|
|
|
|
|
25
|
my $class = "Email::Sender::Transport::$choice"; |
48
|
1
|
|
|
|
|
8
|
load $class; |
49
|
1
|
|
|
|
|
3963
|
$params->{transport} = $class->new ($transport); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
5
|
|
|
|
|
1621
|
return sendmail $email, $params; |
54
|
|
|
|
|
|
|
}; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
register_plugin; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |