line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Goo::Emailer; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# Nigel Hamilton |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Copyright Nigel Hamilton 1999 |
7
|
|
|
|
|
|
|
# All Rights Reserved |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Author: Nigel Hamilton |
10
|
|
|
|
|
|
|
# Filename: Goo::Emailer.pm |
11
|
|
|
|
|
|
|
# Description: Replace tokens in a file or a string and send an email |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# Date Change |
14
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
15
|
|
|
|
|
|
|
# 04/03/1999 Version 1 |
16
|
|
|
|
|
|
|
# 10/05/2000 Version 2 - a more efficient slurping mode |
17
|
|
|
|
|
|
|
# 01/06/2002 Changed in big refactoring session |
18
|
|
|
|
|
|
|
# Replace changed to Template! |
19
|
|
|
|
|
|
|
# 14/08/2002 Email template |
20
|
|
|
|
|
|
|
# 25/05/2003 Added string email |
21
|
|
|
|
|
|
|
# 25/06/2003 Used WebDBLite |
22
|
|
|
|
|
|
|
# 24/10/2005 Converted into a very simple Goo-specific self-contained |
23
|
|
|
|
|
|
|
# emailer without templates |
24
|
|
|
|
|
|
|
# |
25
|
|
|
|
|
|
|
############################################################################### |
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
1
|
|
5901
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
185
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
############################################################################### |
30
|
|
|
|
|
|
|
# |
31
|
|
|
|
|
|
|
# send_email - send an email |
32
|
|
|
|
|
|
|
# |
33
|
|
|
|
|
|
|
############################################################################### |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub send_email { |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
0
|
1
|
|
my ($from, $to, $subject, $body) = @_; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# this talks to postfix on Mandrake |
40
|
0
|
|
|
|
|
|
open(EMAIL, "|/usr/sbin/sendmail -t"); |
41
|
0
|
|
|
|
|
|
print <<EMAIL; |
42
|
|
|
|
|
|
|
From: $from |
43
|
|
|
|
|
|
|
To: $to |
44
|
|
|
|
|
|
|
Subject: $subject |
45
|
|
|
|
|
|
|
$body |
46
|
|
|
|
|
|
|
EMAIL |
47
|
0
|
|
|
|
|
|
close(EMAIL); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
############################################################################### |
52
|
|
|
|
|
|
|
# |
53
|
|
|
|
|
|
|
# show_email - display the contents of the email to stdout, used for debugging |
54
|
|
|
|
|
|
|
# |
55
|
|
|
|
|
|
|
############################################################################### |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub show_email { |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
0
|
1
|
|
my ($from, $to, $subject, $body) = @_; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
print <<EMAIL; |
62
|
|
|
|
|
|
|
From: $from |
63
|
|
|
|
|
|
|
To: $to |
64
|
|
|
|
|
|
|
Subject: $subject |
65
|
|
|
|
|
|
|
$body |
66
|
|
|
|
|
|
|
EMAIL |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__ |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 NAME |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Goo::Emailer - Replace tokens in a file or a string and send an email |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 SYNOPSIS |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
use Goo::Emailer; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 DESCRIPTION |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 METHODS |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=over |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=item show_email |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
display the contents of the email to stdout, used for debugging |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item send_email |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
send an email |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=back |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 AUTHOR |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Nigel Hamilton <nigel@trexy.com> |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 SEE ALSO |
106
|
|
|
|
|
|
|
|