line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package oEdtk::Messenger;
|
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
678
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
997
|
use Email::Sender::Simple qw(sendmail);
|
|
1
|
|
|
|
|
410628
|
|
|
1
|
|
|
|
|
7
|
|
7
|
1
|
|
|
1
|
|
1429
|
use Email::Sender::Transport::SMTP;
|
|
1
|
|
|
|
|
18233
|
|
|
1
|
|
|
|
|
75
|
|
8
|
1
|
|
|
1
|
|
198
|
use oEdtk::Config qw(config_read);
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
66
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
6
|
use Exporter;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
608
|
|
11
|
|
|
|
|
|
|
our $VERSION = 0.001;
|
12
|
|
|
|
|
|
|
our @ISA = qw(Exporter);
|
13
|
|
|
|
|
|
|
our @EXPORT_OK = qw(oe_send_mail);
|
14
|
|
|
|
|
|
|
#http://search.cpan.org/~rjbs/Email-Sender-0.120002/lib/Email/Sender/Manual/QuickStart.pm
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub oe_send_mail {
|
17
|
0
|
|
|
0
|
0
|
|
my ($to, $subject, @body) = @_;
|
18
|
0
|
|
|
|
|
|
my $cfg = config_read('MAIL');
|
19
|
0
|
|
0
|
|
|
|
$subject ||=$0;
|
20
|
0
|
|
|
|
|
|
$subject = $cfg->{'EDTK_TYPE_ENV'} . " - $subject ";
|
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
my $transport = Email::Sender::Transport::SMTP->new({
|
23
|
|
|
|
|
|
|
host => $cfg->{'EDTK_MAIL_SMTP'}
|
24
|
|
|
|
|
|
|
});
|
25
|
|
|
|
|
|
|
|
26
|
0
|
|
0
|
|
|
|
my $email = Email::Simple->create(
|
|
|
|
0
|
|
|
|
|
27
|
|
|
|
|
|
|
header => [
|
28
|
|
|
|
|
|
|
To => $to || $cfg->{'EDTK_MAIL_SENDER'},
|
29
|
|
|
|
|
|
|
From => $cfg->{'EDTK_MAIL_SENDER'},
|
30
|
|
|
|
|
|
|
Subject => $subject || $0
|
31
|
|
|
|
|
|
|
],
|
32
|
|
|
|
|
|
|
body => join('', @body)
|
33
|
|
|
|
|
|
|
);
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Useful for testing.
|
36
|
0
|
0
|
|
|
|
|
if ($cfg->{'EDTK_MAIL_SMTP'} eq 'warn') {
|
37
|
0
|
|
|
|
|
|
print $email->as_string() . "\n" ;
|
38
|
|
|
|
|
|
|
} else {
|
39
|
0
|
|
|
|
|
|
eval { sendmail($email, { transport => $transport }); } ;
|
|
0
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
if ($@) {
|
41
|
0
|
|
|
|
|
|
die "ERROR: sendmail failed. Reason is $@\n";
|
42
|
|
|
|
|
|
|
}
|
43
|
|
|
|
|
|
|
}
|
44
|
|
|
|
|
|
|
}
|