| 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; | ||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use vars '$VERSION'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | $VERSION = '3.005'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use base 'Mail::Reporter'; | ||||||||||||||||||||||||||
|
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 | |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 1 | my %mailers = | |||||||||||||||||||||||||||
| 23 | ( exim => '::Exim' | ||||||||||||||||||||||||||||
| 24 | , imap => '::IMAP4' | ||||||||||||||||||||||||||||
| 25 | , imap4 => '::IMAP4' | ||||||||||||||||||||||||||||
| 26 | , mail => '::Mailx' | ||||||||||||||||||||||||||||
| 27 | , mailx => '::Mailx' | ||||||||||||||||||||||||||||
| 28 | , pop => '::POP3' | ||||||||||||||||||||||||||||
| 29 | , pop3 => '::POP3' | ||||||||||||||||||||||||||||
| 30 | , postfix => '::Sendmail' | ||||||||||||||||||||||||||||
| 31 | , qmail => '::Qmail' | ||||||||||||||||||||||||||||
| 32 | , sendmail => '::Sendmail' | ||||||||||||||||||||||||||||
| 33 | , smtp => '::SMTP' | ||||||||||||||||||||||||||||
| 34 | ); | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | sub new(@) | ||||||||||||||||||||||||||||
| 38 | 0 | ▶ | { my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | return $class->SUPER::new(@_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$class eq __PACKAGE__ or $class eq "Mail::Transport::Send"
MC/DC0%0/2
$class eq __PACKAGE__ or $class eq "Mail::Transport::Send"
$class eq __PACKAGE__
$class eq "Mail::Transport::Send"
Truth table0%0/3
A or B
A= $class eq __PACKAGE__B= $class eq "Mail::Transport::Send"
| |||||||||||||||||||||||||||||
| 41 | unless $class eq __PACKAGE__ || $class eq "Mail::Transport::Send"; | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | # | ||||||||||||||||||||||||||||
| 44 | # auto restart by creating the right transporter. | ||||||||||||||||||||||||||||
| 45 | # | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | my %args = @_; | |||||||||||||||||||||||||||
| 48 | 0 | ▶ | my $via = lc($args{via} || '') | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$args{'via'} || ''
MC/DC0%0/1
$args{'via'} || ''
$args{'via'}
Truth table0%0/2
A
A= $args{'via'}
| |||||||||||||||||||||||||||||
| 49 | or croak "No transport protocol provided"; | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | $via = 'Mail::Transport'.$mailers{$via} | ||||||||||||||||||||||||||||
| 52 | 0 | ▶ | if exists $mailers{$via}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 0 | eval "require $via"; | |||||||||||||||||||||||||||
| 55 | 0 | ▶ | return undef if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | $via->new(@_); | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | sub init($) | ||||||||||||||||||||||||||||
| 61 | 0 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
init: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 0 | $self->SUPER::init($args); | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | $self->{MT_hostname} | ||||||||||||||||||||||||||||
| 66 | 0 | ▶ | = defined $args->{hostname} ? $args->{hostname} : 'localhost'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | $self->{MT_port} = $args->{port}; | |||||||||||||||||||||||||||
| 69 | 0 | $self->{MT_username} = $args->{username}; | |||||||||||||||||||||||||||
| 70 | 0 | $self->{MT_password} = $args->{password}; | |||||||||||||||||||||||||||
| 71 | 0 | ▶ | $self->{MT_interval} = $args->{interval} || 30; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args->{'interval'} || 30
MC/DC0%0/1
$args->{'interval'} || 30
$args->{'interval'}
Truth table0%0/2
A
A= $args->{'interval'}
| |||||||||||||||||||||||||||||
| 72 | 0 | ▶ | $self->{MT_retry} = $args->{retry} || -1; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args->{'retry'} || -1
MC/DC0%0/1
$args->{'retry'} || -1
$args->{'retry'}
Truth table0%0/2
A
A= $args->{'retry'}
| |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | $self->{MT_timeout} = $args->{timeout} || 120; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args->{'timeout'} || 120
MC/DC0%0/1
$args->{'timeout'} || 120
$args->{'timeout'}
Truth table0%0/2
A
A= $args->{'timeout'}
| |||||||||||||||||||||||||||||
| 74 | 0 | $self->{MT_proxy} = $args->{proxy}; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | ▶ | if(my $exec = $args->{executable} || $args->{proxy}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args->{'executable'} || $args->{'proxy'}
MC/DC0%0/2
$args->{'executable'} || $args->{'proxy'}
$args->{'executable'}
$args->{'proxy'}
Truth table0%0/3
A || B
A= $args->{'executable'}B= $args->{'proxy'}
| |||||||||||||||||||||||||||||
| 77 | 0 | { $self->{MT_exec} = $exec; | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | ▶ | $self->log(WARNING => "Avoid program abuse: specify an absolute path for $exec.") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | unless File::Spec->file_name_is_absolute($exec); | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 0 | ▶ | unless(-x $exec) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | 0 | { $self->log(WARNING => "Executable $exec does not exist."); | |||||||||||||||||||||||||||
| 84 | 0 | return undef; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 0 | $self; | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | #------------------------------------------ | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | sub remoteHost() | ||||||||||||||||||||||||||||
| 94 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
remoteHost: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 95 | 0 | @$self{ qw/MT_hostname MT_port MT_username MT_password/ }; | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | sub retry() | ||||||||||||||||||||||||||||
| 100 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
retry: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 101 | 0 | @$self{ qw/MT_interval MT_retry MT_timeout/ }; | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | my @safe_directories | ||||||||||||||||||||||||||||
| 106 | 1 | = qw(/usr/local/bin /usr/bin /bin /sbin /usr/sbin /usr/lib); | |||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | sub findBinary($@) | ||||||||||||||||||||||||||||
| 109 | 0 | ▶ | { my ($self, $name) = (shift, shift); | ||||||||||||||||||||||||||
|
Subroutine
findBinary: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | return $self->{MT_exec} | ||||||||||||||||||||||||||||
| 112 | 0 | ▶ | if exists $self->{MT_exec}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 0 | foreach (@_, @safe_directories) | |||||||||||||||||||||||||||
| 115 | 0 | { my $fullname = File::Spec->catfile($_, $name); | |||||||||||||||||||||||||||
| 116 | 0 | ▶ | return $fullname if -x $fullname; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 0 | undef; | |||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | #------------------------------------------ | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 1 | 1; | |||||||||||||||||||||||||||