| 1 | package Test::Smoke::Mailer::Sendmail; | ||||||||||||||||||||||||||||
| 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::Sendmail | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | This handles sending the message by piping it to the B<sendmail> program. | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | =head2 $mailer->mail( ) | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | C<mail()> sets up a header and body and pipes them to the B<sendmail> | ||||||||||||||||||||||||||||
| 18 | program. | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | =cut | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub mail { | ||||||||||||||||||||||||||
|
Subroutine
mail: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||
| 23 | 0 | 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 | ▶ | if exists $self->{from} && $self->{from}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $self->{"from"} and $self->{"from"}
MC/DC0%0/2
exists $self->{"from"} and $self->{"from"}
exists $self->{"from"}
$self->{"from"}
Truth table0%0/3
A and B
A= exists $self->{"from"}B= $self->{"from"}
| |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | $header .= "Cc: $cc\n" if $cc; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 0 | ▶ | $header .= "Bcc: $self->{bcc}\n" if $self->{bcc}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | 0 | $header .= "Subject: $subject\n\n"; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | ▶ | $self->{v} > 1 and print "[$self->{sendmailbin} -i -t]\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | $self->{v} and print "Sending report to $self->{to} "; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 0 | local *MAILER; | |||||||||||||||||||||||||||
| 37 | 0 | ▶ | if ( open MAILER, "| $self->{sendmailbin} -i -t " ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 0 | print MAILER $header, $self->{body}; | |||||||||||||||||||||||||||
| 39 | close MAILER or | ||||||||||||||||||||||||||||
| 40 | 0 | ▶ | $self->{error} = "Error in pipe to sendmail: $! (" . $?>>8 . ")"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | } else { | ||||||||||||||||||||||||||||
| 42 | 0 | $self->{error} = "Cannot fork ($self->{sendmailbin}): $!"; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | 0 | ▶ | $self->{v} and print $self->{error} ? "not OK\n" : "OK\n"; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 0 | return ! $self->{error}; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 3 | 1; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | (c) 2002-2013, All rights reserved. | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | * Abe Timmerman <abeltje@cpan.org> | ||||||||||||||||||||||||||||
| 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 | * <http://www.perl.com/perl/misc/Artistic.html>, | ||||||||||||||||||||||||||||
| 63 | * <http://www.gnu.org/copyleft/gpl.html> | ||||||||||||||||||||||||||||
| 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 | ||||||||||||||||||||||||||||