blib/lib/Siesta/Send/Sendmail.pm

filter: Statementstmt 17.3% 4 / 23 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 25.0% 1 / 4 Podpod 0.0% 0 / 3 totaltotal 9.6% 5 / 52 CC 9 SCAR 42.2
CC
9
Cov
10%
send
90.0
description
2.0
new
2.0
CRAP 67.9
↑ Summary bin/nacho »
1 # $Id: Sendmail.pm 1429 2003-10-16 16:39:28Z richardc $
2 package Siesta::Send::Sendmail;
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 0 ▶sub description { "Sends a mail using sendmail" };
Subroutine description: not called CC=1 SCAR=6.9
Pod undocumented
6  
7 =head1 NAME
8  
9 Siesta::Send::Sendmail - send a Siesta::Message using sendmail
10  
11 =head1 DESCRIPTION
12  
13 A extension to siesta that allows you to send mail using the local
14 sendmail executable.
15  
16 =head1 USAGE
17  
18 # This module should not really
19 # be used outside the siesta system
20  
21 my $sender = Siesta::Send::Sendmail->new();
22 my $mail = Siesta::Message->new(*\STDIN);
23 $sender->send($mail);
24  
25 =head1 SEE ALSO
26  
27 L<Siesta>, L<Siesta::Message> , L<Siesta::Send>
28  
29 =cut
30  
31 0 ▶sub new { bless {}, $_[0] }
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
32  
33 0 ▶sub send {
Subroutine send: not called CC=9 SCAR=45.0
Pod undocumented
34 0 my $self = shift;
35 0 my $message = shift;
36 0 my %args = @_;
37  
38 0 ▶ my $from = $args{'from'} || $message->from;
Condition0%0/3
$args{'from'} || $message->from
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{'from'} || $message->from
$args{'from'} $message->from
Truth table0%0/3
A || B
A= $args{'from'}B= $message->from
ABresult
1X1
011
000
39 0 ▶ my $to = $args{'to'} || ( $message->to )[0];
Condition0%0/3
$args{'to'} || ($message->to)[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{'to'} || ($message->to)[0]
$args{'to'} ($message->to)[0]
Truth table0%0/3
A || B
A= $args{'to'}B= ($message->to)[0]
ABresult
1X1
011
000
40 0 ▶ my @to = ref $to eq 'ARRAY' ? @$to : ( $to );
Branch: 1 branch
BranchTrueFalseTotal
ref $to eq 'ARRAY' ? : 0 0 0
41 0 ▶ return 1 unless @to; # guard against no recipients
Branch: 1 branch
BranchTrueFalseTotal
unless @to 0 0 0
42  
43 # according to MBM one shouldn't try and give sendmail more than
44 # about 80 recipients at the same time. And frankly, he should
45 # know.
46 0 my $sendmail_limit = 80;
47  
48 0 ▶ while (my @local = splice @to, 0, $sendmail_limit) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@local) = splice(@to, 0, $sendmail_limit)) 0 0 0
49 0 my $pid = open my $sendmail, '|-';
50 0 ▶ die "couldn't fork $!" unless defined $pid;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pid 0 0 0
51 0 ▶ unless ($pid) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pid) 0 0 0
52 0 exec '/usr/sbin/sendmail', '-oi', '-f', $from, @local;
53 0 die "exec failed $!";
54 }
55 0 print $sendmail $message->as_string;
56 0 ▶ close $sendmail
Branch: 1 branch
BranchTrueFalseTotal
close $sendmail or die "problem closing sendmail $! $?" 0 0 0
57 or die "problem closing sendmail $! $?";
58 }
59  
60 0 return 1;
61 }
62  
63 1 1;
↑ Summary bin/nacho »