line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Nightly::Email; |
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
30406
|
use strict; |
|
10
|
|
|
|
|
26
|
|
|
10
|
|
|
|
|
392
|
|
4
|
10
|
|
|
10
|
|
53
|
use warnings; |
|
10
|
|
|
|
|
21
|
|
|
10
|
|
|
|
|
313
|
|
5
|
|
|
|
|
|
|
|
6
|
10
|
|
|
10
|
|
53
|
use Carp; |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
743
|
|
7
|
10
|
|
|
10
|
|
9930
|
use Email::Send; |
|
10
|
|
|
|
|
317043
|
|
|
10
|
|
|
|
|
76
|
|
8
|
10
|
|
|
10
|
|
508
|
use Email::Simple; |
|
10
|
|
|
|
|
21
|
|
|
10
|
|
|
|
|
273
|
|
9
|
10
|
|
|
10
|
|
61
|
use Email::Simple::Creator; |
|
10
|
|
|
|
|
22
|
|
|
10
|
|
|
|
|
255
|
|
10
|
|
|
|
|
|
|
|
11
|
10
|
|
|
10
|
|
56
|
use base qw(Test::Nightly::Base Class::Accessor::Fast); |
|
10
|
|
|
|
|
19
|
|
|
10
|
|
|
|
|
6990
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my @methods = qw( |
14
|
|
|
|
|
|
|
smtp_server |
15
|
|
|
|
|
|
|
to |
16
|
|
|
|
|
|
|
cc |
17
|
|
|
|
|
|
|
bcc |
18
|
|
|
|
|
|
|
from |
19
|
|
|
|
|
|
|
subject |
20
|
|
|
|
|
|
|
content_type |
21
|
|
|
|
|
|
|
mailer |
22
|
|
|
|
|
|
|
message |
23
|
|
|
|
|
|
|
smtp_server |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(@methods); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 NAME |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Test::Nightly::Email - Emails reports, errors etc. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 DESCRIPTION |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Package that uses the Email::* modules to mail reports and error notifications. Use this module to set up your email configuration. You probably should not be dealing with this directly. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 SYNOPSIS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $email = Test::Nightly::Email->new({ |
41
|
|
|
|
|
|
|
to => 'kirstinbettiol@gmail.com', |
42
|
|
|
|
|
|
|
}); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$email->send({ |
45
|
|
|
|
|
|
|
subject => 'Your Test Report', |
46
|
|
|
|
|
|
|
message => 'All your tests failed!' |
47
|
|
|
|
|
|
|
}); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 new() |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $email = Test::Nightly::Email->new({ |
54
|
|
|
|
|
|
|
to => 'kirstinbettiol@gmail.com', # Required |
55
|
|
|
|
|
|
|
cc => 'kirstinbettiol@gmail.com', |
56
|
|
|
|
|
|
|
bcc => 'kirstinbettiol@gmail.com', |
57
|
|
|
|
|
|
|
from => 'kirstinbettiol@gmail.com', |
58
|
|
|
|
|
|
|
subject => 'The results of your test', |
59
|
|
|
|
|
|
|
content_type => 'text/html', # Defaults 'text/html' |
60
|
|
|
|
|
|
|
mailer => 'Sendmail', # 'SMTP' || 'Qmail'. Defaults to 'Sendmail' |
61
|
|
|
|
|
|
|
message => 'The body of the email', |
62
|
|
|
|
|
|
|
smtp_server => 'smtp.yourserver.com', # Required if you specify SMTP as your mailer. |
63
|
|
|
|
|
|
|
}); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
The constructor to create the new email object. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub new { |
70
|
|
|
|
|
|
|
|
71
|
1
|
|
|
1
|
1
|
845
|
my ($class, $conf) = @_; |
72
|
|
|
|
|
|
|
|
73
|
1
|
|
|
|
|
4
|
my $self = bless {}, $class; |
74
|
|
|
|
|
|
|
|
75
|
1
|
|
|
|
|
11
|
$self->_init($conf, \@methods); |
76
|
|
|
|
|
|
|
|
77
|
1
|
|
|
|
|
4
|
return $self; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 send() |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
$email->send({ |
84
|
|
|
|
|
|
|
... takes the same arguments as new ... |
85
|
|
|
|
|
|
|
}); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Sends the email. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub email { |
92
|
|
|
|
|
|
|
|
93
|
1
|
|
|
1
|
0
|
8
|
my ($self, $conf) = @_; |
94
|
|
|
|
|
|
|
|
95
|
1
|
|
|
|
|
23
|
$self->_init($conf, \@methods); |
96
|
|
|
|
|
|
|
|
97
|
1
|
50
|
|
|
|
5
|
$self->content_type('text/html') unless defined $self->content_type(); |
98
|
1
|
50
|
|
|
|
17
|
$self->mailer('Sendmail') unless defined $self->mailer(); |
99
|
|
|
|
|
|
|
|
100
|
1
|
50
|
|
|
|
12
|
unless (defined $self->to()) { |
101
|
1
|
|
|
|
|
6
|
return; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
my %header = ( |
105
|
|
|
|
|
|
|
'To' => $self->to(), |
106
|
|
|
|
|
|
|
'Cc' => $self->cc(), |
107
|
|
|
|
|
|
|
'Bcc' => $self->bcc(), |
108
|
|
|
|
|
|
|
'From' => $self->from(), |
109
|
|
|
|
|
|
|
'Subject' => $self->subject(), |
110
|
|
|
|
|
|
|
'Content-Type' => $self->content_type(), |
111
|
|
|
|
|
|
|
); |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
my $email = Email::Simple->create( |
114
|
|
|
|
|
|
|
header => [%header], |
115
|
|
|
|
|
|
|
body => $self->message(), |
116
|
|
|
|
|
|
|
); |
117
|
|
|
|
|
|
|
|
118
|
0
|
0
|
|
|
|
|
if ($self->mailer() =~ /Sendmail/i) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
|
send Sendmail => $email; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
} elsif ($self->mailer() =~ /SMTP/i) { |
123
|
|
|
|
|
|
|
|
124
|
0
|
0
|
|
|
|
|
if (defined $self->smtp_server()) { |
125
|
|
|
|
|
|
|
|
126
|
0
|
|
|
|
|
|
send SMTP => $email, $self->smtp_server(); |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
} elsif ($self->mailer() =~ /Qmail/i) { |
131
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
send Qmail => $email; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 List of methods: |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=over 4 |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item to |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
The email "To" field. Takes a comma separated list of emails. Required. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item cc |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
The email "Cc" field. Takes a comma separated list of emails. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=item bcc |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
The email "Bcc" field. Takes a comma separated list of emails. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item from |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
The email "from" field. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=item subject |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
The subject line of the email |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item content_type |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
The Content-type you wish the email to be. Defaults to 'text/html'. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=item mailer |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
The mailer you wish to use. Currently supports 'Sendmail' || 'SMTP' || 'Qmail'. Defaults to 'Sendmail' |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=item message |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
The body of the email. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=item smtp_server |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
If you specify SMTP as your mailer then you are required to specify this. |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=back |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 AUTHOR |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
Kirstin Bettiol |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head1 COPYRIGHT |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
(c) 2005 Kirstin Bettiol |
187
|
|
|
|
|
|
|
This library is free software, you can use it under the same terms as perl itself. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 SEE ALSO |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
L, |
192
|
|
|
|
|
|
|
L, |
193
|
|
|
|
|
|
|
L, |
194
|
|
|
|
|
|
|
L, |
195
|
|
|
|
|
|
|
L, |
196
|
|
|
|
|
|
|
L, |
197
|
|
|
|
|
|
|
L, |
198
|
|
|
|
|
|
|
L, |
199
|
|
|
|
|
|
|
L, |
200
|
|
|
|
|
|
|
L, |
201
|
|
|
|
|
|
|
L. |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=cut |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
1; |
206
|
|
|
|
|
|
|
|