| 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::Mailx;{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 fault error/ ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | #-------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | sub init($) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | $args->{via} = 'mailx'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | $self->SUPER::init($args) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | $self->{MTM_program} = $args->{proxy} || $self->findBinary('mailx') || $self->findBinary('Mail') || $self->findBinary('mail') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$args->{'proxy'} || $self->findBinary('mailx') || $self->findBinary('Mail') || $self->findBinary('mail')
$args->{"proxy"} or $self->findBinary("mailx") or $self->findBinary("Mail")
$args->{"proxy"} or $self->findBinary("mailx")
MC/DC0%0/4
$args->{'proxy'} || $self->findBinary('mailx') || $self->findBinary('Mail') || $self->findBinary('mail')
$args->{"proxy"}
$self->findBinary("mailx")
$self->findBinary("Mail")
$self->findBinary('mail')
Truth table0%0/5
A or B or C || D
A= $args->{"proxy"}B= $self->findBinary("mailx")C= $self->findBinary("Mail")D= $self->findBinary('mail')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | or error __x"cannot find binary of mailx."; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | $self->{MTM_style} = $args->{style} // ( $^O =~ m/linux|freebsd|bsdos|netbsd|openbsd/ ? 'BSD' : 'RFC822' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$args->{"style"} // ($^O =~ /linux|freebsd|bsdos|netbsd|openbsd/ ? "BSD" : "RFC822")
MC/DC0%0/1
$args->{"style"} // ($^O =~ /linux|freebsd|bsdos|netbsd|openbsd/ ? "BSD" : "RFC822")
$args->{"style"}
Truth table0%0/2
A
A= $args->{"style"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | sub _try_send_bsdish($$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | { my ($self, $message, $args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_try_send_bsdish: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | my @options = ('-s' => $message->subject); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | { local $" = ','; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my @cc = map $_->format, $message->cc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | push @options, ('-c' => "@cc") if @cc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | my @bcc = map $_->format, $message->bcc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | push @options, ('-b' => "@bcc") if @bcc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | my @to = map $_->format, $message->to; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my $program = $self->{MTM_program}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my $mailer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | if((open $mailer, '|-')==0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | { close STDOUT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | { exec $program, @options, @to } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | fault __x"cannot open pipe to {program}", program => $program; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | $self->putContent($message, $mailer, body_only => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | $mailer->close | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | or fault __x"errors when closing Mailx mailer {program}", program => $program; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | sub trySend($@) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | { my ($self, $message, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trySend: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | return $self->_try_send_bsdish($message, \%args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if $self->{MTM_style} eq 'BSD'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | my $program = $self->{MTM_program}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | open my $mailer, '|-', $program, '-t' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | or fault __x"cannot open pipe to {program}", program => $program; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | $self->putContent($message, $mailer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | $mailer->close | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | or fault __x"errors when closing Mailx mailer {program}", program => $program; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||