| 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::Sendmail;{ | ||||||||||||||||||||||||||||
| 13 | 1 | our $VERSION = '4.01'; | |||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use parent 'Mail::Transport::Send'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use Log::Report 'mail-transport', import => [ qw/__x error fault warning/ ]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | #-------------------- | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | sub init($) | ||||||||||||||||||||||||||||
| 26 | 0 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
init: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | 0 | $args->{via} = 'sendmail'; | |||||||||||||||||||||||||||
| 28 | 0 | $self->SUPER::init($args); | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | ▶ | $self->{MTS_program} = $args->{proxy} || $self->findBinary('sendmail') or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args->{'proxy'} || $self->findBinary('sendmail')
MC/DC0%0/2
$args->{'proxy'} || $self->findBinary('sendmail')
$args->{'proxy'}
$self->findBinary('sendmail')
Truth table0%0/3
A || B
A= $args->{'proxy'}B= $self->findBinary('sendmail')
| |||||||||||||||||||||||||||||
| 31 | 0 | ▶ | $self->{MTS_opts} = $args->{sendmail_options} || []; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args->{'sendmail_options'} || []
MC/DC0%0/1
$args->{'sendmail_options'} || []
$args->{'sendmail_options'}
Truth table0%0/2
A
A= $args->{'sendmail_options'}
| |||||||||||||||||||||||||||||
| 32 | 0 | $self; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | #-------------------- | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | sub trySend($@) | ||||||||||||||||||||||||||||
| 38 | 0 | ▶ | { my ($self, $message, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
trySend: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 0 | my $program = $self->{MTS_program}; | |||||||||||||||||||||||||||
| 41 | 0 | my $mailer; | |||||||||||||||||||||||||||
| 42 | 0 | ▶ | if(open($mailer, '|-')==0) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | { # Child process is sendmail binary | ||||||||||||||||||||||||||||
| 44 | 0 | ▶ | my $options = $args{sendmail_options} || []; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args{'sendmail_options'} || []
MC/DC0%0/1
$args{'sendmail_options'} || []
$args{'sendmail_options'}
Truth table0%0/2
A
A= $args{'sendmail_options'}
| |||||||||||||||||||||||||||||
| 45 | 0 | my @to = map $_->address, $self->destinations($message, $args{to}); | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | # {} to avoid warning about code after exec | ||||||||||||||||||||||||||||
| 48 | 0 | { exec $program, '-i', @{$self->{MTS_opts}}, @$options, @to; } | |||||||||||||||||||||||||||
| 49 | 0 | fault __x"cannot open pipe to {program}", program => $program; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | # Parent process is the main program, still | ||||||||||||||||||||||||||||
| 53 | 0 | $self->putContent($message, $mailer, undisclosed => 1); | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | ▶ | $mailer->close | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | or fault __x"errors when closing sendmail mailer {program}", program => $program; | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | 1; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 1 | 1; | |||||||||||||||||||||||||||