File Coverage

blib/lib/Mail/Transport/Qmail.pm
Criterion Covered Total %
statement 12 27 44.4
branch 0 6 0.0
condition 0 3 0.0
subroutine 4 6 66.6
pod 1 2 50.0
total 17 44 38.6


line stmt bran cond sub pod time code
1             # This code is part of Perl distribution Mail-Transport version 4.01.
2             # The POD got stripped from this file by OODoc version 3.05.
3             # For contributors see file ChangeLog.
4              
5             # This software is copyright (c) 2001-2025 by Mark Overmeer.
6              
7             # This is free software; you can redistribute it and/or modify it under
8             # the same terms as the Perl 5 programming language system itself.
9             # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
10              
11              
12             package Mail::Transport::Qmail;{
13             our $VERSION = '4.01';
14             }
15              
16 1     1   1377 use parent 'Mail::Transport::Send';
  1         2  
  1         6  
17              
18 1     1   71 use strict;
  1         2  
  1         16  
19 1     1   28 use warnings;
  1         3  
  1         59  
20              
21 1     1   4 use Log::Report 'mail-transport', import => [ qw/__x error fault/ ];
  1         2  
  1         8  
22              
23             #--------------------
24              
25             sub init($)
26 0     0 0   { my ($self, $args) = @_;
27 0           $args->{via} = 'qmail';
28 0           $self->SUPER::init($args);
29              
30 0 0 0       $self->{MTM_program} = $args->{proxy} || $self->findBinary('qmail-inject', '/var/qmail/bin') or return;
31 0           $self;
32             }
33              
34              
35             sub trySend($@)
36 0     0 1   { my ($self, $message, %args) = @_;
37              
38 0           my $program = $self->{MTM_program};
39 0           my $mailer;
40 0 0         if(open($mailer, '|-')==0)
41 0           { { exec $program; }
  0            
42 0           fault __x"cannot open pipe to {program}.", program => $program;
43             }
44              
45 0           $self->putContent($message, $mailer, undisclosed => 1);
46              
47 0 0         $mailer->close
48             or fault __x"errors when closing Qmail mailer {program}", program => $program;
49              
50 0           1;
51             }
52              
53             1;