line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TeX::AutoTeX::Mail; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# $Id: Mail.pm,v 1.5.2.4 2011/01/27 18:42:28 thorstens Exp $ |
5
|
|
|
|
|
|
|
# $Revision: 1.5.2.4 $ |
6
|
|
|
|
|
|
|
# $Source: /cvsroot/arxivlib/arXivLib/lib/TeX/AutoTeX/Mail.pm,v $ |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# $Date: 2011/01/27 18:42:28 $ |
9
|
|
|
|
|
|
|
# $Author: thorstens $ |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
122
|
|
13
|
|
|
|
|
|
|
### use warnings; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our ($VERSION) = '$Revision: 1.5.2.4 $' =~ m{ \$Revision: \s+ (\S+) }x; |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
11
|
use TeX::AutoTeX::Config qw($TEX_ADMIN_ADDRESS $MAIL_FAILURES_ADDRESS $SENDMAIL); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
848
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new { |
20
|
0
|
|
|
0
|
1
|
|
my $that = shift; |
21
|
0
|
|
0
|
|
|
|
my $class = ref($that) || $that; |
22
|
0
|
|
|
|
|
|
my $self = {id => shift}; |
23
|
0
|
|
|
|
|
|
bless $self, $class; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub send_notification { |
27
|
0
|
|
|
0
|
1
|
|
my ($self, $to, $subject, $message, $reply_to) = @_; |
28
|
|
|
|
|
|
|
|
29
|
0
|
0
|
|
|
|
|
if (!defined $to) { |
30
|
0
|
|
|
|
|
|
return 'send_notification called but no message sent as destination address undefined.'; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my $PIPEMAIL; |
34
|
0
|
0
|
|
|
|
|
if (!open $PIPEMAIL, q{|-}, $SENDMAIL) { |
35
|
0
|
|
|
|
|
|
return 'send_notification failed to open pipe to sendmail for writing.'; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
0
|
|
|
|
$message ||= '[NO MESSAGE SPECIFIED IN ' . __PACKAGE__ . "]\n"; |
39
|
0
|
|
|
|
|
|
$message =~ s/\n\./\n \./g; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
0
|
|
|
|
my $id = $self->{id} || 'NO_IDENTIFIER'; |
42
|
0
|
|
|
|
|
|
print {$PIPEMAIL} <<"EOM"; |
|
0
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
To: $to |
44
|
|
|
|
|
|
|
Subject: AutoTeX[$id]: $subject |
45
|
|
|
|
|
|
|
EOM |
46
|
0
|
0
|
|
|
|
|
if ($reply_to) { |
47
|
0
|
|
|
|
|
|
print {$PIPEMAIL} "Reply-To: $reply_to\n"; |
|
0
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
} |
49
|
0
|
|
|
|
|
|
print {$PIPEMAIL} "\n\n", |
|
0
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$message; |
51
|
0
|
|
|
|
|
|
close $PIPEMAIL; |
52
|
0
|
|
|
|
|
|
return; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub send_failure { |
56
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
57
|
0
|
|
|
|
|
|
my $subject = shift; |
58
|
0
|
|
|
|
|
|
$subject = "$subject (mail_failure)"; |
59
|
0
|
|
|
|
|
|
return $self->send_notification($MAIL_FAILURES_ADDRESS, $subject, @_); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub send_tex_admin { |
63
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
64
|
0
|
|
|
|
|
|
my $subject = shift; |
65
|
0
|
|
|
|
|
|
$subject = "$subject (mail_tex_admin)"; |
66
|
0
|
|
|
|
|
|
return $self->send_notification($TEX_ADMIN_ADDRESS, $subject, @_); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |