| 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::Send;{ | ||||||||||||||||||||||||||||||||
| 13 | 1 | our $VERSION = '4.01'; | |||||||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use parent 'Mail::Transport'; | ||||||||||||||||||||||||||||||
|
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 warning/ ]; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use File::Spec (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use Errno 'EAGAIN'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||
| 26 | #-------------------- | ||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||
| 28 | sub new(@) | ||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | { my $class = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | $class eq __PACKAGE__ or return $class->SUPER::new(@_); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | 0 | require Mail::Transport::Sendmail; | |||||||||||||||||||||||||||||||
| 33 | 0 | Mail::Transport::Sendmail->new(@_); | |||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||
| 36 | #-------------------- | ||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | sub send($@) | ||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | { my ($self, $message, %args) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
send: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | $message = Mail::Message->coerce($message) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 42 | unless $message->isa('Mail::Message'); | ||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | $self->trySend($message, %args) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 45 | and return 1; | ||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | $?==EAGAIN | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 48 | or return 0; | ||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||
| 50 | 0 | my ($interval, $retry) = $self->retry; | |||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | $interval = $args{interval} if exists $args{interval}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | $retry = $args{retry} if exists $args{retry}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | while($retry!=0) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 55 | 0 | { sleep $interval; | |||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | return 1 if $self->trySend($message, %args); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | $?==EAGAIN or return 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 58 | 0 | $retry--; | |||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||
| 61 | 0 | 0; | |||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||
| 65 | sub trySend($@) | ||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
trySend: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 67 | 0 | error __x"transporters of type {class} cannot send.", class => ref $self; | |||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||
| 71 | sub putContent($$@) | ||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | { my ($self, $message, $fh, %args) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
putContent: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | if($args{body_only}) { $message->body->print($fh) } | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 75 | 0 | elsif($args{undisclosed}) { $message->Mail::Message::print($fh) } | |||||||||||||||||||||||||||||||
| 76 | else | ||||||||||||||||||||||||||||||||
| 77 | 0 | { $message->head->printUndisclosed($fh); | |||||||||||||||||||||||||||||||
| 78 | 0 | $message->body->print($fh); | |||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||
| 81 | 0 | $self; | |||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||
| 86 | sub destinations($;$) | ||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | { my ($self, $message, $overrule) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
destinations: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 88 | 0 | my @to; | |||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | if(defined $overrule) # Destinations overruled by user. | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | { @to = map { ref $_ && $_->isa('Mail::Address') ? ($_) : Mail::Address->parse($_) } | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
ref $_ and $_->isa("Mail::Address")
MC/DC0%0/2
ref $_ and $_->isa("Mail::Address")
ref $_
$_->isa("Mail::Address")
Truth table0%0/3
A and B
A= ref $_B= $_->isa("Mail::Address")
| |||||||||||||||||||||||||||||||||
| 92 | ref $overrule eq 'ARRAY' ? @$overrule : ($overrule); | ||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||
| 94 | elsif(my @rgs = $message->head->resentGroups) | ||||||||||||||||||||||||||||||||
| 95 | { # Create with bounce | ||||||||||||||||||||||||||||||||
| 96 | 0 | @to = $rgs[0]->destinations; | |||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | @to or warning(__x"resent group does not specify a destination."), return (); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||
| 99 | else | ||||||||||||||||||||||||||||||||
| 100 | 0 | { @to = $message->destinations; | |||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | @to or warning(__x"message has no destination."), return (); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||
| 104 | 0 | @to; | |||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||
| 107 | #-------------------- | ||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||
| 109 | 1 | 1; | |||||||||||||||||||||||||||||||