| 1 | package Test::Smoke::Mailer::Mail_X; | ||||||||||||||||||||
| 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::Mail_X | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | This handles sending the message with either the B<mail> or B<mailx> program. | ||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | =head2 Test::Smoke::Mailer::Mail_X->new( %args ) | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | Keys for C<%args>: | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | * ddir | ||||||||||||||||||||
| 20 | * mailbin/mailxbin | ||||||||||||||||||||
| 21 | * to | ||||||||||||||||||||
| 22 | * cc | ||||||||||||||||||||
| 23 | * v | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | =cut | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | =head2 $mailer->mail( ) | ||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | C<mail()> sets up the commandline and body and pipes it to either the | ||||||||||||||||||||
| 30 | B<mail> or the B<mailx> program. | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | =cut | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 0 | ▶ | sub mail { | ||||||||||||||||||
|
Subroutine
mail: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||
| 35 | 0 | my $self = shift; | |||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 0 | ▶ | my $mailer = $self->{mailbin} || $self->{mailxbin}; | ||||||||||||||||||
|
Condition0%0/3
$self->{'mailbin'} || $self->{'mailxbin'}
MC/DC0%0/2
$self->{'mailbin'} || $self->{'mailxbin'}
$self->{'mailbin'}
$self->{'mailxbin'}
Truth table0%0/3
A || B
A= $self->{'mailbin'}B= $self->{'mailxbin'}
| |||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 0 | my $subject = $self->fetch_report(); | |||||||||||||||||||
| 40 | 0 | my $cc = $self->_get_cc( $subject ); | |||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 0 | my $cmdline = qq|$mailer -s '$subject'|; | |||||||||||||||||||
| 43 | 0 | ▶ | $self->{swcc} ||= '-c', $cmdline .= qq| $self->{swcc} '$cc'| if $cc; | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$self->{"swcc"} ||= "-c"
MC/DC0%0/1
$self->{"swcc"} ||= "-c"
$self->{"swcc"}
Truth table0%0/2
A
A= $self->{"swcc"}
| |||||||||||||||||||||
| 44 | $self->{swbcc} ||= '-b', $cmdline .= qq| $self->{swbcc} '$self->{bcc}'| | ||||||||||||||||||||
| 45 | 0 | ▶ | if $self->{bcc}; | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$self->{"swbcc"} ||= "-b"
MC/DC0%0/1
$self->{"swbcc"} ||= "-b"
$self->{"swbcc"}
Truth table0%0/2
A
A= $self->{"swbcc"}
| |||||||||||||||||||||
| 46 | 0 | $cmdline .= qq| $self->{to}|; | |||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 0 | ▶ | $self->{v} > 1 and print "[$cmdline]\n"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 49 | 0 | ▶ | $self->{v} and print "Sending report to $self->{to} "; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 50 | 0 | local *MAILER; | |||||||||||||||||||
| 51 | 0 | ▶ | if ( open MAILER, "| $cmdline " ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 52 | 0 | print MAILER $self->{body}; | |||||||||||||||||||
| 53 | close MAILER or | ||||||||||||||||||||
| 54 | 0 | ▶ | $self->{error} = "Error in pipe to '$mailer': $! (" . $?>>8 . ")"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 55 | } else { | ||||||||||||||||||||
| 56 | 0 | $self->{error} = "Cannot fork '$mailer': $!"; | |||||||||||||||||||
| 57 | } | ||||||||||||||||||||
| 58 | 0 | ▶ | $self->{v} and print $self->{error} ? "not OK\n" : "OK\n"; | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | 0 | return ! $self->{error}; | |||||||||||||||||||
| 61 | } | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | 3 | 1; | |||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | =head1 COPYRIGHT | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | (c) 2002-2013, All rights reserved. | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | * Abe Timmerman <abeltje@cpan.org> | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | This library is free software; you can redistribute it and/or modify | ||||||||||||||||||||
| 72 | it under the same terms as Perl itself. | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | See: | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | * <http://www.perl.com/perl/misc/Artistic.html>, | ||||||||||||||||||||
| 77 | * <http://www.gnu.org/copyleft/gpl.html> | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | This program is distributed in the hope that it will be useful, | ||||||||||||||||||||
| 80 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||
| 81 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | =cut | ||||||||||||||||||||