| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Test::Smoke::Mailer::Sendmail; |
|
2
|
3
|
|
|
3
|
|
21
|
use warnings; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
97
|
|
|
3
|
3
|
|
|
3
|
|
22
|
use strict; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
120
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.016'; |
|
6
|
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
16
|
use base 'Test::Smoke::Mailer::Base'; |
|
|
3
|
|
|
|
|
18
|
|
|
|
3
|
|
|
|
|
1375
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 Test::Smoke::Mailer::Sendmail |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
This handles sending the message by piping it to the B program. |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head2 $mailer->mail( ) |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
C sets up a header and body and pipes them to the B |
|
18
|
|
|
|
|
|
|
program. |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub mail { |
|
23
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
24
|
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
my $subject = $self->fetch_report(); |
|
26
|
0
|
|
|
|
|
|
my $cc = $self->_get_cc( $subject ); |
|
27
|
0
|
|
|
|
|
|
my $header = "To: $self->{to}\n"; |
|
28
|
|
|
|
|
|
|
$header .= "From: $self->{from}\n" |
|
29
|
0
|
0
|
0
|
|
|
|
if exists $self->{from} && $self->{from}; |
|
30
|
0
|
0
|
|
|
|
|
$header .= "Cc: $cc\n" if $cc; |
|
31
|
0
|
0
|
|
|
|
|
$header .= "Bcc: $self->{bcc}\n" if $self->{bcc}; |
|
32
|
0
|
|
|
|
|
|
$header .= "Subject: $subject\n\n"; |
|
33
|
|
|
|
|
|
|
|
|
34
|
0
|
0
|
|
|
|
|
$self->{v} > 1 and print "[$self->{sendmailbin} -i -t]\n"; |
|
35
|
0
|
0
|
|
|
|
|
$self->{v} and print "Sending report to $self->{to} "; |
|
36
|
0
|
|
|
|
|
|
local *MAILER; |
|
37
|
0
|
0
|
|
|
|
|
if ( open MAILER, "| $self->{sendmailbin} -i -t " ) { |
|
38
|
0
|
|
|
|
|
|
print MAILER $header, $self->{body}; |
|
39
|
|
|
|
|
|
|
close MAILER or |
|
40
|
0
|
0
|
|
|
|
|
$self->{error} = "Error in pipe to sendmail: $! (" . $?>>8 . ")"; |
|
41
|
|
|
|
|
|
|
} else { |
|
42
|
0
|
|
|
|
|
|
$self->{error} = "Cannot fork ($self->{sendmailbin}): $!"; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
0
|
0
|
|
|
|
|
$self->{v} and print $self->{error} ? "not OK\n" : "OK\n"; |
|
|
|
0
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
return ! $self->{error}; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
(c) 2002-2013, All rights reserved. |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
* Abe Timmerman |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
58
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
See: |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
* , |
|
63
|
|
|
|
|
|
|
* |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
|
66
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
67
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |