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