line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2001-2019 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
|
|
|
1
|
|
719
|
use vars '$VERSION'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
11
|
|
|
|
|
|
|
$VERSION = '3.004'; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
5
|
use base 'Mail::Transport::Send'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
92
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
16
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
576
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub init($) |
22
|
0
|
|
|
0
|
0
|
|
{ my ($self, $args) = @_; |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
$args->{via} = 'mailx'; |
25
|
|
|
|
|
|
|
|
26
|
0
|
0
|
|
|
|
|
$self->SUPER::init($args) or return; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
$self->{MTM_program} |
29
|
|
|
|
|
|
|
= $args->{proxy} |
30
|
0
|
|
0
|
|
|
|
|| $self->findBinary('mailx') |
31
|
|
|
|
|
|
|
|| $self->findBinary('Mail') |
32
|
|
|
|
|
|
|
|| $self->findBinary('mail') |
33
|
|
|
|
|
|
|
|| return; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
$self->{MTM_style} |
36
|
|
|
|
|
|
|
= defined $args->{style} ? $args->{style} |
37
|
0
|
0
|
|
|
|
|
: $^O =~ m/linux|freebsd|bsdos|netbsd|openbsd/ ? 'BSD' |
|
|
0
|
|
|
|
|
|
38
|
|
|
|
|
|
|
: 'RFC822'; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
$self; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
#------------------------------------------ |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _try_send_bsdish($$) |
47
|
0
|
|
|
0
|
|
|
{ my ($self, $message, $args) = @_; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my @options = ('-s' => $message->subject); |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
{ local $" = ','; |
|
0
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my @cc = map {$_->format} $message->cc; |
|
0
|
|
|
|
|
|
|
53
|
0
|
0
|
|
|
|
|
push @options, ('-c' => "@cc") if @cc; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my @bcc = map {$_->format} $message->bcc; |
|
0
|
|
|
|
|
|
|
56
|
0
|
0
|
|
|
|
|
push @options, ('-b' => "@bcc") if @bcc; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my @to = map {$_->format} $message->to; |
|
0
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
my $program = $self->{MTM_program}; |
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
if((open MAILER, '|-')==0) |
63
|
0
|
|
|
|
|
|
{ close STDOUT; |
64
|
0
|
|
|
|
|
|
{ exec $program, @options, @to } |
|
0
|
|
|
|
|
|
|
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
|
0
|
|
|
|
|
if(close MAILER) { $self->log(PROGRESS => "Message $msgid send.") } |
|
0
|
|
|
|
|
|
|
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
|
|
|
0
|
1
|
|
{ my ($self, $message, %args) = @_; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
return $self->_try_send_bsdish($message, \%args) |
86
|
0
|
0
|
|
|
|
|
if $self->{MTM_style} eq 'BSD'; |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
my $program = $self->{MTM_program}; |
89
|
0
|
0
|
|
|
|
|
unless(open MAILER, '|-', $program, '-t') |
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
|
0
|
|
|
|
|
unless(close MAILER) |
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; |