line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Log::Dispatch::Email::Siffra; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
85579
|
use 5.014; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
5
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
6
|
1
|
|
|
1
|
|
12
|
use Carp; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
56
|
|
7
|
1
|
|
|
1
|
|
537
|
use utf8; |
|
1
|
|
|
|
|
13
|
|
|
1
|
|
|
|
|
4
|
|
8
|
1
|
|
|
1
|
|
548
|
use Data::Dumper; |
|
1
|
|
|
|
|
5803
|
|
|
1
|
|
|
|
|
65
|
|
9
|
1
|
|
|
1
|
|
419
|
use DDP; |
|
1
|
|
|
|
|
36162
|
|
|
1
|
|
|
|
|
10
|
|
10
|
1
|
|
|
1
|
|
547
|
use Encode qw(decode encode); |
|
1
|
|
|
|
|
8314
|
|
|
1
|
|
|
|
|
82
|
|
11
|
1
|
|
|
1
|
|
421
|
use Log::Any qw($log); |
|
1
|
|
|
|
|
8879
|
|
|
1
|
|
|
|
|
6
|
|
12
|
|
|
|
|
|
|
$Carp::Verbose = 1; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
$| = 1; #autoflush |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
BEGIN |
17
|
|
|
|
|
|
|
{ |
18
|
1
|
|
|
1
|
|
27
|
binmode( STDOUT, ":encoding(UTF-8)" ); |
|
1
|
|
|
1
|
|
5
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
19
|
1
|
|
|
|
|
986
|
binmode( STDERR, ":encoding(UTF-8)" ); |
20
|
1
|
|
|
|
|
447
|
require Log::Dispatch::Email; |
21
|
1
|
|
|
1
|
|
1914
|
use Exporter (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
22
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
112
|
|
23
|
1
|
|
|
|
|
256156
|
$VERSION = '0.04'; |
24
|
1
|
|
|
|
|
24
|
@ISA = qw(Log::Dispatch::Email Exporter); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#Give a hoot don't pollute, do not export more than needed by default |
27
|
1
|
|
|
|
|
5
|
@EXPORT = qw(); |
28
|
1
|
|
|
|
|
3
|
@EXPORT_OK = qw(); |
29
|
1
|
|
|
|
|
51
|
%EXPORT_TAGS = (); |
30
|
|
|
|
|
|
|
} ## end BEGIN |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head3 C<send_email()> |
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub send_email |
36
|
|
|
|
|
|
|
{ |
37
|
0
|
|
|
0
|
1
|
|
my ( $self, %parameters ) = @_; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Send email somehow. Message is in $parameters{message} |
40
|
1
|
|
|
1
|
|
852
|
use MIME::Lite; |
|
1
|
|
|
|
|
26325
|
|
|
1
|
|
|
|
|
252
|
|
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my $to = ( join ',', @{ $self->{ to } } ); |
|
0
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my $from = $self->{ from }; |
44
|
0
|
|
|
|
|
|
my $subject = $self->{ subject }; |
45
|
0
|
|
|
|
|
|
my $message = "<h4>$parameters{ message }</h4>"; |
46
|
0
|
|
0
|
|
|
|
my $host = ( $self->{ host } // 'mail' ); |
47
|
0
|
|
0
|
|
|
|
my $port = ( $self->{ port } // 2525 ); |
48
|
0
|
|
|
|
|
|
$message = encode( 'utf8', $message ); |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my $msg = MIME::Lite->new( |
51
|
|
|
|
|
|
|
From => $from, |
52
|
|
|
|
|
|
|
To => $to, |
53
|
|
|
|
|
|
|
Subject => $subject, |
54
|
|
|
|
|
|
|
Data => $message, |
55
|
|
|
|
|
|
|
Type => 'text/html; charset=UTF-8', |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
$msg->attr( 'content-type' => 'text/html' ); |
59
|
0
|
|
|
|
|
|
$msg->attr( 'content-type.charset' => 'UTF-8' ); |
60
|
0
|
|
|
|
|
|
$msg->send( 'smtp', $host, 'port', $port ); |
61
|
0
|
|
|
|
|
|
$log->info( "Email enviado com sucesso : host [ $host ] port [ $port ] subject [ $subject ]\n" ); |
62
|
|
|
|
|
|
|
} ## end sub send_email |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head3 C<flush()> |
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub flush |
68
|
|
|
|
|
|
|
{ |
69
|
0
|
|
|
0
|
1
|
|
my ( $self, %parameters ) = @_; |
70
|
|
|
|
|
|
|
|
71
|
0
|
0
|
0
|
|
|
|
if ( $self->{ buffered } && @{ $self->{ buffer } } ) |
|
0
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
{ |
73
|
0
|
|
|
|
|
|
my $message = join "<br>", @{ $self->{ buffer } }; |
|
0
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
$self->send_email( message => $message ); |
76
|
0
|
|
|
|
|
|
$self->{ buffer } = []; |
77
|
|
|
|
|
|
|
} ## end if ( $self->{ buffered...}) |
78
|
|
|
|
|
|
|
} ## end sub flush |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
#################### main pod documentation begin ################### |
81
|
|
|
|
|
|
|
## Below is the stub of documentation for your module. |
82
|
|
|
|
|
|
|
## You better edit it! |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=encoding UTF-8 |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 NAME |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Log::Dispatch::Email::Siffra - Module abstract (<= 44 characters) goes here |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 SYNOPSIS |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
use Log::Dispatch::Email::Siffra; |
94
|
|
|
|
|
|
|
blah blah blah |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 DESCRIPTION |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Stub documentation for this module was created by ExtUtils::ModuleMaker. |
100
|
|
|
|
|
|
|
It looks like the author of the extension was negligent enough |
101
|
|
|
|
|
|
|
to leave the stub unedited. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Blah blah blah. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 USAGE |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 BUGS |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 SUPPORT |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 AUTHOR |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Luiz Benevenuto |
121
|
|
|
|
|
|
|
CPAN ID: LUIZBENE |
122
|
|
|
|
|
|
|
Siffra TI |
123
|
|
|
|
|
|
|
luiz@siffra.com.br |
124
|
|
|
|
|
|
|
https://siffra.com.br |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 COPYRIGHT |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
This program is free software; you can redistribute |
129
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
The full text of the license can be found in the |
132
|
|
|
|
|
|
|
LICENSE file included with this module. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 SEE ALSO |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
perl(1). |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
#################### main pod documentation end ################### |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
1; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# The preceding line will help the module return a true value |
146
|
|
|
|
|
|
|
|