line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Goo::SimpleEmailer; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# Nigel Hamilton |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Copyright Nigel Hamilton 1999 |
7
|
|
|
|
|
|
|
# All Rights Reserved |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Author: Nigel Hamilton |
10
|
|
|
|
|
|
|
# Filename: Goo::SimpleEmailer.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
|
|
|
|
|
|
|
# 28/10/2005 Added method: sendSMSEmail |
25
|
|
|
|
|
|
|
# |
26
|
|
|
|
|
|
|
############################################################################### |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
|
3871
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
199
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
############################################################################### |
32
|
|
|
|
|
|
|
# |
33
|
|
|
|
|
|
|
# send_email - send an email |
34
|
|
|
|
|
|
|
# |
35
|
|
|
|
|
|
|
############################################################################### |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub send_email { |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
0
|
1
|
|
my ($from, $to, $subject, $body) = @_; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# this talks to postfix on Mandrake |
42
|
0
|
|
|
|
|
|
open(EMAIL, "|/usr/sbin/sendmail -t"); |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
my $message = <<MESSAGE; |
45
|
|
|
|
|
|
|
From: $from |
46
|
|
|
|
|
|
|
To: $to |
47
|
|
|
|
|
|
|
Subject: $subject |
48
|
|
|
|
|
|
|
$body |
49
|
|
|
|
|
|
|
MESSAGE |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
print EMAIL $message; |
52
|
0
|
|
|
|
|
|
close(EMAIL); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
############################################################################### |
58
|
|
|
|
|
|
|
# |
59
|
|
|
|
|
|
|
# show_email - display the contents of the email to STDOUT, used for debugging |
60
|
|
|
|
|
|
|
# |
61
|
|
|
|
|
|
|
############################################################################### |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub show_email { |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
0
|
1
|
|
my ($from, $to, $subject, $body) = @_; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
print <<EMAIL; |
68
|
|
|
|
|
|
|
From: $from |
69
|
|
|
|
|
|
|
To: $to |
70
|
|
|
|
|
|
|
Subject: $subject |
71
|
|
|
|
|
|
|
$body |
72
|
|
|
|
|
|
|
EMAIL |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 NAME |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Goo::SimpleEmailer - Replace tokens in a file or a string and send an email |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 SYNOPSIS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
use Goo::SimpleEmailer; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 DESCRIPTION |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 METHODS |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=over |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item show_email |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
display the contents of the email to STDOUT, used for debugging |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item send_email |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
send an email |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=back |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 AUTHOR |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Nigel Hamilton <nigel@trexy.com> |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 SEE ALSO |
111
|
|
|
|
|
|
|
|