| 1 | package Test::Smoke::Mailer::SendEmail; | ||||||||||||||||||||
| 2 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 3 | our $VERSION = '0.016'; | |||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 3 | ▶ | use base 'Test::Smoke::Mailer::Base'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | =head1 Test::Smoke::Mailer::SendEmail | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | This handles sending the message with the B<sendEmail> program. | ||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | =head2 Test::Smoke::Mailer::SendEmail->new( %args ) | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | Keys for C<%args>: | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | * ddir | ||||||||||||||||||||
| 20 | * mserver | ||||||||||||||||||||
| 21 | * msport | ||||||||||||||||||||
| 22 | * msuser | ||||||||||||||||||||
| 23 | * mspass | ||||||||||||||||||||
| 24 | * sendemailbin | ||||||||||||||||||||
| 25 | * to | ||||||||||||||||||||
| 26 | * from | ||||||||||||||||||||
| 27 | * cc | ||||||||||||||||||||
| 28 | * v | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | =cut | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | =head2 $mailer->mail( ) | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | C<mail()> sets up the commandline and body and passes it to the | ||||||||||||||||||||
| 35 | B<sendemail> program. | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | =cut | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 0 | ▶ | sub mail { | ||||||||||||||||||
|
Subroutine
mail: not called CC=15 SCAR=54.8
Pod
documented
| |||||||||||||||||||||
| 40 | 0 | my $self = shift; | |||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 0 | my $mailer = $self->{sendemailbin}; | |||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 0 | my $subject = $self->fetch_report(); | |||||||||||||||||||
| 45 | 0 | my $cc = $self->_get_cc( $subject ); | |||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 0 | my $cmdline = qq|$mailer -u "$subject"|; | |||||||||||||||||||
| 48 | 0 | ▶ | $self->{swcc} ||= '-cc', $cmdline .= qq| $self->{swcc} "$cc"| if $cc; | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$self->{"swcc"} ||= "-cc"
MC/DC0%0/1
$self->{"swcc"} ||= "-cc"
$self->{"swcc"}
Truth table0%0/2
A
A= $self->{"swcc"}
| |||||||||||||||||||||
| 49 | $self->{swbcc} ||= '-bcc', $cmdline .= qq| $self->{swbcc} "$self->{bcc}"| | ||||||||||||||||||||
| 50 | 0 | ▶ | if $self->{bcc}; | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$self->{"swbcc"} ||= "-bcc"
MC/DC0%0/1
$self->{"swbcc"} ||= "-bcc"
$self->{"swbcc"}
Truth table0%0/2
A
A= $self->{"swbcc"}
| |||||||||||||||||||||
| 51 | 0 | $cmdline .= qq| -t "$self->{to}"|; | |||||||||||||||||||
| 52 | 0 | ▶ | $cmdline .= qq| -f "$self->{from}"| if $self->{from}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 0 | ▶ | if ($self->{mserver}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 55 | 0 | my $mserver = $self->{mserver}; | |||||||||||||||||||
| 56 | 0 | ▶ | if ($self->{msport}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 57 | 0 | $mserver .= ":$self->{msport}"; | |||||||||||||||||||
| 58 | } | ||||||||||||||||||||
| 59 | 0 | $cmdline .= qq| -s "$mserver"|; | |||||||||||||||||||
| 60 | } | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 0 | ▶ | $cmdline .= qq| -xu "$self->{msuser}"| if $self->{msuser}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 63 | 0 | ▶ | $cmdline .= qq| -xp "$self->{mspass}"| if defined $self->{mspass}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 64 | 0 | $cmdline .= qq| -o message-file="$self->{file}"|; | |||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | 0 | ▶ | $self->{v} > 1 and print "[$cmdline]\n"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 67 | 0 | ▶ | $self->{v} and print "Sending report to $self->{to}\n"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 68 | 0 | system $cmdline; | |||||||||||||||||||
| 69 | 0 | ▶ | if ($?) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 70 | 0 | $self->{error} = "Error executing '$mailer': " . $?>>8; | |||||||||||||||||||
| 71 | } | ||||||||||||||||||||
| 72 | 0 | ▶ | $self->{v} and print $self->{error} ? "not OK\n" : "OK\n"; | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | 0 | return ! $self->{error}; | |||||||||||||||||||
| 75 | } | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | 3 | 1; | |||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | =head1 COPYRIGHT | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | (c) 2002-2013, All rights reserved. | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | * Abe Timmerman <abeltje@cpan.org> | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | This library is free software; you can redistribute it and/or modify | ||||||||||||||||||||
| 86 | it under the same terms as Perl itself. | ||||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | See: | ||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | * <http://www.perl.com/perl/misc/Artistic.html>, | ||||||||||||||||||||
| 91 | * <http://www.gnu.org/copyleft/gpl.html> | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | This program is distributed in the hope that it will be useful, | ||||||||||||||||||||
| 94 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||
| 95 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | =cut | ||||||||||||||||||||