| 1 | # Copyrights 2001-2020 by [Mark Overmeer]. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # For other contributors see ChangeLog. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # See the manual pages for details on the licensing terms. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # Pod stripped from pm file by OODoc 2.02. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # This code is part of distribution Mail-Transport. Meta-POD processed with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # OODoc into POD and HTML manual-pages. See README.md | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | package Mail::Transport::Mailx; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | $VERSION = '3.005'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use base 'Mail::Transport::Send'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | sub init($) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | $args->{via} = 'mailx'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | $self->SUPER::init($args) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | $self->{MTM_program} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | = $args->{proxy} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | || $self->findBinary('mailx') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/11
$args->{'proxy'} || $self->findBinary('mailx') || $self->findBinary('Mail') || $self->findBinary('mail') || (return)
$args->{"proxy"} or $self->findBinary("mailx") or $self->findBinary("Mail") or $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') || (return)
$args->{"proxy"}
$self->findBinary("mailx")
$self->findBinary("Mail")
$self->findBinary("mail")
Truth table0%0/5
A or B or C or D
A= $args->{"proxy"}B= $self->findBinary("mailx")C= $self->findBinary("Mail")D= $self->findBinary("mail")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | || $self->findBinary('Mail') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | || $self->findBinary('mail') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | $self->{MTM_style} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | = defined $args->{style} ? $args->{style} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | : $^O =~ m/linux|freebsd|bsdos|netbsd|openbsd/ ? 'BSD' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | : 'RFC822'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | sub _try_send_bsdish($$) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | { my ($self, $message, $args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_try_send_bsdish: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | my @options = ('-s' => $message->subject); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | { local $" = ','; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | my @cc = map {$_->format} $message->cc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | push @options, ('-c' => "@cc") if @cc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my @bcc = map {$_->format} $message->bcc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | push @options, ('-b' => "@bcc") if @bcc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my @to = map {$_->format} $message->to; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my $program = $self->{MTM_program}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | if((open MAILER, '|-')==0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | { close STDOUT; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | { exec $program, @options, @to } | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | $self->log(NOTICE => "Cannot start contact to $program: $!"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | exit 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $self->putContent($message, \*MAILER, body_only => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | my $msgid = $message->messageId; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | if(close MAILER) { $self->log(PROGRESS => "Message $msgid send.") } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | { $self->log(ERROR => "Sending via mailx mailer $program failed: $! ($?)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | sub trySend($@) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | { my ($self, $message, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trySend: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | return $self->_try_send_bsdish($message, \%args) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | if $self->{MTM_style} eq 'BSD'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | my $program = $self->{MTM_program}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | unless(open MAILER, '|-', $program, '-t') | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | { $self->log(NOTICE => "Cannot start contact to $program: $!"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | $self->putContent($message, \*MAILER); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | unless(close MAILER) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | { $self->log(ERROR => "Sending via mailx mailer $program failed: $! ($?)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | #------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||