Sender.pm

filter: Statementstmt 24.4% 316 / 1293 Branchbran 9.8% 74 / 748 Conditioncond 15.7% 61 / 387 MC/DCmcdc 12.5% 28 / 223 Subroutinesub 58.0% 58 / 100 Podpod 71.0% 27 / 38 totaltotal 20.2% 564 / 2789 CC 533 SCAR 80.5
CC
533
Cov
19%
Open
10302.0
OpenMultipart
8556.0
SendFile
1260.0
CRAP 3131.6
↑ Summary Sender/CType/Ext.pm »
1 package Mail::Sender;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Encode ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use File::Basename ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use IO::Socket::INET ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use MIME::Base64 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use MIME::QuotedPrint ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use Socket ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use Time::Local ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 2 our @EXPORT = qw();
18 2 our @EXPORT_OK = qw(GuessCType);
19  
20 2 our $VERSION = '0.903'; # VERSION
21 2 $VERSION = eval $VERSION;
22  
23 2 warnings::warnif('deprecated', 'Mail::Sender is deprecated and you should look to Email::Sender instead');
24  
25 2 our $GMTdiff;
26 2 our $Error;
27 2 our %default; # loaded in from our config files
28 2 our $MD5_loaded = 0;
29 2 our $debug = 0;
30 2 our %CTypes = (
31 GIF => 'image/gif',
32 JPE => 'image/jpeg',
33 JPEG => 'image/jpeg',
34 SHTML => 'text/html',
35 SHTM => 'text/html',
36 HTML => 'text/html',
37 HTM => 'text/html',
38 TXT => 'text/plain',
39 INI => 'text/plain',
40 DOC => 'application/x-msword',
41 EML => 'message/rfc822',
42 );
43 2 our @Errors = (
44 'OK',
45 'Unknown encoding',
46 'TLS unsupported by server',
47 'TLS unsupported by script',
48 'IO::SOCKET::SSL failed',
49 'STARTTLS failed',
50 'debug file cannot be opened',
51 'file cannot be read',
52 'all recipients have been rejected',
53 'authentication protocol is not implemented',
54 'login not accepted',
55 'authentication protocol not accepted by the server',
56 'no From: address specified',
57 'no SMTP server specified',
58 'connection not established. Did you mean MailFile instead of SendFile?',
59 'site specific error',
60 'not available in singlepart mode',
61 'file not found',
62 'no file name specified in call to MailFile or SendFile',
63 'no message specified in call to MailMsg or MailFile',
64 'argument $to empty',
65 'transmission of message failed',
66 'local user $to unknown on host $smtp',
67 'unspecified communication error',
68 'service not available',
69 'connect() failed',
70 'socket() failed',
71 '$smtphost unknown'
72 );
73  
74 # if you do not use MailFile or SendFile and only send 7BIT or 8BIT "encoded"
75 # messages you may comment out these lines.
76 #MIME::Base64 and MIME::QuotedPrint may be found at CPAN.
77  
78 2 my $TLS_notsupported;
79  
80 2 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=7.0
81 eval <<'END'
82 use IO::Socket::SSL;# qw(debug4);
83 use Net::SSLeay;
84 1;
85 END
86 2 ▶ or $TLS_notsupported = $@;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
eval " use IO::Socket::SSL;# qw(debug4);\n use Net::SSLeay;\n 1;\n" or $TLS_notsupported = $@ 2 0 2
87 }
88  
89 # include config file and libraries when packaging the script
90 2 if (0) {
91 require 'Mail/Sender.config'; # local configuration
92 require 'Symbol.pm'; # for debuging and GetHandle() method
93 require 'Tie/Handle.pm'; # for debuging and GetHandle() method
94 require 'IO/Handle.pm'; # for debuging and GetHandle() method
95 require 'Digest/HMAC_MD5.pm'; # for CRAM-MD5 authentication only
96 require 'Authen/NTLM.pm'; # for NTLM authentication only
97 } # this block above is there to let PAR, PerlApp, PerlCtrl, PerlSvc and Perl2Exe know I may need those files.
98  
99 2 ▶BEGIN {
Subroutine BEGIN: called CC=6 SCAR=26.8
100 2 my $config = $INC{'Mail/Sender.pm'};
101 2 ▶ die
Branch: 1 branch
BranchTrueFalseTotal
unless $config 0 2 2
102 "Wrong case in use statement or Mail::Sender module renamed. Perl is case sensitive!!!\n"
103 unless $config;
104 2 my $compiled = !(-e $config)
105 ; # if the module was not read from disk => the script has been "compiled"
106 2 $config =~ s/\.pm$/.config/;
107 2 ▶ if ($compiled or -e $config) {
Branch: 1 branch
BranchTrueFalseTotal
if ($compiled or -e $config) 0 2 2
Condition33%1/3
$compiled or -e $config
l!l&&r!l&&!r
002
MC/DC0%0/2
$compiled or -e $config
$compiled -e $config
Truth table33%1/3
A or B
A= $compiledB= -e $config
ABresult
1X1
011
000
108  
109 # in a Perl2Exe or PerlApp created executable or PerlCtrl generated COM object
110 # or the config is known to exist
111 0 eval { require $config };
112 0 ▶ if ($@ and $@ !~ /Can't locate /) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@ and not $@ =~ /Can't locate /) 0 0 0
Condition0%0/3
$@ and not $@ =~ /Can't locate /
!ll&&!rl&&r
000
MC/DC0%0/2
$@ and not $@ =~ /Can't locate /
$@ not $@ =~ /Can't locate /
Truth table0%0/3
A and not(B)
A= $@B= not $@ =~ /Can't locate /
ABresult
0X0
100
111
113 0 print STDERR "Error in Mail::Sender.config : $@";
114 }
115 }
116 }
117  
118 #local IP address and name
119 my $local_name
120 2 ▶ = $ENV{HOSTNAME} || $ENV{HTTP_HOST} || (gethostbyname 'localhost')[0];
Condition33%2/6
$ENV{'HOSTNAME'} || $ENV{'HTTP_HOST'} || (gethostbyname 'localhost')[0]
l!l&&r!l&&!r
200
$ENV{"HOSTNAME"} or $ENV{"HTTP_HOST"}
l!l&&r!l&&!r
200
MC/DC0%0/3
$ENV{'HOSTNAME'} || $ENV{'HTTP_HOST'} || (gethostbyname 'localhost')[0]
$ENV{"HOSTNAME"} $ENV{"HTTP_HOST"} (gethostbyname 'localhost')[0]
Truth table25%1/4
A or B || C
A= $ENV{"HOSTNAME"}B= $ENV{"HTTP_HOST"}C= (gethostbyname 'localhost')[0]
ABCresult
1XX1
01X1
0011
0000
121 2 $local_name
122 =~ s/:.*$//; # the HTTP_HOST may be set to something like "foo.bar.com:1000"
123 2 my $local_IP = join('.', unpack('CCCC', (gethostbyname $local_name)[4]));
124  
125 #time diference to GMT - Windows will not set $ENV{'TZ'}, if you know a better way ...
126  
127 3 ▶sub ResetGMTdiff {
Subroutine ResetGMTdiff: called CC=1 SCAR=0.0
Pod documented
128 3 my $local = time;
129 3 my $gm = Time::Local::timelocal(gmtime $local);
130 3 my $sign = qw( + + - ) [$local <=> $gm];
131 3 $GMTdiff = sprintf "%s%02d%02d", $sign, (gmtime abs($local - $gm))[2, 1];
132 3 return $GMTdiff;
133 }
134 2 ResetGMTdiff();
135  
136 #
137 my @priority
138 2 = ('', '1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)');
139  
140 #data encoding
141 2 my $chunksize = 1024 * 4;
142 2 my $chunksize64 = 71 * 57; # must be divisible by 57 !
143 2 my $enc_base64_chunk = 57;
144  
145 2 ▶sub enc_base64 {
Subroutine enc_base64: called CC=2 SCAR=9.2
Pod undocumented
146 2 ▶ if ($_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0]) { } 1 1 2
147 1 my $charset = $_[0];
148 0 ▶ return sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
149 0 my $s
150 = MIME::Base64::encode_base64(Encode::encode($charset, $_[0]));
151 0 $s =~ s/\x0A/\x0D\x0A/sg;
152 0 return $s;
153 }
154 1 }
155 else {
156 0 ▶ return sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
157 0 my $s = MIME::Base64::encode_base64($_[0]);
158 0 $s =~ s/\x0A/\x0D\x0A/sg;
159 0 return $s;
160 }
161 1 }
162 }
163  
164 2 ▶sub enc_qp {
Subroutine enc_qp: called CC=2 SCAR=11.6
Pod undocumented
165 2 ▶ if ($_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0]) { } 1 1 2
166 1 my $charset = $_[0];
167 0 ▶ return sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
168 0 my $s = Encode::encode($charset, $_[0]);
169 0 $s =~ s/\x0D\x0A/\n/g;
170 0 $s = MIME::QuotedPrint::encode_qp($s);
171 0 $s =~ s/^\./../gm;
172 0 $s =~ s/\x0A/\x0D\x0A/sg;
173 0 return $s;
174 }
175 1 }
176 else {
177 0 ▶ return sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
178 0 my $s = $_[0];
179 0 $s =~ s/\x0D\x0A/\n/g;
180 0 $s = MIME::QuotedPrint::encode_qp($s);
181 0 $s =~ s/^\./../gm;
182 0 $s =~ s/\x0A/\x0D\x0A/sg;
183 0 return $s;
184 }
185 1 }
186 }
187  
188 2 ▶sub enc_plain {
Subroutine enc_plain: called CC=2 SCAR=10.1
Pod undocumented
189 2 ▶ if ($_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0]) { } 1 1 2
190 1 my $charset = $_[0];
191 0 ▶ return sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
192 0 my $s = Encode::encode($charset, $_[0]);
193 0 $s =~ s/^\./../gm;
194 0 $s =~ s/(?:\x0D\x0A?|\x0A)/\x0D\x0A/sg;
195 0 return $s;
196 }
197 1 }
198 else {
199 0 ▶ return sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
200 0 my $s = $_[0];
201 0 $s =~ s/^\./../gm;
202 0 $s =~ s/(?:\x0D\x0A?|\x0A)/\x0D\x0A/sg;
203 0 return $s;
204 }
205 1 }
206 }
207  
208 9 ▶sub enc_xtext {
Subroutine enc_xtext: called CC=1 SCAR=0.2
Pod undocumented
209 9 my $input = shift;
210 0 $input =~ s/([^!-*,-<>-~])/'+'.uc(unpack('H*', $1))/eg;
211 9 return $input;
212 }
213  
214 {
215 2 my $username;
216  
217 2 ▶ sub getusername () {
Subroutine getusername: called CC=4 SCAR=15.6
Pod undocumented
218 2 ▶ return $username if defined($username);
Branch: 1 branch
BranchTrueFalseTotal
if defined $username 1 1 2
219 1 ▶ return $username = eval { getlogin || getpwuid($<) } || $ENV{USERNAME};
Condition33%2/6
eval { do { getlogin or getpwuid $< } } || $ENV{'USERNAME'}
l!l&&r!l&&!r
100
getlogin || getpwuid $<
l!l&&r!l&&!r
010
MC/DC0%0/2
eval { do { getlogin or getpwuid $< } } || $ENV{'USERNAME'}
eval { do { getlogin or getpwuid $< } } $ENV{'USERNAME'}
MC/DC0%0/2
getlogin || getpwuid $<
getlogin getpwuid $<
Truth table33%1/3
A || B
A= eval { do { getlogin or getpwuid $< } }B= $ENV{'USERNAME'}
ABresult
1X1
011
000
Truth table33%1/3
A || B
A= getloginB= getpwuid $<
ABresult
1X1
011
000
220 }
221 }
222  
223 #IO
224  
225 #reads the whole SMTP response
226 # converts
227 # nnn-very
228 # nnn-long
229 # nnn message
230 # to
231 # nnn very
232 # long
233 # message
234 2 ▶sub get_response ($) {
Subroutine get_response: not called CC=3 SCAR=23.4
Pod undocumented
235 0 my $s = shift;
236 0 my $res = <$s>;
237 0 ▶ if ($res =~ s/^(\d\d\d)-/$1 /) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res =~ s/^(\d\d\d)-/$1 /) 0 0 0
238 0 my $nextline = <$s>;
239 0 ▶ while ($nextline =~ s/^\d\d\d-//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nextline =~ s/^\d\d\d-//) 0 0 0
240 0 $res .= $nextline;
241 0 $nextline = <$s>;
242 }
243 0 $nextline =~ s/^\d\d\d //;
244 0 $res .= $nextline;
245 }
246 0 $Mail::Sender::LastResponse = $res;
247 0 return $res;
248 }
249  
250 0 ▶sub send_cmd ($$) {
Subroutine send_cmd: not called CC=2 SCAR=17.9
Pod undocumented
251 0 my ($s, $cmd) = @_;
252 0 chomp $cmd;
253 0 ▶ if ($s->opened()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s->opened) { } 0 0 0
254 0 print $s "$cmd\x0D\x0A";
255 0 get_response($s);
256 }
257 else {
258 0 return '400 connection lost';
259 }
260 }
261  
262 0 ▶sub _print_hdr {
Subroutine _print_hdr: not called CC=11 SCAR=48.8
263 0 my ($s, $hdr, $str, $charset) = @_;
264 0 ▶ return if !defined $str or $str eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $str or $str eq "" 0 0 0
Condition0%0/3
not defined $str or $str eq ""
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $str or $str eq ""
not defined $str $str eq ""
Truth table0%0/3
not(A) or B
A= not defined $strB= $str eq ""
ABresult
1X1
011
000
265 0 $str =~ s/[\x0D\x0A\s]+$//;
266  
267 0 ▶ if ($charset && $str =~ /[^[:ascii:]]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($charset and $str =~ /[^[:ascii:]]/) 0 0 0
Condition0%0/3
$charset and $str =~ /[^[:ascii:]]/
!ll&&!rl&&r
000
MC/DC0%0/2
$charset and $str =~ /[^[:ascii:]]/
$charset $str =~ /[^[:ascii:]]/
Truth table0%0/3
A and B
A= $charsetB= $str =~ /[^[:ascii:]]/
ABresult
0X0
100
111
268 0 $str = Encode::encode($charset, $str);
269 0 my @parts = split /(\s*[,;<> ]\s*)/, $str;
270 0 $str = '';
271 0 ▶ for (my $i = 0; $i < @parts; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @parts) 0 0 0
272 0 my $part = $parts[$i];
273 0 ▶ $part .= $parts[++$i]
Branch: 1 branch
BranchTrueFalseTotal
if $i < $#parts and $parts[$i + 1] =~ /^\s+$/ 0 0 0
Condition0%0/3
$i < $#parts and $parts[$i + 1] =~ /^\s+$/
!ll&&!rl&&r
000
MC/DC0%0/2
$i < $#parts and $parts[$i + 1] =~ /^\s+$/
$i < $#parts $parts[$i + 1] =~ /^\s+$/
Truth table0%0/3
A and B
A= $i < $#partsB= $parts[$i + 1] =~ /^\s+$/
ABresult
0X0
100
111
274 if ($i < $#parts && $parts[$i + 1] =~ /^\s+$/);
275 0 ▶ if ($part =~ /[^[:ascii:]]/ || $part =~ /[\r\n\t]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($part =~ /[^[:ascii:]]/ or $part =~ /[\r\n\t]/) { } 0 0 0
Condition0%0/3
$part =~ /[^[:ascii:]]/ or $part =~ /[\r\n\t]/
l!l&&r!l&&!r
000
MC/DC0%0/2
$part =~ /[^[:ascii:]]/ or $part =~ /[\r\n\t]/
$part =~ /[^[:ascii:]]/ $part =~ /[\r\n\t]/
Truth table0%0/3
A or B
A= $part =~ /[^[:ascii:]]/B= $part =~ /[\r\n\t]/
ABresult
1X1
011
000
276 0 $part = MIME::QuotedPrint::encode_qp($part, '');
277 0 $part =~ s/([\s\?])/'=' . sprintf '%02x',ord($1)/ge;
278 0 $str .= "=?$charset?Q?$part?=";
279 }
280 else {
281 0 $str .= $part;
282 }
283 }
284 }
285  
286 0 $str =~ s/(?:\x0D\x0A?|\x0A)/\x0D\x0A/sg; # \n or \r => \r\n
287 0 $str =~ s/\x0D\x0A([^\t])/\x0D\x0A\t$1/sg;
288 0 ▶ if (length($str) + length($hdr) > 997) { # header too long, max 1000 chars
Branch: 1 branch
BranchTrueFalseTotal
if (length($str) + length($hdr) > 997) 0 0 0
289 0 $str =~ s/(.{1,980}[;,])\s+(\S)/$1\x0D\x0A\t$2/g;
290 }
291 0 print $s "$hdr: $str\x0D\x0A";
292 }
293  
294  
295 0 ▶sub _say_helo {
Subroutine _say_helo: not called CC=10 SCAR=47.0
296 0 my ($self, $s) = @_;
297 0 my $res = send_cmd $s, "EHLO $self->{'client'}";
298 0 ▶ if ($res !~ /^[123]/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($res =~ /^[123]/) 0 0 0
299 0 $res = send_cmd $s, "HELO $self->{'client'}";
300 0 ▶ if ($res !~ /^[123]/) { return $self->Error(_COMMERROR($_)); }
Branch: 1 branch
BranchTrueFalseTotal
unless ($res =~ /^[123]/) 0 0 0
301 0 return;
302 }
303  
304 0 $res =~ s/^.*\n//;
305 0 $self->{'supports'} = {map { split /(?:\s+|=)/, $_, 2 } split /\n/, $res};
306  
307 0 ▶ if (exists $self->{'supports'}{AUTH}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"supports"}{"AUTH"}) 0 0 0
308 0 my @auth = split /\s+/, uc($self->{'supports'}{AUTH});
309 0 $self->{'auth_protocols'} = {map { $_, 1 } @auth};
310  
311 # create a hash with accepted authentication protocols
312 }
313  
314 0 $self->{esmtp}{_MAIL_FROM} = '';
315 0 $self->{esmtp}{_RCPT_TO} = '';
316 0 ▶ if (exists $self->{'supports'}{DSN} and exists $self->{esmtp}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"supports"}{"DSN"} and exists $self->{"esmtp"}) 0 0 0
Condition0%0/3
exists $self->{"supports"}{"DSN"} and exists $self->{"esmtp"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $self->{"supports"}{"DSN"} and exists $self->{"esmtp"}
exists $self->{"supports"}{"DSN"} exists $self->{"esmtp"}
Truth table0%0/3
A and B
A= exists $self->{"supports"}{"DSN"}B= exists $self->{"esmtp"}
ABresult
0X0
100
111
317 0 for (qw(RET ENVID)) {
318 $self->{esmtp}{_MAIL_FROM} .= " $_=$self->{esmtp}{$_}"
319 0 ▶ if $self->{esmtp}{$_} ne '';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"esmtp"}{$_} ne "" 0 0 0
320 }
321 0 for (qw(NOTIFY ORCPT)) {
322 $self->{esmtp}{_RCPT_TO} .= " $_=$self->{esmtp}{$_}"
323 0 ▶ if $self->{esmtp}{$_} ne '';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"esmtp"}{$_} ne "" 0 0 0
324 }
325 }
326 0 return;
327 }
328  
329 0 ▶sub login {
Subroutine login: not called CC=7 SCAR=37.1
Pod undocumented
330 0 my $self = shift();
331 0 ▶ my $auth = uc($self->{'auth'}) || 'LOGIN';
Condition0%0/2
uc $self->{'auth'} || 'LOGIN'
l!l
00
MC/DC0%0/1
uc $self->{'auth'} || 'LOGIN'
uc $self->{'auth'}
Truth table0%0/2
A
A= uc $self->{'auth'}
Aresult
11
00
332 0 ▶ if (!$self->{'auth_protocols'}->{$auth}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"auth_protocols"}{$auth}) 0 0 0
333 0 return $self->Error(_INVALIDAUTH($auth));
334 }
335  
336 $self->{'authid'} = $self->{'username'}
337 0 ▶ if (exists $self->{'username'} and !exists $self->{'authid'});
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"username"} and not exists $self->{"authid"} 0 0 0
Condition0%0/3
exists $self->{"username"} and not exists $self->{"authid"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $self->{"username"} and not exists $self->{"authid"}
exists $self->{"username"} not exists $self->{"authid"}
Truth table0%0/3
A and not(B)
A= exists $self->{"username"}B= not exists $self->{"authid"}
ABresult
0X0
100
111
338  
339 $self->{'authpwd'} = $self->{'password'}
340 0 ▶ if (exists $self->{'password'} and !exists $self->{'authpwd'});
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"password"} and not exists $self->{"authpwd"} 0 0 0
Condition0%0/3
exists $self->{"password"} and not exists $self->{"authpwd"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $self->{"password"} and not exists $self->{"authpwd"}
exists $self->{"password"} not exists $self->{"authpwd"}
Truth table0%0/3
A and not(B)
A= exists $self->{"password"}B= not exists $self->{"authpwd"}
ABresult
0X0
100
111
341  
342 # change all characters except letters, numbers and underscores to underscores
343 0 $auth =~ tr/a-zA-Z0-9_/_/c;
344 2 ▶ no strict qw'subs refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
345 0 my $method = "Mail::Sender::Auth::$auth";
346 0 $method->($self);
347 }
348  
349 # authentication code stolen from http://support.zeitform.de/techinfo/e-mail_prot.html
350 0 ▶sub Mail::Sender::Auth::LOGIN {
Subroutine LOGIN: not called CC=7 SCAR=40.3
351 0 my $self = shift();
352 0 my $s = $self->{'socket'};
353  
354 0 $_ = send_cmd $s, 'AUTH LOGIN';
355 0 ▶ if (!/^[123]/) { return $self->Error(_INVALIDAUTH('LOGIN', $_)); }
Branch: 1 branch
BranchTrueFalseTotal
unless (/^[123]/) 0 0 0
356  
357 0 ▶ if ($self->{auth_encoded}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'auth_encoded'}) { } 0 0 0
358  
359 # I assume the username and password had been base64 encoded already!
360 0 $_ = send_cmd $s, $self->{'authid'};
361 0 ▶ if (!/^[123]/) { return $self->Error(_LOGINERROR($_)); }
Branch: 1 branch
BranchTrueFalseTotal
unless (/^[123]/) 0 0 0
362  
363 0 $_ = send_cmd $s, $self->{'authpwd'};
364 0 ▶ if (!/^[123]/) { return $self->Error(_LOGINERROR($_)); }
Branch: 1 branch
BranchTrueFalseTotal
unless (/^[123]/) 0 0 0
365 }
366 else {
367 0 $_ = send_cmd $s, MIME::Base64::encode_base64($self->{'authid'}, '');
368 0 ▶ if (!/^[123]/) { return $self->Error(_LOGINERROR($_)); }
Branch: 1 branch
BranchTrueFalseTotal
unless (/^[123]/) 0 0 0
369  
370 0 $_ = send_cmd $s, MIME::Base64::encode_base64($self->{'authpwd'}, '');
371 0 ▶ if (!/^[123]/) { return $self->Error(_LOGINERROR($_)); }
Branch: 1 branch
BranchTrueFalseTotal
unless (/^[123]/) 0 0 0
372 }
373 0 return;
374 }
375  
376 0 ▶sub Mail::Sender::Auth::CRAM_MD5 {
Subroutine CRAM_MD5: not called CC=6 SCAR=37.4
377 0 my $self = shift();
378 0 my $s = $self->{'socket'};
379  
380 0 $_ = send_cmd $s, "AUTH CRAM-MD5";
381 0 ▶ if (!/^[123]/) { return $self->Error(_INVALIDAUTH('CRAM-MD5', $_)); }
Branch: 1 branch
BranchTrueFalseTotal
unless (/^[123]/) 0 0 0
382 0 ▶ my $stamp = $1 if /^\d{3}\s+(.*)$/;
Branch: 1 branch
BranchTrueFalseTotal
if /^\d{3}\s+(.*)$/ 0 0 0
383  
384 0 ▶ unless ($MD5_loaded) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Mail::Sender::MD5_loaded) 0 0 0
385 0 eval 'use Digest::HMAC_MD5 qw(hmac_md5_hex)';
386 0 ▶ die "$@\n" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
387 0 $MD5_loaded = 1;
388 }
389  
390 0 my $user = $self->{'authid'};
391 0 my $secret = $self->{'authpwd'};
392  
393 0 my $decoded_stamp = MIME::Base64::decode_base64($stamp);
394 0 my $hmac = hmac_md5_hex($decoded_stamp, $secret);
395 0 my $answer = MIME::Base64::encode_base64($user . ' ' . $hmac, '');
396 0 $_ = send_cmd $s, $answer;
397 0 ▶ if (!/^[123]/) { return $self->Error(_LOGINERROR($_)); }
Branch: 1 branch
BranchTrueFalseTotal
unless (/^[123]/) 0 0 0
398 0 return;
399 }
400  
401 0 ▶sub Mail::Sender::Auth::PLAIN {
Subroutine PLAIN: not called CC=3 SCAR=24.8
402 0 my $self = shift();
403 0 my $s = $self->{'socket'};
404  
405 0 $_ = send_cmd $s, "AUTH PLAIN";
406 0 ▶ if (!/^[123]/) { return $self->Error(_INVALIDAUTH('PLAIN', $_)); }
Branch: 1 branch
BranchTrueFalseTotal
unless (/^[123]/) 0 0 0
407  
408 $_ = send_cmd $s,
409 MIME::Base64::encode_base64(
410 0 "\000" . $self->{'authid'} . "\000" . $self->{'authpwd'}, '');
411 0 ▶ if (!/^[123]/) { return $self->Error(_LOGINERROR($_)); }
Branch: 1 branch
BranchTrueFalseTotal
unless (/^[123]/) 0 0 0
412 0 return;
413 }
414  
415 {
416 2 my $NTLM_loaded = 0;
417  
418 0 ▶ sub Mail::Sender::Auth::NTLM {
Subroutine NTLM: not called CC=7 SCAR=40.3
419 0 ▶ unless ($NTLM_loaded) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($NTLM_loaded) 0 0 0
420 0 eval "use Authen::NTLM qw();";
421 0 ▶ die "$@\n" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
422 0 $NTLM_loaded = 1;
423 }
424 0 my $self = shift();
425 0 my $s = $self->{'socket'};
426  
427 0 $_ = send_cmd $s, "AUTH NTLM";
428 0 ▶ if (!/^[123]/) { return $self->Error(_INVALIDAUTH('NTLM', $_)); }
Branch: 1 branch
BranchTrueFalseTotal
unless (/^[123]/) 0 0 0
429  
430 0 Authen::NTLM::ntlm_reset();
431 0 Authen::NTLM::ntlm_user($self->{'authid'});
432 0 Authen::NTLM::ntlm_password($self->{'authpwd'});
433 Authen::NTLM::ntlm_domain($self->{'authdomain'})
434 0 ▶ if defined $self->{'authdomain'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"authdomain"} 0 0 0
435  
436 0 $_ = send_cmd $s, Authen::NTLM::ntlm();
437 0 ▶ if (!/^3\d\d (.*)$/s) { return $self->Error(_LOGINERROR($_)); }
Branch: 1 branch
BranchTrueFalseTotal
unless (/^3\d\d (.*)$/s) 0 0 0
438 0 my $response = $1;
439 0 $_ = send_cmd $s, Authen::NTLM::ntlm($response);
440 0 ▶ if (!/^[123]/) { return $self->Error(_LOGINERROR($_)); }
Branch: 1 branch
BranchTrueFalseTotal
unless (/^[123]/) 0 0 0
441 0 return;
442 }
443 }
444  
445 2 ▶sub Mail::Sender::Auth::AUTOLOAD {
Subroutine AUTOLOAD: not called CC=1 SCAR=5.1
446 0 (my $auth = $Mail::Sender::Auth::AUTOLOAD) =~ s/.*:://;
447 0 my $self = shift();
448 0 my $s = $self->{'socket'};
449 0 send_cmd $s, "QUIT";
450 0 close $s;
451 0 delete $self->{'socket'};
452 0 return $self->Error(_UNKNOWNAUTH($auth));
453 }
454  
455 2 my $debug_code;
456  
457 0 ▶sub __Debug {
Subroutine __Debug: not called CC=6 SCAR=37.4
458 0 my ($socket, $file) = @_;
459 0 ▶ if (defined $file) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $file) { } 0 0 0
460 0 ▶ unless (@Mail::Sender::DBIO::ISA) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@Mail::Sender::DBIO::ISA) 0 0 0
461 0 eval "use Symbol;";
462 0 eval $debug_code;
463 0 ▶ die $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
464 }
465 0 my $handle = gensym();
466 0 *$handle = \$socket;
467 0 ▶ if (!ref $file) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $file) { } 0 0 0
468 0 ▶ open my $DEBUG, '>', $file
Branch: 1 branch
BranchTrueFalseTotal
open my $DEBUG, ">", $file or die "Cannot open the debug file '${file}': $^E\n" 0 0 0
469 or die "Cannot open the debug file '$file': $^E\n";
470 0 binmode $DEBUG;
471 0 $DEBUG->autoflush();
472 0 tie *$handle, 'Mail::Sender::DBIO', $socket, $DEBUG, 1;
473 }
474 else {
475 0 my $DEBUG = $file;
476 0 tie *$handle, 'Mail::Sender::DBIO', $socket, $DEBUG, 0;
477 }
478 0 bless $handle, 'Mail::Sender::DBIO';
479 0 return $handle;
480 }
481 else {
482 0 return $socket;
483 }
484 }
485  
486 #internale
487  
488 3 ▶sub _HOSTNOTFOUND {
Subroutine _HOSTNOTFOUND: called CC=2 SCAR=6.9
489 3 ▶ my $msg = shift || '';
Condition100%2/2
shift() || ''
l!l
21
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
490 3 $! = 2;
491 3 $Error = "The SMTP server $msg was not found";
492 3 return -1, $Error;
493 }
494  
495 1 ▶sub _CONNFAILED {
Subroutine _CONNFAILED: called CC=1 SCAR=0.0
496 1 $! = 5;
497 1 $Error = "connect() failed: $^E";
498 1 return -3, $Error;
499 }
500  
501 2 ▶sub _SERVNOTAVAIL {
Subroutine _SERVNOTAVAIL: called CC=3 SCAR=11.0
502 2 ▶ my $msg = shift || '';
Condition100%2/2
shift() || ''
l!l
11
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
503 2 $! = 40;
504 2 ▶ $Error = "Service not available. "
Branch: 1 branch
BranchTrueFalseTotal
$msg ? : 1 1 2
505 . ($msg ? "Reply: $msg" : "Server closed the connection unexpectedly");
506 2 return -4, $Error;
507 }
508  
509 2 ▶sub _COMMERROR {
Subroutine _COMMERROR: called CC=3 SCAR=11.0
510 2 ▶ my $msg = shift || '';
Condition100%2/2
shift() || ''
l!l
11
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
511 2 $! = 5;
512 2 ▶ if ($msg eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($msg eq '') { } 1 1 2
513 1 $Error = "No response from server";
514 }
515 else {
516 1 $Error = "Server error: $msg";
517 }
518 2 return -5, $Error;
519 }
520  
521 5 ▶sub _USERUNKNOWN {
Subroutine _USERUNKNOWN: called CC=7 SCAR=19.5
522 5 ▶ my $user = shift || '';
Condition100%2/2
shift() || ''
l!l
41
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
523 5 ▶ my $host = shift || '';
Condition100%2/2
shift() || ''
l!l
41
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
524 5 ▶ my $err = shift || '';
Condition100%2/2
shift() || ''
l!l
32
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
525 5 $! = 2;
526 5 ▶ if ($err and $err !~ /Local user/i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($err and not $err =~ /Local user/i) { } 2 3 5
Condition100%3/3
$err and not $err =~ /Local user/i
!ll&&!rl&&r
212
MC/DC100%2/2
$err and not $err =~ /Local user/i
$err not $err =~ /Local user/i
Truth table100%3/3
A and not(B)
A= $errB= not $err =~ /Local user/i
ABresult
0X0
100
111
527 2 $err =~ s/^\d+\s*//;
528 2 $err =~ s/\s*$//s;
529 2 ▶ $err ||= "Error";
Condition100%2/2
$err ||= "Error"
l!l
11
MC/DC100%1/1
$err ||= "Error"
$err
Truth table100%2/2
A
A= $err
Aresult
11
00
530 2 $Error = "$err for \"$user\" on host \"$host\"";
531 }
532 else {
533 3 $Error = "Local user \"$user\" unknown on host \"$host\"";
534 }
535 5 return -6, $Error;
536 }
537  
538 2 ▶sub _TRANSFAILED {
Subroutine _TRANSFAILED: called CC=2 SCAR=6.9
539 2 ▶ my $msg = shift || '';
Condition100%2/2
shift() || ''
l!l
11
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
540 2 $! = 5;
541 2 $Error = "Transmission of message failed ($msg)";
542 2 return -7, $Error;
543 }
544  
545 1 ▶sub _TOEMPTY {
Subroutine _TOEMPTY: called CC=1 SCAR=0.0
546 1 $! = 14;
547 1 $Error = "Argument \$to empty";
548 1 return -8, $Error;
549 }
550  
551 1 ▶sub _NOMSG {
Subroutine _NOMSG: called CC=1 SCAR=0.0
552 1 $! = 22;
553 1 $Error = "No message specified";
554 1 return -9, $Error;
555 }
556  
557 1 ▶sub _NOFILE {
Subroutine _NOFILE: called CC=1 SCAR=0.0
558 1 $! = 22;
559 1 $Error = "No file name specified";
560 1 return -10, $Error;
561 }
562  
563 2 ▶sub _FILENOTFOUND {
Subroutine _FILENOTFOUND: called CC=2 SCAR=6.9
564 2 ▶ my $msg = shift || '';
Condition100%2/2
shift() || ''
l!l
11
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
565 2 $! = 2;
566 2 $Error = "File \"$msg\" not found";
567 2 return -11, $Error;
568 }
569  
570 2 ▶sub _NOTMULTIPART {
Subroutine _NOTMULTIPART: called CC=2 SCAR=6.9
571 2 ▶ my $msg = shift || '';
Condition100%2/2
shift() || ''
l!l
11
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
572 2 $! = 40;
573 2 $Error = "$msg not available in singlepart mode";
574 2 return -12, $Error;
575 }
576  
577 1 ▶sub _SITEERROR {
Subroutine _SITEERROR: called CC=1 SCAR=0.0
578 1 $! = 15;
579 1 $Error = "Site specific error";
580 1 return -13, $Error;
581 }
582  
583 1 ▶sub _NOTCONNECTED {
Subroutine _NOTCONNECTED: called CC=1 SCAR=0.0
584 1 $! = 1;
585 1 $Error = "Connection not established";
586 1 return -14, $Error;
587 }
588  
589 1 ▶sub _NOSERVER {
Subroutine _NOSERVER: called CC=1 SCAR=0.0
590 1 $! = 22;
591 1 $Error = "No SMTP server specified";
592 1 return -15, $Error;
593 }
594  
595 1 ▶sub _NOFROMSPECIFIED {
Subroutine _NOFROMSPECIFIED: called CC=1 SCAR=0.0
596 1 $! = 22;
597 1 $Error = "No From: address specified";
598 1 return -16, $Error;
599 }
600  
601 3 ▶sub _INVALIDAUTH {
Subroutine _INVALIDAUTH: called CC=4 SCAR=13.9
602 3 ▶ my $proto = shift || '';
Condition100%2/2
shift() || ''
l!l
21
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
603 3 ▶ my $res = shift || '';
Condition100%2/2
shift() || ''
l!l
12
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
604 3 $! = 22;
605 3 $Error = "Authentication protocol $proto is not accepted by the server";
606 3 ▶ $Error .= ",\nresponse: $res" if $res;
Branch: 1 branch
BranchTrueFalseTotal
if $res 1 2 3
607 3 return -17, $Error;
608 }
609  
610 1 ▶sub _LOGINERROR {
Subroutine _LOGINERROR: called CC=1 SCAR=0.0
611 1 $! = 22;
612 1 $Error = "Login not accepted";
613 1 return -18, $Error;
614 }
615  
616 2 ▶sub _UNKNOWNAUTH {
Subroutine _UNKNOWNAUTH: called CC=2 SCAR=6.9
617 2 ▶ my $msg = shift || '';
Condition100%2/2
shift() || ''
l!l
11
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
618 2 $! = 22;
619 2 $Error = "Authentication protocol $msg is not implemented by Mail::Sender";
620 2 return -19, $Error;
621 }
622  
623 1 ▶sub _ALLRECIPIENTSBAD {
Subroutine _ALLRECIPIENTSBAD: called CC=1 SCAR=0.0
624 1 $! = 2;
625 1 $Error = "All recipients are bad";
626 1 return -20, $Error;
627 }
628  
629 2 ▶sub _FILECANTREAD {
Subroutine _FILECANTREAD: called CC=2 SCAR=6.9
630 2 ▶ my $msg = shift || '';
Condition100%2/2
shift() || ''
l!l
11
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
631 2 $Error = "File \"$msg\" cannot be read: $^E";
632 2 return -21, $Error;
633 }
634  
635 2 ▶sub _DEBUGFILE {
Subroutine _DEBUGFILE: called CC=1 SCAR=0.0
636 2 $Error = shift;
637 2 return -22, $Error;
638 }
639  
640 3 ▶sub _STARTTLS {
Subroutine _STARTTLS: called CC=3 SCAR=11.0
641 3 ▶ my $msg = shift || '';
Condition100%2/2
shift() || ''
l!l
21
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
642 3 ▶ my $two = shift || '';
Condition100%2/2
shift() || ''
l!l
12
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
643 3 $! = 5;
644 3 $Error = "STARTTLS failed: $msg $two";
645 3 return -23, $Error;
646 }
647  
648 2 ▶sub _IO_SOCKET_SSL {
Subroutine _IO_SOCKET_SSL: called CC=2 SCAR=6.9
649 2 ▶ my $msg = shift || '';
Condition100%2/2
shift() || ''
l!l
11
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
650 2 $! = 5;
651 2 $Error = "IO::Socket::SSL->start_SSL failed: $msg";
652 2 return -24, $Error;
653 }
654  
655 2 ▶sub _TLS_UNSUPPORTED_BY_ME {
Subroutine _TLS_UNSUPPORTED_BY_ME: called CC=2 SCAR=6.9
656 2 ▶ my $msg = shift || '';
Condition100%2/2
shift() || ''
l!l
11
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
657 2 $! = 5;
658 2 $Error = "TLS unsupported by the script: $msg";
659 2 return -25, $Error;
660 }
661  
662 1 ▶sub _TLS_UNSUPPORTED_BY_SERVER {
Subroutine _TLS_UNSUPPORTED_BY_SERVER: called CC=1 SCAR=0.0
663 1 $! = 5;
664 1 $Error = "TLS unsupported by server";
665 1 return -26, $Error;
666 }
667  
668 2 ▶sub _UNKNOWNENCODING {
Subroutine _UNKNOWNENCODING: called CC=2 SCAR=6.9
669 2 ▶ my $msg = shift || '';
Condition100%2/2
shift() || ''
l!l
11
MC/DC100%1/1
shift() || ''
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
670 2 $! = 5;
671 2 $Error = "Unknown encoding '$msg'";
672 2 return -27, $Error;
673 }
674  
675 19 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
676 19 my $this = shift;
677 19 my $self = {};
678 19 my $class;
679 19 ▶ if (ref($this)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $this) { } 2 17 19
680 2 $class = ref($this);
681 2 %$self = %$this;
682 }
683 else {
684 17 $class = $this;
685 }
686 19 bless $self, $class;
687 19 return $self->_initialize(@_);
688 }
689  
690 19 ▶sub _initialize {
Subroutine _initialize: called CC=20 SCAR=30.0
691 19 undef $Error;
692 19 my $self = shift;
693  
694 19 delete $self->{'_buffer'};
695 19 $self->{'debug'} = 0;
696 19 $self->{'proto'} = (getprotobyname('tcp'))[2];
697  
698 $self->{'port'} = getservbyname('smtp', 'tcp') || 25
699 19 ▶ unless $self->{'port'};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"port"} 17 2 19
Condition50%1/2
getservbyname('smtp', 'tcp') || 25
l!l
017
MC/DC0%0/1
getservbyname('smtp', 'tcp') || 25
getservbyname('smtp', 'tcp')
Truth table50%1/2
A
A= getservbyname('smtp', 'tcp')
Aresult
11
00
700  
701 19 $self->{'boundary'} = 'Message-Boundary-by-Mail-Sender-' . time();
702 19 $self->{'multipart'} = 'mixed'; # default is multipart/mixed
703 19 $self->{'tls_allowed'} = 1;
704  
705 19 $self->{'client'} = $local_name;
706  
707 # Copy defaults from %default
708 19 foreach my $key (keys %default) {
709 36 $self->{lc $key} = $default{$key};
710 }
711  
712 19 ▶ if (@_ != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ != 0) 18 1 19
713 18 ▶ if (ref $_[0] eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 17 1 18
714 17 my $hash = $_[0];
715 17 foreach my $key (keys %$hash) {
716 5 $self->{lc $key} = $hash->{$key};
717 }
718 $self->{'reply'} = $self->{'replyto'}
719 17 ▶ if ($self->{'replyto'} and !$self->{'reply'});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"replyto"} and not $self->{"reply"} 1 16 17
Condition100%3/3
$self->{"replyto"} and not $self->{"reply"}
!ll&&!rl&&r
1331
MC/DC100%2/2
$self->{"replyto"} and not $self->{"reply"}
$self->{"replyto"} not $self->{"reply"}
Truth table100%3/3
A and not(B)
A= $self->{"replyto"}B= not $self->{"reply"}
ABresult
0X0
100
111
720 }
721 else {
722 (
723 $self->{'from'}, $self->{'reply'}, $self->{'to'},
724 $self->{'smtp'}, $self->{'subject'}, $self->{'headers'},
725 1 $self->{'boundary'}
726 ) = @_;
727 }
728 }
729  
730 19 $self->{'fromaddr'} = $self->{'from'};
731 19 $self->{'replyaddr'} = $self->{'reply'};
732  
733 19 ▶ $self->_prepare_addresses('to') if $self->{'to'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"to"} 6 13 19
734 19 ▶ $self->_prepare_addresses('cc') if $self->{'cc'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"cc"} 5 14 19
735 19 ▶ $self->_prepare_addresses('bcc') if $self->{'bcc'};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"bcc"} 5 14 19
736  
737 19 ▶ $self->_prepare_ESMTP() if defined $self->{'esmtp'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"esmtp"} 1 18 19
738  
739 # get from email address
740 19 ▶ $self->{'fromaddr'} =~ s/.*<([^\s]*?)>/$1/ if ($self->{'fromaddr'});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"fromaddr"} 1 18 19
741  
742 19 ▶ if ($self->{'replyaddr'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"replyaddr"}) 4 15 19
743 4 $self->{'replyaddr'} =~ s/.*<([^\s]*?)>/$1/; # get reply email address
744 4 $self->{'replyaddr'} =~ s/^([^\s]+).*/$1/; # use first address
745 }
746  
747 19 ▶ if ($self->{'smtp'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"smtp"}) 3 16 19
748 3 $self->{'smtp'} =~ s/^\s+//g; # remove spaces around $smtp
749 3 $self->{'smtp'} =~ s/\s+$//g;
750  
751 3 ▶ unless ($self->{'smtpaddr'} = Socket::inet_aton($self->{'smtp'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"smtpaddr"} = Socket::inet_aton($self->{"smtp"})) 1 2 3
752 1 return $self->Error(_HOSTNOTFOUND($self->{'smtp'}));
753 }
754 2 ▶ $self->{'smtpaddr'} = $1 if ($self->{'smtpaddr'} =~ /(.*)/s); # Untaint
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"smtpaddr"} =~ /(.*)/s 2 0 2
755 }
756  
757 18 ▶ $self->{'boundary'} =~ tr/=/-/ if defined $self->{'boundary'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"boundary"} 17 1 18
758  
759 18 ▶ $self->_prepare_headers() if defined $self->{'headers'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"headers"} 3 15 18
760  
761 18 return $self;
762 }
763  
764 7 ▶sub GuessCType {
Subroutine GuessCType: called CC=4 SCAR=13.9
Pod documented
765 7 my $file = shift;
766 7 ▶ if (defined $file && $file =~ /\.(.*)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $file and $file =~ /\.(.*)$/) 5 2 7
Condition100%3/3
defined $file and $file =~ /\.(.*)$/
!ll&&!rl&&r
115
MC/DC100%2/2
defined $file and $file =~ /\.(.*)$/
defined $file $file =~ /\.(.*)$/
Truth table100%3/3
A and B
A= defined $fileB= $file =~ /\.(.*)$/
ABresult
0X0
100
111
767 5 ▶ return $CTypes{uc($1)} || 'application/octet-stream';
Condition100%2/2
$Mail::Sender::CTypes{uc $1} || 'application/octet-stream'
l!l
41
MC/DC100%1/1
$Mail::Sender::CTypes{uc $1} || 'application/octet-stream'
$Mail::Sender::CTypes{uc $1}
Truth table100%2/2
A
A= $Mail::Sender::CTypes{uc $1}
Aresult
11
00
768 }
769 2 return 'application/octet-stream';
770 }
771  
772 0 ▶sub Connect {
Subroutine Connect: not called CC=31 SCAR=69.0
Pod documented
773 0 my $self = shift();
774  
775 my $s = IO::Socket::INET->new(
776 PeerHost => $self->{'smtp'},
777 PeerPort => $self->{'port'},
778 Proto => "tcp",
779 0 ▶ Timeout => ($self->{'timeout'} || 120),
Branch: 1 branch
BranchTrueFalseTotal
my $s = "IO::Socket::INET"->new("PeerHost", $self->{"smtp"}, "PeerPort", $self->{"port"}, "Proto", "tcp", "Timeout", $self->{"timeout"} || 120) or return $self->Error(_CONNFAILED()) 0 0 0
Condition0%0/2
$self->{'timeout'} || 120
l!l
00
MC/DC0%0/1
$self->{'timeout'} || 120
$self->{'timeout'}
Truth table0%0/2
A
A= $self->{'timeout'}
Aresult
11
00
780 ) or return $self->Error(_CONNFAILED);
781  
782 0 $s->autoflush(1);
783 0 binmode($s);
784  
785 0 ▶ if ($self->{'debug'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"debug"}) 0 0 0
786 0 ▶ eval { $s = __Debug($s, $self->{'debug'}); }
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $s = __Debug($s, $self->{"debug"}) } } or return $self->Error(_DEBUGFILE($@)) 0 0 0
787 or return $self->Error(_DEBUGFILE($@));
788 0 ▶ $self->{'debug_level'} = 4 unless defined $self->{'debug_level'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"debug_level"} 0 0 0
789 }
790  
791 0 $_ = get_response($s);
792 0 ▶ if (not $_ or !/^[123]/) { return $self->Error(_SERVNOTAVAIL($_)); }
Branch: 1 branch
BranchTrueFalseTotal
unless ($_ and /^[123]/) 0 0 0
Condition0%0/3
$_ and /^[123]/
!ll&&!rl&&r
000
MC/DC0%0/2
$_ and /^[123]/
$_ /^[123]/
Truth table0%0/3
A and B
A= $_B= /^[123]/
ABresult
0X0
100
111
793 0 $self->{'server'} = substr $_, 4;
794 0 $self->{'!greeting'} = $_;
795  
796 {
797 0 my $res = $self->_say_helo($s);
798 0 ▶ return $res if $res;
Branch: 1 branch
BranchTrueFalseTotal
if $res 0 0 0
799 }
800  
801 0 ▶ if (
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'tls_required'} || $self->{'tls_allowed'} and not $TLS_notsupported and defined $self->{'supports'}{'STARTTLS'} || defined $self->{'supports'}{'TLS'}) { } 0 0 0
elsif ($self->{'tls_required'}) { } 0 0 0
Condition0%0/12
$self->{"tls_required"} || $self->{"tls_allowed"} and not $TLS_notsupported and defined $self->{"supports"}{"STARTTLS"} || defined $self->{"supports"}{"TLS"}
!ll&&!rl&&r
000
$self->{"tls_required"} || $self->{"tls_allowed"} and not $TLS_notsupported
!ll&&!rl&&r
000
$self->{"tls_required"} or $self->{"tls_allowed"}
l!l&&r!l&&!r
000
defined $self->{"supports"}{"STARTTLS"} or defined $self->{"supports"}{"TLS"}
l!l&&r!l&&!r
000
MC/DC0%0/5
$self->{"tls_required"} || $self->{"tls_allowed"} and not $TLS_notsupported and defined $self->{"supports"}{"STARTTLS"} || defined $self->{"supports"}{"TLS"}
$self->{"tls_required"} $self->{"tls_allowed"} not $TLS_notsupported defined $self->{"supports"}{"STARTTLS"} defined $self->{"supports"}{"TLS"}
Truth table0%0/9
A or B and not(C) and D or E
A= $self->{"tls_required"}B= $self->{"tls_allowed"}C= not $TLS_notsupportedD= defined $self->{"supports"}{"STARTTLS"}E= defined $self->{"supports"}{"TLS"}
ABCDEresult
00XXX0
1X0XX0
010XX0
1X1000
011000
1X11X1
1X1011
0111X1
011011
802 ($self->{tls_required} or $self->{tls_allowed})
803 and !$TLS_notsupported
804 and ( defined($self->{'supports'}{STARTTLS})
805 or defined($self->{'supports'}{TLS}))
806 )
807 {
808 0 Net::SSLeay::load_error_strings();
809 0 Net::SSLeay::SSLeay_add_ssl_algorithms();
810 0 ▶ $Net::SSLeay::random_device = $0 if (!-s $Net::SSLeay::random_device);
Branch: 1 branch
BranchTrueFalseTotal
unless -s $Net::SSLeay::random_device 0 0 0
811 0 Net::SSLeay::randomize();
812  
813 0 my $res = send_cmd $s, "STARTTLS";
814 0 my ($code, $text) = split(/\s/, $res, 2);
815  
816 0 ▶ return $self->Error(_STARTTLS($code, $text)) if ($code != 220);
Branch: 1 branch
BranchTrueFalseTotal
if $code != 220 0 0 0
817  
818 0 my %ssl_options = (
819 SSL_version => 'TLSv1',
820 SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE(),
821 );
822 0 ▶ if (exists $self->{ssl_version}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"ssl_version"}) 0 0 0
823 0 $ssl_options{SSL_version} = $self->{ssl_version};
824 }
825 0 ▶ if (exists $self->{ssl_verify_mode}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"ssl_verify_mode"}) 0 0 0
826 0 $ssl_options{SSL_verify_mode} = $self->{ssl_verify_mode};
827 }
828 0 ▶ if (exists $self->{ssl_ca_path}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"ssl_ca_path"}) 0 0 0
829 0 $ssl_options{SSL_ca_path} = $self->{ssl_ca_path};
830 }
831 0 ▶ if (exists $self->{ssl_ca_file}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"ssl_ca_file"}) 0 0 0
832 0 $ssl_options{SSL_ca_file} = $self->{ssl_ca_file};
833 }
834 0 ▶ if (exists $self->{ssl_verifycb_name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"ssl_verifycb_name"}) 0 0 0
835 0 $ssl_options{SSL_verifycb_name} = $self->{ssl_verifycb_name};
836 }
837 0 ▶ if (exists $self->{ssl_verifycn_schema}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"ssl_verifycn_schema"}) 0 0 0
838 0 $ssl_options{ssl_verifycn_schema} = $self->{ssl_verifycn_schema};
839 }
840 0 ▶ if (exists $self->{ssl_hostname}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"ssl_hostname"}) 0 0 0
841 0 $ssl_options{SSL_hostname} = $self->{ssl_hostname};
842 }
843  
844 0 ▶ if ($self->{'debug'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'debug'}) { } 0 0 0
845 0 $res = IO::Socket::SSL->start_SSL(tied(*$s)->[0], %ssl_options);
846 }
847 else {
848 0 $res = IO::Socket::SSL->start_SSL($s, %ssl_options);
849 }
850 0 ▶ if (!$res) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($res) 0 0 0
851 0 return $self->Error(_IO_SOCKET_SSL(IO::Socket::SSL::errstr()));
852 }
853  
854 {
855 0 my $res = $self->_say_helo($s);
856 0 ▶ return $res if $res;
Branch: 1 branch
BranchTrueFalseTotal
if $res 0 0 0
857 }
858 }
859 elsif ($self->{tls_required}) {
860 0 ▶ if ($TLS_notsupported) {
Branch: 1 branch
BranchTrueFalseTotal
if ($TLS_notsupported) { } 0 0 0
861 0 return $self->Error(_TLS_UNSUPPORTED_BY_ME($TLS_notsupported));
862 }
863 else {
864 0 return $self->Error(_TLS_UNSUPPORTED_BY_SERVER());
865 }
866 }
867  
868 0 ▶ if ($self->{'auth'} or $self->{'username'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"auth"} or $self->{"username"}) 0 0 0
Condition0%0/3
$self->{"auth"} or $self->{"username"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"auth"} or $self->{"username"}
$self->{"auth"} $self->{"username"}
Truth table0%0/3
A or B
A= $self->{"auth"}B= $self->{"username"}
ABresult
1X1
011
000
869 0 $self->{'socket'} = $s;
870 0 my $res = $self->login();
871 0 ▶ return $res if $res;
Branch: 1 branch
BranchTrueFalseTotal
if $res 0 0 0
872 0 delete $self->{'socket'}; # it's supposed to be added later
873 }
874  
875 0 return $s;
876 }
877  
878 1 ▶sub Error {
Subroutine Error: called CC=9 SCAR=32.0
Pod undocumented
879 1 my $self = shift();
880 1 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1 0 1
881 1 ▶ if (defined $self->{'socket'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"socket"}) 0 1 1
882 0 my $s = $self->{'socket'};
883 0 print $s "quit\x0D\x0A";
884 0 close $s;
885 0 delete $self->{'socket'};
886 }
887 1 delete $self->{'_data'};
888 1 ($self->{'error'}, $self->{'error_msg'}) = @_;
889 }
890 1 ▶ if ($self->{'die_on_errors'} or ($self->{on_errors} && $self->{'on_errors'} eq 'die')) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'die_on_errors'} or $self->{'on_errors'} and $self->{'on_errors'} eq 'die') { } 0 1 1
elsif (exists $self->{'on_errors'} and !defined($self->{'on_errors'}) || $self->{'on_errors'} eq 'undef') { } 0 2 2
Condition33%2/6
$self->{"die_on_errors"} or $self->{"on_errors"} and $self->{"on_errors"} eq "die"
l!l&&r!l&&!r
001
$self->{"on_errors"} and $self->{"on_errors"} eq "die"
!ll&&!rl&&r
100
MC/DC0%0/3
$self->{"die_on_errors"} or $self->{"on_errors"} and $self->{"on_errors"} eq "die"
$self->{"die_on_errors"} $self->{"on_errors"} $self->{"on_errors"} eq "die"
Truth table25%1/4
A or B and C
A= $self->{"die_on_errors"}B= $self->{"on_errors"}C= $self->{"on_errors"} eq "die"
ABCresult
1XX1
0111
00X0
0100
891 0 die $self->{'error_msg'} . "\n";
892 }
893 ▶ elsif (exists $self->{'on_errors'}
Condition16%1/6
exists $self->{"on_errors"} and !defined($self->{"on_errors"}) || $self->{"on_errors"} eq "undef"
!ll&&!rl&&r
100
not defined $self->{"on_errors"} or $self->{"on_errors"} eq "undef"
l!l&&r!l&&!r
000
MC/DC0%0/3
exists $self->{"on_errors"} and !defined($self->{"on_errors"}) || $self->{"on_errors"} eq "undef"
exists $self->{"on_errors"} not defined $self->{"on_errors"} $self->{"on_errors"} eq "undef"
Truth table25%1/4
A and not(B) or C
A= exists $self->{"on_errors"}B= not defined $self->{"on_errors"}C= $self->{"on_errors"} eq "undef"
ABCresult
0XX0
1000
11X1
1011
894 and (!defined($self->{'on_errors'}) or $self->{'on_errors'} eq 'undef'))
895 {
896 0 return;
897 }
898 1 return $self->{'error'};
899 }
900  
901 1 ▶sub ClearErrors {
Subroutine ClearErrors: called CC=1 SCAR=0.0
Pod documented
902 1 my $self = shift();
903 1 delete $self->{'error'};
904 1 delete $self->{'error_msg'};
905 1 undef $Error;
906 }
907  
908 17 ▶sub _prepare_addresses {
Subroutine _prepare_addresses: called CC=2 SCAR=6.9
909 17 my ($self, $type) = @_;
910 17 ▶ if (ref $self->{$type}) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{$type}) { } 1 16 17
911 $self->{$type . '_list'}
912 1 = [map { s/\s+$//; s/^\s+//; $_ } @{$self->{$type}}];
913 1 $self->{$type} = join ', ', @{$self->{$type . '_list'}};
914 }
915 else {
916 16 $self->{$type} =~ s/\s+/ /g;
917 16 $self->{$type} =~ s/, ?,/,/g;
918 16 $self->{$type . '_list'} = [map { s/\s+$//; $_ }
919 16 $self->{$type} =~ /((?:[^",]+|"[^"]*")+)(?:,\s*|\s*$)/g ];
920 }
921 }
922  
923 4 ▶sub _prepare_ESMTP {
Subroutine _prepare_ESMTP: called CC=4 SCAR=13.9
924 4 my $self = shift;
925 $self->{esmtp}
926 4 = {%{$self->{esmtp}}}; # make a copy of the hash. Just in case
927  
928 $self->{esmtp}{ORCPT} = 'rfc822;' . $self->{esmtp}{ORCPT}
929 4 ▶ if $self->{esmtp}{ORCPT} ne '' and $self->{esmtp}{ORCPT} !~ /;/;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"esmtp"}{"ORCPT"} ne "" and not $self->{"esmtp"}{"ORCPT"} =~ /;/ 2 2 4
Condition100%3/3
$self->{"esmtp"}{"ORCPT"} ne "" and not $self->{"esmtp"}{"ORCPT"} =~ /;/
!ll&&!rl&&r
112
MC/DC100%2/2
$self->{"esmtp"}{"ORCPT"} ne "" and not $self->{"esmtp"}{"ORCPT"} =~ /;/
$self->{"esmtp"}{"ORCPT"} ne "" not $self->{"esmtp"}{"ORCPT"} =~ /;/
Truth table100%3/3
A and not(B)
A= $self->{"esmtp"}{"ORCPT"} ne ""B= not $self->{"esmtp"}{"ORCPT"} =~ /;/
ABresult
0X0
100
111
930 4 for (qw(ENVID ORCPT)) {
931 8 $self->{esmtp}{$_} = enc_xtext($self->{esmtp}{$_});
932 }
933 }
934  
935 10 ▶sub _prepare_headers {
Subroutine _prepare_headers: called CC=9 SCAR=22.0
936 10 my $self = shift;
937 10 ▶ return unless exists $self->{'headers'};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"headers"} 1 9 10
938 9 ▶ if ($self->{'headers'} eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"headers"} eq "") 5 4 9
939 5 delete $self->{'headers'};
940 5 delete $self->{'_headers'};
941 5 return;
942 }
943 4 ▶ if (ref($self->{'headers'}) eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $self->{'headers'} eq 'HASH') { } 2 2 4
elsif (ref $self->{'headers'}) { } 1 1 2
944 2 my $headers = '';
945 2 ▶ while (my ($hdr, $value) = each %{$self->{'headers'}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$self{"headers"};}) 2 2 4
946 2 for ($hdr, $value) {
947 4 s/(?:\x0D\x0A?|\x0A)/\x0D\x0A/sg
948 ; # convert all end-of-lines to CRLF
949 4 s/^(?:\x0D\x0A)+//; # strip leading
950 4 s/(?:\x0D\x0A)+$//; # and trailing end-of-lines
951 4 s/\x0D\x0A(\S)/\x0D\x0A\t$1/sg;
952 4 ▶ if (length($_) > 997) { # header too long, max 1000 chars
Branch: 1 branch
BranchTrueFalseTotal
if (length $_ > 997) 1 3 4
953 1 s/(.{1,980}[;,])\s+(\S)/$1\x0D\x0A\t$2/g;
954 }
955 }
956 2 $headers .= "$hdr: $value\x0D\x0A";
957 }
958 2 $headers =~ s/(?:\x0D\x0A)+$//; # and trailing end-of-lines
959 2 $self->{'_headers'} = $headers;
960 }
961 elsif (ref($self->{'headers'})) {
962 }
963 else {
964 1 $self->{'_headers'} = $self->{'headers'};
965 1 for ($self->{'_headers'}) {
966 1 s/(?:\x0D\x0A?|\x0A)/\x0D\x0A/sg; # convert all end-of-lines to CRLF
967 1 s/^(?:\x0D\x0A)+//; # strip leading
968 1 s/(?:\x0D\x0A)+$//; # and trailing end-of-lines
969 }
970 }
971 }
972  
973 0 ▶sub Open {
Subroutine Open: not called CC=101 SCAR=92.4
Pod documented
974 0 undef $Error;
975 0 my $self = shift;
976 0 local $_;
977 0 ▶ if (!$self->{'keepconnection'} and $self->{'_data'})
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"keepconnection"} and $self->{"_data"}) 0 0 0
Condition0%0/3
not $self->{"keepconnection"} and $self->{"_data"}
!ll&&!rl&&r
000
MC/DC0%0/2
not $self->{"keepconnection"} and $self->{"_data"}
not $self->{"keepconnection"} $self->{"_data"}
Truth table0%0/3
not(A) and B
A= not $self->{"keepconnection"}B= $self->{"_data"}
ABresult
0X0
100
111
978 { # the user did not Close() or Cancel() the previous mail
979 0 ▶ if ($self->{'error'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'error'}) { } 0 0 0
980 0 $self->Cancel;
981 }
982 else {
983 0 $self->Close;
984 }
985 }
986  
987 0 delete $self->{'error'};
988 0 delete $self->{'encoding'};
989 0 delete $self->{'messageid'};
990 0 my %changed;
991 0 $self->{'multipart'} = 0;
992 0 $self->{'_had_newline'} = 1;
993  
994 0 ▶ if (ref $_[0] eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 0 0
995 0 my $key;
996 0 my $hash = $_[0];
997 $hash->{'reply'} = $hash->{'replyto'}
998 0 ▶ if (defined $hash->{'replyto'} and !defined $hash->{'reply'});
Branch: 1 branch
BranchTrueFalseTotal
if defined $hash->{"replyto"} and not defined $hash->{"reply"} 0 0 0
Condition0%0/3
defined $hash->{"replyto"} and not defined $hash->{"reply"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $hash->{"replyto"} and not defined $hash->{"reply"}
defined $hash->{"replyto"} not defined $hash->{"reply"}
Truth table0%0/3
A and not(B)
A= defined $hash->{"replyto"}B= not defined $hash->{"reply"}
ABresult
0X0
100
111
999 0 foreach $key (keys %$hash) {
1000 0 ▶ if (ref($hash->{$key}) eq 'HASH' and exists $self->{lc $key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $hash->{$key} eq 'HASH' and exists $$self{lc $key}) { } 0 0 0
Condition0%0/3
ref $hash->{$key} eq "HASH" and exists $$self{lc $key}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $hash->{$key} eq "HASH" and exists $$self{lc $key}
ref $hash->{$key} eq "HASH" exists $$self{lc $key}
Truth table0%0/3
A and B
A= ref $hash->{$key} eq "HASH"B= exists $$self{lc $key}
ABresult
0X0
100
111
1001 0 ▶ if (ref($self->{lc $key}) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $$self{lc $key} eq 'HASH') { } 0 0 0
1002 0 $self->{lc $key} = {%{$self->{lc $key}}, %{$hash->{$key}}};
1003 }
1004 else {
1005 0 $self->{lc $key} = {%{$hash->{$key}}}; # make a shallow copy
1006 }
1007 }
1008 else {
1009 0 $self->{lc $key} = $hash->{$key};
1010 }
1011 0 $changed{lc $key} = 1;
1012 }
1013 }
1014 else {
1015 0 my ($from, $reply, $to, $smtp, $subject, $headers) = @_;
1016  
1017 0 ▶ if ($from) { $self->{'from'} = $from; $changed{'from'} = 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($from) 0 0 0
1018 0 ▶ if ($reply) { $self->{'reply'} = $reply; $changed{'reply'} = 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($reply) 0 0 0
1019 0 ▶ if ($to) { $self->{'to'} = $to; $changed{'to'} = 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($to) 0 0 0
1020 0 ▶ if ($smtp) { $self->{'smtp'} = $smtp; $changed{'smtp'} = 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($smtp) 0 0 0
1021 0 ▶ if ($subject) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subject) 0 0 0
1022 0 $self->{'subject'} = $subject;
1023 0 $changed{'subject'} = 1;
1024 }
1025 0 ▶ if ($headers) {
Branch: 1 branch
BranchTrueFalseTotal
if ($headers) 0 0 0
1026 0 $self->{'headers'} = $headers;
1027 0 $changed{'headers'} = 1;
1028 }
1029 }
1030  
1031 0 ▶ $self->_prepare_addresses('to') if $changed{'to'};
Branch: 1 branch
BranchTrueFalseTotal
if $changed{"to"} 0 0 0
1032 0 ▶ $self->_prepare_addresses('cc') if $changed{'cc'};
Branch: 1 branch
BranchTrueFalseTotal
if $changed{"cc"} 0 0 0
1033 0 ▶ $self->_prepare_addresses('bcc') if $changed{'bcc'};
Branch: 1 branch
BranchTrueFalseTotal
if $changed{"bcc"} 0 0 0
1034  
1035 0 ▶ $self->_prepare_ESMTP() if defined $changed{'esmtp'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $changed{"esmtp"} 0 0 0
1036  
1037 0 ▶ $self->{'boundary'} =~ tr/=/-/ if defined $changed{'boundary'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $changed{"boundary"} 0 0 0
1038  
1039 0 ▶ return $self->Error(_NOFROMSPECIFIED) unless defined $self->{'from'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"from"} 0 0 0
1040  
1041 0 ▶ if ($changed{'from'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($changed{"from"}) 0 0 0
1042 0 $self->{'fromaddr'} = $self->{'from'};
1043 0 $self->{'fromaddr'} =~ s/.*<([^\s]*?)>/$1/; # get from email address
1044 }
1045  
1046 0 ▶ if ($changed{'reply'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($changed{"reply"}) 0 0 0
1047 0 $self->{'replyaddr'} = $self->{'reply'};
1048 0 $self->{'replyaddr'} =~ s/.*<([^\s]*?)>/$1/; # get reply email address
1049 0 $self->{'replyaddr'} =~ s/^([^\s]+).*/$1/; # use first address
1050 }
1051  
1052 0 ▶ if ($changed{'smtp'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($changed{"smtp"}) 0 0 0
1053 0 $self->{'smtp'} =~ s/^\s+//g; # remove spaces around $smtp
1054 0 $self->{'smtp'} =~ s/\s+$//g;
1055 0 $self->{'smtpaddr'} = Socket::inet_aton($self->{'smtp'});
1056 0 ▶ if (!defined($self->{'smtpaddr'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"smtpaddr"}) 0 0 0
1057 0 return $self->Error(_HOSTNOTFOUND($self->{'smtp'}));
1058 }
1059 0 ▶ $self->{'smtpaddr'} = $1 if ($self->{'smtpaddr'} =~ /(.*)/s); # Untaint
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"smtpaddr"} =~ /(.*)/s 0 0 0
1060 0 ▶ if (exists $self->{'socket'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"socket"}) 0 0 0
1061 0 my $s = $self->{'socket'};
1062 0 close $s;
1063 0 delete $self->{'socket'};
1064 }
1065 }
1066  
1067 0 ▶ $self->_prepare_headers() if ($changed{'headers'});
Branch: 1 branch
BranchTrueFalseTotal
if $changed{"headers"} 0 0 0
1068  
1069 0 ▶ if (!$self->{'to'}) { return $self->Error(_TOEMPTY); }
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"to"}) 0 0 0
1070  
1071 0 ▶ return $self->Error(_NOSERVER) unless defined $self->{'smtp'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"smtp"} 0 0 0
1072  
1073 0 ▶ if ($Mail::Sender::{'SiteHook'} and !$self->SiteHook()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Mail::Sender::{"SiteHook"} and not $self->SiteHook) 0 0 0
Condition0%0/3
$Mail::Sender::{"SiteHook"} and not $self->SiteHook
!ll&&!rl&&r
000
MC/DC0%0/2
$Mail::Sender::{"SiteHook"} and not $self->SiteHook
$Mail::Sender::{"SiteHook"} not $self->SiteHook
Truth table0%0/3
A and not(B)
A= $Mail::Sender::{"SiteHook"}B= not $self->SiteHook
ABresult
0X0
100
111
1074 0 ▶ return defined $self->{'error'} ? $self->{'error'} : $self->{'error'}
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'error'} ? : 0 0 0
1075 = _SITEERROR();
1076 }
1077  
1078 0 ▶ my $s = $self->{'socket'} || $self->Connect();
Condition0%0/3
$self->{'socket'} || $self->Connect
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{'socket'} || $self->Connect
$self->{'socket'} $self->Connect
Truth table0%0/3
A || B
A= $self->{'socket'}B= $self->Connect
ABresult
1X1
011
000
1079 0 ▶ return $s
Branch: 1 branch
BranchTrueFalseTotal
unless ref $s 0 0 0
1080 unless ref $s; # return the error number if we did not get a socket
1081 0 $self->{'socket'} = $s;
1082  
1083 $_ = send_cmd $s,
1084 0 ▶ "MAIL FROM:<".($self->{'fromaddr'}||'').">".($self->{esmtp}{_MAIL_FROM}||'');
Condition0%0/4
$self->{'fromaddr'} || ''
l!l
00
$self->{'esmtp'}{'_MAIL_FROM'} || ''
l!l
00
MC/DC0%0/1
$self->{'fromaddr'} || ''
$self->{'fromaddr'}
MC/DC0%0/1
$self->{'esmtp'}{'_MAIL_FROM'} || ''
$self->{'esmtp'}{'_MAIL_FROM'}
Truth table0%0/2
A
A= $self->{'fromaddr'}
Aresult
11
00
Truth table0%0/2
A
A= $self->{'esmtp'}{'_MAIL_FROM'}
Aresult
11
00
1085 0 ▶ if (!/^[123]/) { return $self->Error(_COMMERROR($_)); }
Branch: 1 branch
BranchTrueFalseTotal
unless (/^[123]/) 0 0 0
1086  
1087 {
1088 0 local $^W;
1089 0 ▶ if ($self->{'skip_bad_recipients'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'skip_bad_recipients'}) { } 0 0 0
1090 0 my $good_count = 0;
1091 0 my %failed;
1092 0 foreach my $addr (
1093 0 @{$self->{'to_list'}},
1094 0 @{$self->{'cc_list'}},
1095 0 @{$self->{'bcc_list'}}
1096 )
1097 {
1098 0 ▶ if ($addr =~ /<(.*)>/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($addr =~ /<(.*)>/) { } 0 0 0
1099 0 $_ = send_cmd $s, "RCPT TO:<$1>$self->{esmtp}{_RCPT_TO}";
1100 }
1101 else {
1102 0 $_ = send_cmd $s, "RCPT TO:<$addr>$self->{esmtp}{_RCPT_TO}";
1103 }
1104 0 ▶ if (!/^[123]/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not /^[123]/) { } 0 0 0
1105 0 chomp;
1106 0 s/^\d{3} //;
1107 0 $failed{$addr} = $_;
1108 }
1109 else {
1110 0 $good_count++;
1111 }
1112 }
1113 0 ▶ $self->{'skipped_recipients'} = \%failed if %failed;
Branch: 1 branch
BranchTrueFalseTotal
if %failed 0 0 0
1114 0 ▶ if ($good_count == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($good_count == 0) 0 0 0
1115 0 return $self->Error(_ALLRECIPIENTSBAD);
1116 }
1117 }
1118 else {
1119 0 foreach my $addr (
1120 0 @{$self->{'to_list'}},
1121 0 @{$self->{'cc_list'}},
1122 0 @{$self->{'bcc_list'}}
1123 )
1124 {
1125 0 ▶ if ($addr =~ /<(.*)>/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($addr =~ /<(.*)>/) { } 0 0 0
1126 0 $_ = send_cmd $s, "RCPT TO:<$1>$self->{esmtp}{_RCPT_TO}";
1127 }
1128 else {
1129 0 ▶ $_ = send_cmd $s, "RCPT TO:<".($addr||'').">".($self->{esmtp}{_RCPT_TO}||'');
Condition0%0/4
$addr || ''
l!l
00
$self->{'esmtp'}{'_RCPT_TO'} || ''
l!l
00
MC/DC0%0/1
$addr || ''
$addr
MC/DC0%0/1
$self->{'esmtp'}{'_RCPT_TO'} || ''
$self->{'esmtp'}{'_RCPT_TO'}
Truth table0%0/2
A
A= $addr
Aresult
11
00
Truth table0%0/2
A
A= $self->{'esmtp'}{'_RCPT_TO'}
Aresult
11
00
1130 }
1131 0 ▶ if (!/^[123]/) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/^[123]/) 0 0 0
1132 return $self->Error(
1133 0 _USERUNKNOWN($addr, $self->{'smtp'}, $_));
1134 }
1135 }
1136 }
1137 }
1138  
1139 0 $_ = send_cmd $s, "DATA";
1140 0 ▶ if (!/^[123]/) { return $self->Error(_COMMERROR($_)); }
Branch: 1 branch
BranchTrueFalseTotal
unless (/^[123]/) 0 0 0
1141  
1142 $self->{'socket'}
1143 ->stop_logging("\x0D\x0A... message headers and data skipped ...")
1144 0 ▶ if ($self->{'debug'} and $self->{'debug_level'} <= 1);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} and $self->{"debug_level"} <= 1 0 0 0
Condition0%0/3
$self->{"debug"} and $self->{"debug_level"} <= 1
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"debug"} and $self->{"debug_level"} <= 1
$self->{"debug"} $self->{"debug_level"} <= 1
Truth table0%0/3
A and B
A= $self->{"debug"}B= $self->{"debug_level"} <= 1
ABresult
0X0
100
111
1145 0 $self->{'_data'} = 1;
1146  
1147 $self->{'ctype'} = 'text/plain'
1148 0 ▶ if (defined $self->{'charset'} and !defined $self->{'ctype'});
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"charset"} and not defined $self->{"ctype"} 0 0 0
Condition0%0/3
defined $self->{"charset"} and not defined $self->{"ctype"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"charset"} and not defined $self->{"ctype"}
defined $self->{"charset"} not defined $self->{"ctype"}
Truth table0%0/3
A and not(B)
A= defined $self->{"charset"}B= not defined $self->{"ctype"}
ABresult
0X0
100
111
1149  
1150 0 my $headers;
1151 0 ▶ if (defined $self->{'encoding'} or defined $self->{'ctype'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"encoding"} or defined $self->{"ctype"}) 0 0 0
Condition0%0/3
defined $self->{"encoding"} or defined $self->{"ctype"}
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $self->{"encoding"} or defined $self->{"ctype"}
defined $self->{"encoding"} defined $self->{"ctype"}
Truth table0%0/3
A or B
A= defined $self->{"encoding"}B= defined $self->{"ctype"}
ABresult
1X1
011
000
1152 0 $headers = 'MIME-Version: 1.0';
1153 $headers .= "\r\nContent-Type: $self->{'ctype'}"
1154 0 ▶ if defined $self->{'ctype'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"ctype"} 0 0 0
1155 $headers .= "; charset=$self->{'charset'}"
1156 0 ▶ if defined $self->{'charset'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"charset"} 0 0 0
1157  
1158 0 undef $self->{'chunk_size'};
1159 0 ▶ if (defined $self->{'encoding'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"encoding"}) 0 0 0
1160 0 $headers .= "\r\nContent-Transfer-Encoding: $self->{'encoding'}";
1161 0 ▶ if ($self->{'encoding'} =~ /Base64/i) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->{'encoding'} =~ /Base64/i) { } 0 0 0
elsif ($self->{'encoding'} =~ /Quoted[_\-]print/i) { } 0 0 0
elsif ($self->{'encoding'} =~ /^[78]bit$/i) { } 0 0 0
1162 0 $self->{'code'} = enc_base64($self->{'charset'});
1163 0 $self->{'chunk_size'} = $enc_base64_chunk;
1164 }
1165 elsif ($self->{'encoding'} =~ /Quoted[_\-]print/i) {
1166 0 $self->{'code'} = enc_qp($self->{'charset'});
1167 }
1168 elsif ($self->{'encoding'} =~ /^[78]bit$/i) {
1169 0 $self->{'code'} = enc_plain($self->{charset});
1170 }
1171 else {
1172 0 return $self->Error(_UNKNOWNENCODING($self->{'encoding'}));
1173 }
1174 }
1175 }
1176  
1177 0 ▶ $self->{'code'} = enc_plain($self->{charset}) unless $self->{'code'};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"code"} 0 0 0
1178  
1179 _print_hdr $s,
1180 "To" =>
1181 (defined $self->{'fake_to'} ? $self->{'fake_to'} : $self->{'to'}),
1182 0 ▶ $self->{'charset'};
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'fake_to'} ? : 0 0 0
1183 _print_hdr $s,
1184 "From" =>
1185 (defined $self->{'fake_from'} ? $self->{'fake_from'} : $self->{'from'}),
1186 0 ▶ $self->{'charset'};
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'fake_from'} ? : 0 0 0
1187 0 ▶ if (defined $self->{'fake_cc'} and $self->{'fake_cc'}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $self->{'fake_cc'} and $self->{'fake_cc'}) { } 0 0 0
elsif (defined $self->{'cc'} and $self->{'cc'}) { } 0 0 0
Condition0%0/3
defined $self->{"fake_cc"} and $self->{"fake_cc"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"fake_cc"} and $self->{"fake_cc"}
defined $self->{"fake_cc"} $self->{"fake_cc"}
Truth table0%0/3
A and B
A= defined $self->{"fake_cc"}B= $self->{"fake_cc"}
ABresult
0X0
100
111
1188 0 _print_hdr $s, "Cc" => $self->{'fake_cc'}, $self->{'charset'};
1189 }
1190 ▶ elsif (defined $self->{'cc'} and $self->{'cc'}) {
Condition0%0/3
defined $self->{"cc"} and $self->{"cc"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"cc"} and $self->{"cc"}
defined $self->{"cc"} $self->{"cc"}
Truth table0%0/3
A and B
A= defined $self->{"cc"}B= $self->{"cc"}
ABresult
0X0
100
111
1191 0 _print_hdr $s, "Cc" => $self->{'cc'}, $self->{'charset'};
1192 }
1193 _print_hdr $s, "Reply-To", $self->{'reply'}, $self->{'charset'}
1194 0 ▶ if defined $self->{'reply'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"reply"} 0 0 0
1195  
1196 0 ▶ $self->{'subject'} = "<No subject>" unless defined $self->{'subject'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"subject"} 0 0 0
1197 0 _print_hdr $s, "Subject" => $self->{'subject'}, $self->{'charset'};
1198  
1199 0 ▶ unless (defined $Mail::Sender::NO_DATE and $Mail::Sender::NO_DATE
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Mail::Sender::NO_DATE and $Mail::Sender::NO_DATE or defined $self->{"_headers"} and $self->{"_headers"} =~ /^Date:/m or defined $Mail::Sender::SITE_HEADERS and $Mail::Sender::SITE_HEADERS =~ /^Date:/m) 0 0 0
Condition0%0/15
defined $Mail::Sender::NO_DATE and $Mail::Sender::NO_DATE or defined $self->{"_headers"} and $self->{"_headers"} =~ /^Date:/m or defined $Mail::Sender::SITE_HEADERS and $Mail::Sender::SITE_HEADERS =~ /^Date:/m
l!l&&r!l&&!r
000
defined $Mail::Sender::NO_DATE and $Mail::Sender::NO_DATE or defined $self->{"_headers"} and $self->{"_headers"} =~ /^Date:/m
l!l&&r!l&&!r
000
defined $Mail::Sender::NO_DATE and $Mail::Sender::NO_DATE
!ll&&!rl&&r
000
defined $self->{"_headers"} and $self->{"_headers"} =~ /^Date:/m
!ll&&!rl&&r
000
defined $Mail::Sender::SITE_HEADERS and $Mail::Sender::SITE_HEADERS =~ /^Date:/m
!ll&&!rl&&r
000
MC/DC0%0/6
defined $Mail::Sender::NO_DATE and $Mail::Sender::NO_DATE or defined $self->{"_headers"} and $self->{"_headers"} =~ /^Date:/m or defined $Mail::Sender::SITE_HEADERS and $Mail::Sender::SITE_HEADERS =~ /^Date:/m
defined $Mail::Sender::NO_DATE $Mail::Sender::NO_DATE defined $self->{"_headers"} $self->{"_headers"} =~ /^Date:/m defined $Mail::Sender::SITE_HEADERS $Mail::Sender::SITE_HEADERS =~ /^Date:/m
Truth table0%0/15
A and B or C and D or E and F
A= defined $Mail::Sender::NO_DATEB= $Mail::Sender::NO_DATEC= defined $self->{"_headers"}D= $self->{"_headers"} =~ /^Date:/mE= defined $Mail::Sender::SITE_HEADERSF= $Mail::Sender::SITE_HEADERS =~ /^Date:/m
ABCDEFresult
11XXXX1
0X11XX1
1011XX1
0X0X111
0X10111
100X111
1010111
0X0X0X0
0X0X100
0X100X0
0X10100
100X0X0
100X100
10100X0
1010100
1200 or defined $self->{'_headers'} and $self->{'_headers'} =~ /^Date:/m
1201 or defined $Mail::Sender::SITE_HEADERS
1202 && $Mail::Sender::SITE_HEADERS =~ /^Date:/m)
1203 {
1204 0 my $date = localtime();
1205 0 $date
1206 =~ s/^(\w+)\s+(\w+)\s+(\d+)\s+(\d+:\d+:\d+)\s+(\d+)$/$1, $3 $2 $5 $4/;
1207 0 _print_hdr $s, "Date" => "$date $GMTdiff";
1208 }
1209  
1210 0 ▶ if ($self->{'priority'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"priority"}) 0 0 0
1211 $self->{'priority'} = $priority[$self->{'priority'}]
1212 0 ▶ if ($self->{'priority'} + 0 eq $self->{'priority'});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"priority"} + 0 eq $self->{"priority"} 0 0 0
1213 0 _print_hdr $s, "X-Priority" => $self->{'priority'};
1214 }
1215  
1216 0 ▶ if ($self->{'confirm'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"confirm"}) 0 0 0
1217 0 for my $confirm (split /\s*,\s*/, $self->{'confirm'}) {
1218 0 ▶ if ($confirm =~ /^\s*reading\s*(?:\:\s*(.*))?/i) {
Branch: 2 branches
BranchTrueFalseTotal
if ($confirm =~ /^\s*reading\s*(?:\:\s*(.*))?/i) { } 0 0 0
elsif ($confirm =~ /^\s*delivery\s*(?:\:\s*(.*))?/i) { } 0 0 0
1219 _print_hdr $s,
1220 "X-Confirm-Reading-To" => ($1 || $self->{'from'}),
1221 0 ▶ $self->{'charset'};
Condition0%0/3
$1 || $self->{'from'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$1 || $self->{'from'}
$1 $self->{'from'}
Truth table0%0/3
A || B
A= $1B= $self->{'from'}
ABresult
1X1
011
000
1222 }
1223 elsif ($confirm =~ /^\s*delivery\s*(?:\:\s*(.*))?/i) {
1224 _print_hdr $s,
1225 "Return-Receipt-To" => ($1 || $self->{'fromaddr'}),
1226 0 ▶ $self->{'charset'};
Condition0%0/3
$1 || $self->{'fromaddr'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$1 || $self->{'fromaddr'}
$1 $self->{'fromaddr'}
Truth table0%0/3
A || B
A= $1B= $self->{'fromaddr'}
ABresult
1X1
011
000
1227 _print_hdr $s,
1228 "Disposition-Notification-To" =>
1229 ($1 || $self->{'fromaddr'}),
1230 0 ▶ $self->{'charset'};
Condition0%0/3
$1 || $self->{'fromaddr'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$1 || $self->{'fromaddr'}
$1 $self->{'fromaddr'}
Truth table0%0/3
A || B
A= $1B= $self->{'fromaddr'}
ABresult
1X1
011
000
1231 }
1232 }
1233 }
1234  
1235 0 ▶ unless (defined $Mail::Sender::NO_X_MAILER) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Mail::Sender::NO_X_MAILER) 0 0 0
1236 0 my $script = File::Basename::basename($0);
1237 0 _print_hdr $s,
1238 "X-Mailer" =>
1239 qq{Perl script "$script"\r\n\tusing Mail::Sender $VERSION by Jenda Krynicky, Czechlands\r\n\trunning on $local_name ($local_IP)\r\n\tunder account "}
1240 . getusername()
1241 . qq{"\r\n};
1242 }
1243  
1244 0 ▶ unless (defined $Mail::Sender::NO_MESSAGE_ID
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Mail::Sender::NO_MESSAGE_ID and $Mail::Sender::NO_MESSAGE_ID) 0 0 0
Condition0%0/3
defined $Mail::Sender::NO_MESSAGE_ID and $Mail::Sender::NO_MESSAGE_ID
!ll&&!rl&&r
000
MC/DC0%0/2
defined $Mail::Sender::NO_MESSAGE_ID and $Mail::Sender::NO_MESSAGE_ID
defined $Mail::Sender::NO_MESSAGE_ID $Mail::Sender::NO_MESSAGE_ID
Truth table0%0/3
A and B
A= defined $Mail::Sender::NO_MESSAGE_IDB= $Mail::Sender::NO_MESSAGE_ID
ABresult
0X0
100
111
1245 and $Mail::Sender::NO_MESSAGE_ID)
1246 {
1247 0 ▶ if (!defined $self->{'messageid'} or $self->{'messageid'} eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{"messageid"} or $self->{"messageid"} eq "") 0 0 0
Condition0%0/3
not defined $self->{"messageid"} or $self->{"messageid"} eq ""
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $self->{"messageid"} or $self->{"messageid"} eq ""
not defined $self->{"messageid"} $self->{"messageid"} eq ""
Truth table0%0/3
not(A) or B
A= not defined $self->{"messageid"}B= $self->{"messageid"} eq ""
ABresult
1X1
011
000
1248 0 ▶ if (defined $self->{'createmessageid'}
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'createmessageid'} and ref $self->{'createmessageid'} eq 'CODE') { } 0 0 0
Condition0%0/3
defined $self->{"createmessageid"} and ref $self->{"createmessageid"} eq "CODE"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"createmessageid"} and ref $self->{"createmessageid"} eq "CODE"
defined $self->{"createmessageid"} ref $self->{"createmessageid"} eq "CODE"
Truth table0%0/3
A and B
A= defined $self->{"createmessageid"}B= ref $self->{"createmessageid"} eq "CODE"
ABresult
0X0
100
111
1249 and ref $self->{'createmessageid'} eq 'CODE')
1250 {
1251 $self->{'messageid'}
1252 0 = $self->{'createmessageid'}->($self->{'fromaddr'});
1253 }
1254 else {
1255 0 $self->{'messageid'} = MessageID($self->{'fromaddr'});
1256 }
1257 }
1258 0 _print_hdr $s, "Message-ID" => $self->{'messageid'};
1259 }
1260  
1261 0 ▶ print $s $Mail::Sender::SITE_HEADERS,
Branch: 1 branch
BranchTrueFalseTotal
if defined $Mail::Sender::SITE_HEADERS 0 0 0
1262 "\x0D\x0A" #<???> should handle \r\n at the end of the headers
1263 if (defined $Mail::Sender::SITE_HEADERS);
1264  
1265 print $s $self->{'_headers'}, "\x0D\x0A"
1266 0 ▶ if defined $self->{'_headers'} and $self->{'_headers'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"_headers"} and $self->{"_headers"} 0 0 0
Condition0%0/3
defined $self->{"_headers"} and $self->{"_headers"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"_headers"} and $self->{"_headers"}
defined $self->{"_headers"} $self->{"_headers"}
Truth table0%0/3
A and B
A= defined $self->{"_headers"}B= $self->{"_headers"}
ABresult
0X0
100
111
1267 0 ▶ print $s $headers, "\r\n" if defined $headers;
Branch: 1 branch
BranchTrueFalseTotal
if defined $headers 0 0 0
1268  
1269 0 print $s "\r\n";
1270  
1271 $self->{'socket'}->stop_logging("... message data skipped ...")
1272 0 ▶ if ($self->{'debug'} and $self->{'debug_level'} <= 2);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} and $self->{"debug_level"} <= 2 0 0 0
Condition0%0/3
$self->{"debug"} and $self->{"debug_level"} <= 2
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"debug"} and $self->{"debug_level"} <= 2
$self->{"debug"} $self->{"debug_level"} <= 2
Truth table0%0/3
A and B
A= $self->{"debug"}B= $self->{"debug_level"} <= 2
ABresult
0X0
100
111
1273  
1274 0 return $self;
1275 }
1276  
1277 0 ▶sub OpenMultipart {
Subroutine OpenMultipart: not called CC=92 SCAR=90.5
Pod documented
1278 0 undef $Error;
1279 0 my $self = shift;
1280  
1281 0 local $_;
1282 0 ▶ if (!$self->{'keepconnection'} and $self->{'_data'})
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"keepconnection"} and $self->{"_data"}) 0 0 0
Condition0%0/3
not $self->{"keepconnection"} and $self->{"_data"}
!ll&&!rl&&r
000
MC/DC0%0/2
not $self->{"keepconnection"} and $self->{"_data"}
not $self->{"keepconnection"} $self->{"_data"}
Truth table0%0/3
not(A) and B
A= not $self->{"keepconnection"}B= $self->{"_data"}
ABresult
0X0
100
111
1283 { # the user did not Close() or Cancel() the previous mail
1284 0 ▶ if ($self->{'error'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'error'}) { } 0 0 0
1285 0 $self->Cancel;
1286 }
1287 else {
1288 0 $self->Close;
1289 }
1290 }
1291  
1292 0 delete $self->{'error'};
1293 0 delete $self->{'encoding'};
1294 0 delete $self->{'messageid'};
1295 0 $self->{'_part'} = 0;
1296  
1297 0 my %changed;
1298 0 ▶ if (defined $self->{'type'} and $self->{'type'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"type"} and $self->{"type"}) 0 0 0
Condition0%0/3
defined $self->{"type"} and $self->{"type"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"type"} and $self->{"type"}
defined $self->{"type"} $self->{"type"}
Truth table0%0/3
A and B
A= defined $self->{"type"}B= $self->{"type"}
ABresult
0X0
100
111
1299 0 ▶ $self->{'multipart'} = $1 if $self->{'type'} =~ m{^multipart/(.*)}i;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"type"} =~ m[^multipart/(.*)]i 0 0 0
1300 }
1301 0 ▶ $self->{'multipart'} = 'Mixed' unless $self->{'multipart'};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"multipart"} 0 0 0
1302 0 $self->{'idcounter'} = 0;
1303  
1304 0 ▶ if (ref $_[0] eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 0 0
1305 0 my $key;
1306 0 my $hash = $_[0];
1307 0 ▶ $hash->{'multipart'} = $hash->{'subtype'} if defined $hash->{'subtype'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $hash->{"subtype"} 0 0 0
1308 $hash->{'reply'} = $hash->{'replyto'}
1309 0 ▶ if (defined $hash->{'replyto'} and !defined $hash->{'reply'});
Branch: 1 branch
BranchTrueFalseTotal
if defined $hash->{"replyto"} and not defined $hash->{"reply"} 0 0 0
Condition0%0/3
defined $hash->{"replyto"} and not defined $hash->{"reply"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $hash->{"replyto"} and not defined $hash->{"reply"}
defined $hash->{"replyto"} not defined $hash->{"reply"}
Truth table0%0/3
A and not(B)
A= defined $hash->{"replyto"}B= not defined $hash->{"reply"}
ABresult
0X0
100
111
1310 0 foreach $key (keys %$hash) {
1311 0 ▶ if ((ref($hash->{$key}) eq 'HASH') and exists($self->{lc $key})) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $hash->{$key} eq 'HASH' and exists $$self{lc $key}) { } 0 0 0
Condition0%0/3
ref $hash->{$key} eq "HASH" and exists $$self{lc $key}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $hash->{$key} eq "HASH" and exists $$self{lc $key}
ref $hash->{$key} eq "HASH" exists $$self{lc $key}
Truth table0%0/3
A and B
A= ref $hash->{$key} eq "HASH"B= exists $$self{lc $key}
ABresult
0X0
100
111
1312 0 ▶ if (ref($self->{lc $key}) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $$self{lc $key} eq 'HASH') { } 0 0 0
1313 0 $self->{lc $key} = {%{$self->{lc $key}}, %{$hash->{$key}}};
1314 }
1315 else {
1316 0 $self->{lc $key} = {%{$hash->{$key}}}; # make a shallow copy
1317 }
1318 }
1319 else {
1320 0 $self->{lc $key} = $hash->{$key};
1321 }
1322 0 $changed{lc $key} = 1;
1323 }
1324 }
1325 else {
1326 0 my ($from, $reply, $to, $smtp, $subject, $headers, $boundary) = @_;
1327  
1328 0 ▶ if ($from) { $self->{'from'} = $from; $changed{'from'} = 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($from) 0 0 0
1329 0 ▶ if ($reply) { $self->{'reply'} = $reply; $changed{'reply'} = 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($reply) 0 0 0
1330 0 ▶ if ($to) { $self->{'to'} = $to; $changed{'to'} = 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($to) 0 0 0
1331 0 ▶ if ($smtp) { $self->{'smtp'} = $smtp; $changed{'smtp'} = 1; }
Branch: 1 branch
BranchTrueFalseTotal
if ($smtp) 0 0 0
1332 0 ▶ if ($subject) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subject) 0 0 0
1333 0 $self->{'subject'} = $subject;
1334 0 $changed{'subject'} = 1;
1335 }
1336 0 ▶ if ($headers) {
Branch: 1 branch
BranchTrueFalseTotal
if ($headers) 0 0 0
1337 0 $self->{'headers'} = $headers;
1338 0 $changed{'headers'} = 1;
1339 }
1340 0 ▶ if ($boundary) { $self->{'boundary'} = $boundary; }
Branch: 1 branch
BranchTrueFalseTotal
if ($boundary) 0 0 0
1341 }
1342  
1343 0 ▶ $self->_prepare_addresses('to') if $changed{'to'};
Branch: 1 branch
BranchTrueFalseTotal
if $changed{"to"} 0 0 0
1344 0 ▶ $self->_prepare_addresses('cc') if $changed{'cc'};
Branch: 1 branch
BranchTrueFalseTotal
if $changed{"cc"} 0 0 0
1345 0 ▶ $self->_prepare_addresses('bcc') if $changed{'bcc'};
Branch: 1 branch
BranchTrueFalseTotal
if $changed{"bcc"} 0 0 0
1346  
1347 0 ▶ $self->_prepare_ESMTP() if defined $changed{'esmtp'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $changed{"esmtp"} 0 0 0
1348  
1349 0 ▶ $self->{'boundary'} =~ tr/=/-/ if $changed{'boundary'};
Branch: 1 branch
BranchTrueFalseTotal
if $changed{"boundary"} 0 0 0
1350  
1351 0 ▶ $self->_prepare_headers() if ($changed{'headers'});
Branch: 1 branch
BranchTrueFalseTotal
if $changed{"headers"} 0 0 0
1352  
1353 0 ▶ return $self->Error(_NOFROMSPECIFIED) unless defined $self->{'from'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"from"} 0 0 0
1354 0 ▶ if ($changed{'from'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($changed{"from"}) 0 0 0
1355 0 $self->{'fromaddr'} = $self->{'from'};
1356 0 $self->{'fromaddr'} =~ s/.*<([^\s]*?)>/$1/; # get from email address
1357 }
1358  
1359 0 ▶ if ($changed{'reply'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($changed{"reply"}) 0 0 0
1360 0 $self->{'replyaddr'} = $self->{'reply'};
1361 0 $self->{'replyaddr'} =~ s/.*<([^\s]*?)>/$1/; # get reply email address
1362 0 $self->{'replyaddr'} =~ s/^([^\s]+).*/$1/; # use first address
1363 }
1364  
1365 0 ▶ if ($changed{'smtp'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($changed{"smtp"}) 0 0 0
1366 0 $self->{'smtp'} =~ s/^\s+//g; # remove spaces around $smtp
1367 0 $self->{'smtp'} =~ s/\s+$//g;
1368 0 $self->{'smtpaddr'} = Socket::inet_aton($self->{'smtp'});
1369 0 ▶ if (!defined($self->{'smtpaddr'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"smtpaddr"}) 0 0 0
1370 0 return $self->Error(_HOSTNOTFOUND($self->{'smtp'}));
1371 }
1372 0 ▶ $self->{'smtpaddr'} = $1 if ($self->{'smtpaddr'} =~ /(.*)/s); # Untaint
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"smtpaddr"} =~ /(.*)/s 0 0 0
1373 0 ▶ if (exists $self->{'socket'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"socket"}) 0 0 0
1374 0 my $s = $self->{'socket'};
1375 0 close $s;
1376 0 delete $self->{'socket'};
1377 }
1378 }
1379  
1380 0 ▶ if (!$self->{'to'}) { return $self->Error(_TOEMPTY); }
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"to"}) 0 0 0
1381  
1382 0 ▶ return $self->Error(_NOSERVER) unless defined $self->{'smtp'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"smtp"} 0 0 0
1383  
1384 # if (!defined($self->{'smtpaddr'})) { return $self->Error(_HOSTNOTFOUND($self->{'smtp'})); }
1385  
1386 0 ▶ if ($Mail::Sender::{'SiteHook'} and !$self->SiteHook()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Mail::Sender::{"SiteHook"} and not $self->SiteHook) 0 0 0
Condition0%0/3
$Mail::Sender::{"SiteHook"} and not $self->SiteHook
!ll&&!rl&&r
000
MC/DC0%0/2
$Mail::Sender::{"SiteHook"} and not $self->SiteHook
$Mail::Sender::{"SiteHook"} not $self->SiteHook
Truth table0%0/3
A and not(B)
A= $Mail::Sender::{"SiteHook"}B= not $self->SiteHook
ABresult
0X0
100
111
1387 0 ▶ return defined $self->{'error'} ? $self->{'error'} : $self->{'error'}
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'error'} ? : 0 0 0
1388 = _SITEERROR();
1389 }
1390  
1391 0 ▶ my $s = $self->{'socket'} || $self->Connect();
Condition0%0/3
$self->{'socket'} || $self->Connect
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{'socket'} || $self->Connect
$self->{'socket'} $self->Connect
Truth table0%0/3
A || B
A= $self->{'socket'}B= $self->Connect
ABresult
1X1
011
000
1392 0 ▶ return $s
Branch: 1 branch
BranchTrueFalseTotal
unless ref $s 0 0 0
1393 unless ref $s; # return the error number if we did not get a socket
1394 0 $self->{'socket'} = $s;
1395  
1396 0 $_ = send_cmd $s,
1397 "MAIL FROM:<$self->{'fromaddr'}>$self->{esmtp}{_MAIL_FROM}";
1398 0 ▶ if (!/^[123]/) { return $self->Error(_COMMERROR($_)); }
Branch: 1 branch
BranchTrueFalseTotal
unless (/^[123]/) 0 0 0
1399  
1400 {
1401 0 local $^W;
1402 0 ▶ if ($self->{'skip_bad_recipients'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'skip_bad_recipients'}) { } 0 0 0
1403 0 my $good_count = 0;
1404 0 my %failed;
1405 0 foreach my $addr (
1406 0 @{$self->{'to_list'}},
1407 0 @{$self->{'cc_list'}},
1408 0 @{$self->{'bcc_list'}}
1409 )
1410 {
1411 0 ▶ if ($addr =~ /<(.*)>/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($addr =~ /<(.*)>/) { } 0 0 0
1412 0 $_ = send_cmd $s, "RCPT TO:<$1>$self->{esmtp}{_RCPT_TO}";
1413 }
1414 else {
1415 0 $_ = send_cmd $s, "RCPT TO:<$addr>$self->{esmtp}{_RCPT_TO}";
1416 }
1417 0 ▶ if (!/^[123]/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not /^[123]/) { } 0 0 0
1418 0 s/^\d{3} //;
1419 0 $failed{$addr} = $_;
1420 }
1421 else {
1422 0 $good_count++;
1423 }
1424 }
1425 0 ▶ $self->{'skipped_recipients'} = \%failed if %failed;
Branch: 1 branch
BranchTrueFalseTotal
if %failed 0 0 0
1426 0 ▶ if ($good_count == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($good_count == 0) 0 0 0
1427 0 return $self->Error(_ALLRECIPIENTSBAD);
1428 }
1429 }
1430 else {
1431 0 foreach my $addr (
1432 0 @{$self->{'to_list'}},
1433 0 @{$self->{'cc_list'}},
1434 0 @{$self->{'bcc_list'}}
1435 )
1436 {
1437 0 ▶ if ($addr =~ /<(.*)>/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($addr =~ /<(.*)>/) { } 0 0 0
1438 0 $_ = send_cmd $s, "RCPT TO:<$1>$self->{esmtp}{_RCPT_TO}";
1439 }
1440 else {
1441 0 $_ = send_cmd $s, "RCPT TO:<$addr>$self->{esmtp}{_RCPT_TO}";
1442 }
1443 0 ▶ if (!/^[123]/) {
Branch: 1 branch
BranchTrueFalseTotal
unless (/^[123]/) 0 0 0
1444 return $self->Error(
1445 0 _USERUNKNOWN($addr, $self->{'smtp'}, $_));
1446 }
1447 }
1448 }
1449 }
1450  
1451 0 $_ = send_cmd $s, "DATA";
1452 0 ▶ if (!/^[123]/) { return $self->Error(_COMMERROR($_)); }
Branch: 1 branch
BranchTrueFalseTotal
unless (/^[123]/) 0 0 0
1453  
1454 $self->{'socket'}
1455 ->stop_logging("\x0D\x0A... message headers and data skipped ...")
1456 0 ▶ if ($self->{'debug'} and $self->{'debug_level'} <= 1);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} and $self->{"debug_level"} <= 1 0 0 0
Condition0%0/3
$self->{"debug"} and $self->{"debug_level"} <= 1
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"debug"} and $self->{"debug_level"} <= 1
$self->{"debug"} $self->{"debug_level"} <= 1
Truth table0%0/3
A and B
A= $self->{"debug"}B= $self->{"debug_level"} <= 1
ABresult
0X0
100
111
1457 0 $self->{'_data'} = 1;
1458  
1459 _print_hdr $s,
1460 "To" =>
1461 (defined $self->{'fake_to'} ? $self->{'fake_to'} : $self->{'to'}),
1462 0 ▶ $self->{'charset'};
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'fake_to'} ? : 0 0 0
1463 _print_hdr $s,
1464 "From" =>
1465 (defined $self->{'fake_from'} ? $self->{'fake_from'} : $self->{'from'}),
1466 0 ▶ $self->{'charset'};
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'fake_from'} ? : 0 0 0
1467 0 ▶ if (defined $self->{'fake_cc'} and $self->{'fake_cc'}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $self->{'fake_cc'} and $self->{'fake_cc'}) { } 0 0 0
elsif (defined $self->{'cc'} and $self->{'cc'}) { } 0 0 0
Condition0%0/3
defined $self->{"fake_cc"} and $self->{"fake_cc"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"fake_cc"} and $self->{"fake_cc"}
defined $self->{"fake_cc"} $self->{"fake_cc"}
Truth table0%0/3
A and B
A= defined $self->{"fake_cc"}B= $self->{"fake_cc"}
ABresult
0X0
100
111
1468 0 _print_hdr $s, "Cc" => $self->{'fake_cc'}, $self->{'charset'};
1469 }
1470 ▶ elsif (defined $self->{'cc'} and $self->{'cc'}) {
Condition0%0/3
defined $self->{"cc"} and $self->{"cc"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"cc"} and $self->{"cc"}
defined $self->{"cc"} $self->{"cc"}
Truth table0%0/3
A and B
A= defined $self->{"cc"}B= $self->{"cc"}
ABresult
0X0
100
111
1471 0 _print_hdr $s, "Cc" => $self->{'cc'}, $self->{'charset'};
1472 }
1473 _print_hdr $s,
1474 "Reply-To" => $self->{'reply'},
1475 $self->{'charset'}
1476 0 ▶ if defined $self->{'reply'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"reply"} 0 0 0
1477  
1478 0 ▶ $self->{'subject'} = "<No subject>" unless defined $self->{'subject'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"subject"} 0 0 0
1479 0 _print_hdr $s, "Subject" => $self->{'subject'}, $self->{'charset'};
1480  
1481 0 ▶ unless (defined $Mail::Sender::NO_DATE and $Mail::Sender::NO_DATE
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Mail::Sender::NO_DATE and $Mail::Sender::NO_DATE or defined $self->{"_headers"} and $self->{"_headers"} =~ /^Date:/m or defined $Mail::Sender::SITE_HEADERS and $Mail::Sender::SITE_HEADERS =~ /^Date:/m) 0 0 0
Condition0%0/15
defined $Mail::Sender::NO_DATE and $Mail::Sender::NO_DATE or defined $self->{"_headers"} and $self->{"_headers"} =~ /^Date:/m or defined $Mail::Sender::SITE_HEADERS and $Mail::Sender::SITE_HEADERS =~ /^Date:/m
l!l&&r!l&&!r
000
defined $Mail::Sender::NO_DATE and $Mail::Sender::NO_DATE or defined $self->{"_headers"} and $self->{"_headers"} =~ /^Date:/m
l!l&&r!l&&!r
000
defined $Mail::Sender::NO_DATE and $Mail::Sender::NO_DATE
!ll&&!rl&&r
000
defined $self->{"_headers"} and $self->{"_headers"} =~ /^Date:/m
!ll&&!rl&&r
000
defined $Mail::Sender::SITE_HEADERS and $Mail::Sender::SITE_HEADERS =~ /^Date:/m
!ll&&!rl&&r
000
MC/DC0%0/6
defined $Mail::Sender::NO_DATE and $Mail::Sender::NO_DATE or defined $self->{"_headers"} and $self->{"_headers"} =~ /^Date:/m or defined $Mail::Sender::SITE_HEADERS and $Mail::Sender::SITE_HEADERS =~ /^Date:/m
defined $Mail::Sender::NO_DATE $Mail::Sender::NO_DATE defined $self->{"_headers"} $self->{"_headers"} =~ /^Date:/m defined $Mail::Sender::SITE_HEADERS $Mail::Sender::SITE_HEADERS =~ /^Date:/m
Truth table0%0/15
A and B or C and D or E and F
A= defined $Mail::Sender::NO_DATEB= $Mail::Sender::NO_DATEC= defined $self->{"_headers"}D= $self->{"_headers"} =~ /^Date:/mE= defined $Mail::Sender::SITE_HEADERSF= $Mail::Sender::SITE_HEADERS =~ /^Date:/m
ABCDEFresult
11XXXX1
0X11XX1
1011XX1
0X0X111
0X10111
100X111
1010111
0X0X0X0
0X0X100
0X100X0
0X10100
100X0X0
100X100
10100X0
1010100
1482 or defined $self->{'_headers'} and $self->{'_headers'} =~ /^Date:/m
1483 or defined $Mail::Sender::SITE_HEADERS
1484 && $Mail::Sender::SITE_HEADERS =~ /^Date:/m)
1485 {
1486 0 my $date = localtime();
1487 0 $date
1488 =~ s/^(\w+)\s+(\w+)\s+(\d+)\s+(\d+:\d+:\d+)\s+(\d+)$/$1, $3 $2 $5 $4/;
1489 0 _print_hdr $s, "Date" => "$date $GMTdiff";
1490 }
1491  
1492 0 ▶ if ($self->{'priority'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"priority"}) 0 0 0
1493 $self->{'priority'} = $priority[$self->{'priority'}]
1494 0 ▶ if ($self->{'priority'} + 0 eq $self->{'priority'});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"priority"} + 0 eq $self->{"priority"} 0 0 0
1495 0 _print_hdr $s, "X-Priority" => $self->{'priority'};
1496 }
1497  
1498 0 ▶ if ($self->{'confirm'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"confirm"}) 0 0 0
1499 0 for my $confirm (split /\s*,\s*/, $self->{'confirm'}) {
1500 0 ▶ if ($confirm =~ /^\s*reading\s*(?:\:\s*(.*))?/i) {
Branch: 2 branches
BranchTrueFalseTotal
if ($confirm =~ /^\s*reading\s*(?:\:\s*(.*))?/i) { } 0 0 0
elsif ($confirm =~ /^\s*delivery\s*(?:\:\s*(.*))?/i) { } 0 0 0
1501 _print_hdr $s,
1502 "X-Confirm-Reading-To" => ($1 || $self->{'from'}),
1503 0 ▶ $self->{'charset'};
Condition0%0/3
$1 || $self->{'from'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$1 || $self->{'from'}
$1 $self->{'from'}
Truth table0%0/3
A || B
A= $1B= $self->{'from'}
ABresult
1X1
011
000
1504 }
1505 elsif ($confirm =~ /^\s*delivery\s*(?:\:\s*(.*))?/i) {
1506 _print_hdr $s,
1507 "Return-Receipt-To" => ($1 || $self->{'fromaddr'}),
1508 0 ▶ $self->{'charset'};
Condition0%0/3
$1 || $self->{'fromaddr'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$1 || $self->{'fromaddr'}
$1 $self->{'fromaddr'}
Truth table0%0/3
A || B
A= $1B= $self->{'fromaddr'}
ABresult
1X1
011
000
1509 _print_hdr $s,
1510 "Disposition-Notification-To" =>
1511 ($1 || $self->{'fromaddr'}),
1512 0 ▶ $self->{'charset'};
Condition0%0/3
$1 || $self->{'fromaddr'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$1 || $self->{'fromaddr'}
$1 $self->{'fromaddr'}
Truth table0%0/3
A || B
A= $1B= $self->{'fromaddr'}
ABresult
1X1
011
000
1513 }
1514 }
1515 }
1516  
1517 0 ▶ unless (defined $Mail::Sender::NO_X_MAILER and $Mail::Sender::NO_X_MAILER) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Mail::Sender::NO_X_MAILER and $Mail::Sender::NO_X_MAILER) 0 0 0
Condition0%0/3
defined $Mail::Sender::NO_X_MAILER and $Mail::Sender::NO_X_MAILER
!ll&&!rl&&r
000
MC/DC0%0/2
defined $Mail::Sender::NO_X_MAILER and $Mail::Sender::NO_X_MAILER
defined $Mail::Sender::NO_X_MAILER $Mail::Sender::NO_X_MAILER
Truth table0%0/3
A and B
A= defined $Mail::Sender::NO_X_MAILERB= $Mail::Sender::NO_X_MAILER
ABresult
0X0
100
111
1518 0 my $script = File::Basename::basename($0);
1519 0 _print_hdr $s,
1520 "X-Mailer" =>
1521 qq{Perl script "$script"\r\n\tusing Mail::Sender $VERSION by Jenda Krynicky, Czechlands\r\n\trunning on $local_name ($local_IP)\r\n\tunder account "}
1522 . getusername()
1523 . qq{"\r\n};
1524 }
1525  
1526 0 ▶ print $s $Mail::Sender::SITE_HEADERS, "\r\n"
Branch: 1 branch
BranchTrueFalseTotal
if defined $Mail::Sender::SITE_HEADERS 0 0 0
1527 if (defined $Mail::Sender::SITE_HEADERS);
1528  
1529 0 ▶ unless (defined $Mail::Sender::NO_MESSAGE_ID
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Mail::Sender::NO_MESSAGE_ID and $Mail::Sender::NO_MESSAGE_ID) 0 0 0
Condition0%0/3
defined $Mail::Sender::NO_MESSAGE_ID and $Mail::Sender::NO_MESSAGE_ID
!ll&&!rl&&r
000
MC/DC0%0/2
defined $Mail::Sender::NO_MESSAGE_ID and $Mail::Sender::NO_MESSAGE_ID
defined $Mail::Sender::NO_MESSAGE_ID $Mail::Sender::NO_MESSAGE_ID
Truth table0%0/3
A and B
A= defined $Mail::Sender::NO_MESSAGE_IDB= $Mail::Sender::NO_MESSAGE_ID
ABresult
0X0
100
111
1530 and $Mail::Sender::NO_MESSAGE_ID)
1531 {
1532 0 ▶ if (!defined $self->{'messageid'} or $self->{'messageid'} eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{"messageid"} or $self->{"messageid"} eq "") 0 0 0
Condition0%0/3
not defined $self->{"messageid"} or $self->{"messageid"} eq ""
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $self->{"messageid"} or $self->{"messageid"} eq ""
not defined $self->{"messageid"} $self->{"messageid"} eq ""
Truth table0%0/3
not(A) or B
A= not defined $self->{"messageid"}B= $self->{"messageid"} eq ""
ABresult
1X1
011
000
1533 0 ▶ if (defined $self->{'createmessageid'}
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'createmessageid'} and ref $self->{'createmessageid'} eq 'CODE') { } 0 0 0
Condition0%0/3
defined $self->{"createmessageid"} and ref $self->{"createmessageid"} eq "CODE"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"createmessageid"} and ref $self->{"createmessageid"} eq "CODE"
defined $self->{"createmessageid"} ref $self->{"createmessageid"} eq "CODE"
Truth table0%0/3
A and B
A= defined $self->{"createmessageid"}B= ref $self->{"createmessageid"} eq "CODE"
ABresult
0X0
100
111
1534 and ref $self->{'createmessageid'} eq 'CODE')
1535 {
1536 $self->{'messageid'}
1537 0 = $self->{'createmessageid'}->($self->{'fromaddr'});
1538 }
1539 else {
1540 0 $self->{'messageid'} = MessageID($self->{'fromaddr'});
1541 }
1542 }
1543 0 _print_hdr $s, "Message-ID" => $self->{'messageid'};
1544 }
1545  
1546 print $s $self->{'_headers'}, "\r\n"
1547 0 ▶ if defined $self->{'_headers'} and $self->{'_headers'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"_headers"} and $self->{"_headers"} 0 0 0
Condition0%0/3
defined $self->{"_headers"} and $self->{"_headers"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"_headers"} and $self->{"_headers"}
defined $self->{"_headers"} $self->{"_headers"}
Truth table0%0/3
A and B
A= defined $self->{"_headers"}B= $self->{"_headers"}
ABresult
0X0
100
111
1548 0 print $s "MIME-Version: 1.0\r\n";
1549 0 _print_hdr $s, "Content-Type",
1550 qq{multipart/$self->{'multipart'};\r\n\tboundary="$self->{'boundary'}"};
1551  
1552 0 print $s "\r\n";
1553 $self->{'socket'}->stop_logging("... message data skipped ...")
1554 0 ▶ if ($self->{'debug'} and $self->{'debug_level'} <= 2);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} and $self->{"debug_level"} <= 2 0 0 0
Condition0%0/3
$self->{"debug"} and $self->{"debug_level"} <= 2
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"debug"} and $self->{"debug_level"} <= 2
$self->{"debug"} $self->{"debug_level"} <= 2
Truth table0%0/3
A and B
A= $self->{"debug"}B= $self->{"debug_level"} <= 2
ABresult
0X0
100
111
1555  
1556 0 print $s
1557 "This message is in MIME format. Since your mail reader does not understand\r\n"
1558 . "this format, some or all of this message may not be legible.\r\n"
1559 . "\r\n--$self->{'boundary'}\r\n";
1560  
1561 0 return $self;
1562 }
1563  
1564 0 ▶sub Connected {
Subroutine Connected: not called CC=3 SCAR=24.8
Pod documented
1565 0 my $self = shift();
1566 0 ▶ return unless exists $self->{'socket'} and $self->{'socket'};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"socket"} and $self->{"socket"} 0 0 0
Condition0%0/3
exists $self->{"socket"} and $self->{"socket"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $self->{"socket"} and $self->{"socket"}
exists $self->{"socket"} $self->{"socket"}
Truth table0%0/3
A and B
A= exists $self->{"socket"}B= $self->{"socket"}
ABresult
0X0
100
111
1567 0 my $s = $self->{'socket'};
1568 0 return $s->opened();
1569 }
1570  
1571 0 ▶sub MailMsg {
Subroutine MailMsg: not called CC=6 SCAR=37.4
Pod documented
1572 0 my $self = shift;
1573 0 my $msg;
1574 0 local $_;
1575 0 ▶ if (ref $_[0] eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 0 0
1576 0 my $hash = $_[0];
1577 0 $msg = $hash->{'msg'};
1578 }
1579 else {
1580 0 $msg = pop;
1581 }
1582 0 ▶ return $self->Error(_NOMSG) unless $msg;
Branch: 1 branch
BranchTrueFalseTotal
unless $msg 0 0 0
1583  
1584 0 ▶ if (ref $self->Open(@_) and ref $self->SendEnc($msg) and ref $self->Close())
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->Open(@_) and ref $self->SendEnc($msg) and ref $self->Close) { } 0 0 0
Condition0%0/6
ref $self->Open(@_) and ref $self->SendEnc($msg) and ref $self->Close
!ll&&!rl&&r
000
ref $self->Open(@_) and ref $self->SendEnc($msg)
!ll&&!rl&&r
000
MC/DC0%0/3
ref $self->Open(@_) and ref $self->SendEnc($msg) and ref $self->Close
ref $self->Open(@_) ref $self->SendEnc($msg) ref $self->Close
Truth table0%0/4
A and B and C
A= ref $self->Open(@_)B= ref $self->SendEnc($msg)C= ref $self->Close
ABCresult
0XX0
10X0
1100
1111
1585 {
1586 0 return $self;
1587 }
1588 else {
1589 0 return $self->{'error'};
1590 }
1591 }
1592  
1593 0 ▶sub MailFile {
Subroutine MailFile: not called CC=32 SCAR=69.6
Pod documented
1594 0 my $self = shift;
1595 0 my $msg;
1596 0 local $_;
1597 0 my ($file, $desc, $haddesc, $ctype, $charset, $encoding);
1598 0 my @files;
1599 0 my $hash;
1600 0 ▶ if (ref $_[0] eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 0 0
1601 0 $hash = {%{$_[0]}}; # make a copy
1602  
1603 0 $msg = delete $hash->{'msg'};
1604  
1605 0 $file = delete $hash->{'file'};
1606  
1607 0 $desc = delete $hash->{'description'};
1608 0 ▶ $haddesc = 1 if defined $desc;
Branch: 1 branch
BranchTrueFalseTotal
if defined $desc 0 0 0
1609  
1610 0 $ctype = delete $hash->{'ctype'};
1611  
1612 0 $charset = delete $hash->{'charset'};
1613  
1614 0 $encoding = delete $hash->{'encoding'};
1615 }
1616 else {
1617 0 ▶ $desc = pop if ($#_ >= 2);
Branch: 1 branch
BranchTrueFalseTotal
if $#_ >= 2 0 0 0
1618 0 ▶ $haddesc = 1 if defined $desc;
Branch: 1 branch
BranchTrueFalseTotal
if defined $desc 0 0 0
1619 0 $file = pop;
1620 0 $msg = pop;
1621 }
1622 0 ▶ return $self->Error(_NOMSG) unless $msg;
Branch: 1 branch
BranchTrueFalseTotal
unless $msg 0 0 0
1623 0 ▶ return $self->Error(_NOFILE) unless $file;
Branch: 1 branch
BranchTrueFalseTotal
unless $file 0 0 0
1624  
1625 0 ▶ if (ref $file eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $file eq 'ARRAY') { } 0 0 0
elsif ($file =~ /,/) { } 0 0 0
1626 0 @files = @$file;
1627 }
1628 elsif ($file =~ /,/) {
1629 0 @files = split / *, */, $file;
1630 }
1631 else {
1632 0 @files = ($file);
1633 }
1634 0 foreach $file (@files) {
1635 0 ▶ return $self->Error(_FILENOTFOUND($file))
Branch: 1 branch
BranchTrueFalseTotal
unless $file =~ /^&/ or -e $file 0 0 0
Condition0%0/3
$file =~ /^&/ or -e $file
l!l&&r!l&&!r
000
MC/DC0%0/2
$file =~ /^&/ or -e $file
$file =~ /^&/ -e $file
Truth table0%0/3
A or B
A= $file =~ /^&/B= -e $file
ABresult
1X1
011
000
1636 unless ($file =~ /^&/ or -e $file);
1637 }
1638  
1639 ref $self->OpenMultipart($hash ? $hash : @_)
1640 and ref $self->Body($self->{'b_charset'} || $self->{'charset'},
1641 $self->{'b_encoding'}, $self->{'b_ctype'})
1642 and $self->SendEnc($msg)
1643 0 ▶ or return $self->{'error'};
Branch: 2 branches
BranchTrueFalseTotal
ref $self->OpenMultipart($hash ? $hash : @_) and ref $self->Body($self->{"b_charset"} || $self->{"charset"}, $self->{"b_encoding"}, $self->{"b_ctype"}) and $self->SendEnc($msg) or return $self->{"error"} 0 0 0
$hash ? : 0 0 0
Condition0%0/9
ref $self->OpenMultipart($hash ? $hash : @_) and ref $self->Body($self->{"b_charset"} || $self->{"charset"}, $self->{"b_encoding"}, $self->{"b_ctype"}) and $self->SendEnc($msg)
!ll&&!rl&&r
000
ref $self->OpenMultipart($hash ? $hash : @_) and ref $self->Body($self->{"b_charset"} || $self->{"charset"}, $self->{"b_encoding"}, $self->{"b_ctype"})
!ll&&!rl&&r
000
$self->{'b_charset'} || $self->{'charset'}
l!l&&r!l&&!r
000
MC/DC0%0/3
ref $self->OpenMultipart($hash ? $hash : @_) and ref $self->Body($self->{"b_charset"} || $self->{"charset"}, $self->{"b_encoding"}, $self->{"b_ctype"}) and $self->SendEnc($msg)
ref $self->OpenMultipart($hash ? $hash : @_) ref $self->Body($self->{"b_charset"} || $self->{"charset"}, $self->{"b_encoding"}, $self->{"b_ctype"}) $self->SendEnc($msg)
MC/DC0%0/2
$self->{'b_charset'} || $self->{'charset'}
$self->{'b_charset'} $self->{'charset'}
Truth table0%0/4
A and B and C
A= ref $self->OpenMultipart($hash ? $hash : @_)B= ref $self->Body($self->{"b_charset"} || $self->{"charset"}, $self->{"b_encoding"}, $self->{"b_ctype"})C= $self->SendEnc($msg)
ABCresult
0XX0
10X0
1100
1111
Truth table0%0/3
A || B
A= $self->{'b_charset'}B= $self->{'charset'}
ABresult
1X1
011
000
1644  
1645 0 $Error = '';
1646 0 foreach $file (@files) {
1647 0 my $cnt;
1648 0 my $filename = File::Basename::basename $file;
1649 0 ▶ my $ctype = $ctype || GuessCType $filename, $file;
Condition0%0/3
$ctype || GuessCType($filename, $file)
l!l&&r!l&&!r
000
MC/DC0%0/2
$ctype || GuessCType($filename, $file)
$ctype GuessCType($filename, $file)
Truth table0%0/3
A || B
A= $ctypeB= GuessCType($filename, $file)
ABresult
1X1
011
000
1650 0 ▶ my $encoding = $encoding
Branch: 1 branch
BranchTrueFalseTotal
$ctype =~ m[^text/]i ? : 0 0 0
Condition0%0/3
$encoding || ($ctype =~ m[^text/]i ? 'Quoted-printable' : 'Base64')
l!l&&r!l&&!r
000
MC/DC0%0/2
$encoding || ($ctype =~ m[^text/]i ? 'Quoted-printable' : 'Base64')
$encoding ($ctype =~ m[^text/]i ? 'Quoted-printable' : 'Base64')
Truth table0%0/3
A || B
A= $encodingB= ($ctype =~ m[^text/]i ? 'Quoted-printable' : 'Base64')
ABresult
1X1
011
000
1651 || ($ctype =~ m#^text/#i ? 'Quoted-printable' : 'Base64');
1652  
1653 0 ▶ $desc = $filename unless (defined $haddesc);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $haddesc 0 0 0
1654  
1655 $self->Part(
1656 {
1657 encoding => $encoding,
1658 disposition => (
1659 0 ▶ defined $self->{'disposition'} ? $self->{'disposition'}
Branch: 3 branches
BranchTrueFalseTotal
defined $self->{'disposition'} ? : 0 0 0
$ctype =~ /;\s*name(?:\*(?:0\*?)?)?=/ ? : 0 0 0
defined $charset ? : 0 0 0
1660 : "attachment; filename=\"$filename\""
1661 ),
1662 ctype => (
1663 $ctype =~ /;\s*name(?:\*(?:0\*?)?)?=/ ? $ctype
1664 : "$ctype; name=\"$filename\""
1665 )
1666 . (defined $charset ? "; charset=$charset" : ''),
1667 description => $desc
1668 }
1669 );
1670  
1671 0 my $code = $self->{'code'};
1672  
1673 0 ▶ open my $FH, "<", $file or return $self->Error(_FILECANTREAD($file));
Branch: 1 branch
BranchTrueFalseTotal
open my $FH, "<", $file or return $self->Error(_FILECANTREAD($file)) 0 0 0
1674 0 ▶ binmode $FH
Branch: 1 branch
BranchTrueFalseTotal
unless $ctype =~ m[^text/]i and $encoding =~ /Quoted[_\-]print|Base64/i 0 0 0
Condition0%0/3
$ctype =~ m[^text/]i and $encoding =~ /Quoted[_\-]print|Base64/i
!ll&&!rl&&r
000
MC/DC0%0/2
$ctype =~ m[^text/]i and $encoding =~ /Quoted[_\-]print|Base64/i
$ctype =~ m[^text/]i $encoding =~ /Quoted[_\-]print|Base64/i
Truth table0%0/3
A and B
A= $ctype =~ m[^text/]iB= $encoding =~ /Quoted[_\-]print|Base64/i
ABresult
0X0
100
111
1675 unless $ctype =~ m#^text/#i
1676 and $encoding =~ /Quoted[_\-]print|Base64/i;
1677 0 my $s;
1678 0 $s = $self->{'socket'};
1679 0 my $mychunksize = $chunksize;
1680 0 ▶ $mychunksize = $chunksize64 if defined $self->{'chunk_size'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"chunk_size"} 0 0 0
1681 0 ▶ while (read $FH, $cnt, $mychunksize) {
Branch: 1 branch
BranchTrueFalseTotal
if (read $FH, $cnt, $mychunksize) 0 0 0
1682 0 $cnt = $code->($cnt);
1683 0 ▶ $cnt =~ s/^\.\././ unless $self->{'_had_newline'};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_had_newline"} 0 0 0
1684 0 print $s $cnt;
1685 0 $self->{'_had_newline'} = ($cnt =~ /[\n\r]$/);
1686 }
1687 0 close $FH;
1688 }
1689  
1690 0 ▶ if ($Error eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($Mail::Sender::Error eq '') { } 0 0 0
1691 0 undef $Error;
1692 }
1693 else {
1694 0 chomp $Error;
1695 }
1696 0 return $self->Close;
1697 }
1698  
1699 0 ▶sub Send {
Subroutine Send: not called CC=1 SCAR=6.9
Pod documented
1700 0 my $self = shift;
1701 0 my $s;
1702 0 $s = $self->{'socket'};
1703 0 print $s @_;
1704 0 return $self;
1705 }
1706  
1707 0 ▶sub SendLine {
Subroutine SendLine: not called CC=1 SCAR=6.9
Pod documented
1708 0 my $self = shift;
1709 0 my $s = $self->{'socket'};
1710 0 print $s (@_, "\x0D\x0A");
1711 0 return $self;
1712 }
1713  
1714 0 ▶sub print { return shift->SendEnc(@_) }
Subroutine print: not called CC=1 SCAR=6.9
Pod documented
1715 0 ▶sub SendLineEnc { push @_, "\r\n"; return shift->SendEnc(@_) }
Subroutine SendLineEnc: not called CC=1 SCAR=6.9
Pod documented
1716  
1717 0 ▶sub SendEnc {
Subroutine SendEnc: not called CC=7 SCAR=40.3
Pod documented
1718 0 my $self = shift;
1719 0 local $_;
1720 0 my $code = $self->{'code'};
1721 0 ▶ $self->{'code'} = $code = enc_plain($self->{'charset'})
Branch: 1 branch
BranchTrueFalseTotal
unless defined $code 0 0 0
1722 unless defined $code;
1723 0 my $s;
1724 0 ▶ $s = $self->{'socket'} or return $self->Error(_NOTCONNECTED);
Branch: 1 branch
BranchTrueFalseTotal
$s = $self->{"socket"} or return $self->Error(_NOTCONNECTED()) 0 0 0
1725 0 ▶ if (defined $self->{'chunk_size'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'chunk_size'}) { } 0 0 0
1726 0 my $str;
1727 0 my $chunk = $self->{'chunk_size'};
1728 0 ▶ if (defined $self->{'_buffer'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'_buffer'}) { } 0 0 0
1729 0 $str = (join '', ($self->{'_buffer'}, @_));
1730 }
1731 else {
1732 0 $str = join '', @_;
1733 }
1734 0 my ($len, $blen);
1735 0 $len = length $str;
1736 0 ▶ if (($blen = ($len % $chunk)) > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (($blen = $len % $chunk) > 0) { } 0 0 0
1737 0 $self->{'_buffer'} = substr($str, ($len - $blen));
1738 0 print $s ($code->(substr($str, 0, $len - $blen)));
1739 }
1740 else {
1741 0 delete $self->{'_buffer'};
1742 0 print $s ($code->($str));
1743 }
1744 }
1745 else {
1746 0 my $encoded = $code->(join('', @_));
1747 0 ▶ $encoded =~ s/^\.\././ unless $self->{'_had_newline'};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_had_newline"} 0 0 0
1748 0 print $s $encoded;
1749 0 $self->{'_had_newline'} = ($_[-1] =~ /[\n\r]$/);
1750 }
1751 0 return $self;
1752 }
1753  
1754 0 ▶sub SendLineEx { push @_, "\r\n"; shift->SendEx(@_) }
Subroutine SendLineEx: not called CC=1 SCAR=6.9
Pod documented
1755  
1756 0 ▶sub SendEx {
Subroutine SendEx: not called CC=3 SCAR=24.8
Pod documented
1757 0 my $self = shift;
1758 0 my $s;
1759 0 ▶ $s = $self->{'socket'} or return $self->Error(_NOTCONNECTED);
Branch: 1 branch
BranchTrueFalseTotal
$s = $self->{"socket"} or return $self->Error(_NOTCONNECTED()) 0 0 0
1760 0 my $str;
1761 0 my @data = @_;
1762 0 foreach $str (@data) {
1763 0 $str =~ s/(?:\x0D\x0A?|\x0A)/\x0D\x0A/sg;
1764 0 $str =~ s/^\./../mg;
1765 }
1766 0 print $s @data;
1767 0 return $self;
1768 }
1769  
1770 0 ▶sub Part {
Subroutine Part: not called CC=24 SCAR=64.0
Pod documented
1771 0 my $self = shift;
1772 0 local $_;
1773 0 ▶ if (!$self->{'multipart'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"multipart"}) 0 0 0
1774 0 return $self->Error(_NOTMULTIPART("\$sender->Part()"));
1775 }
1776 0 $self->EndPart();
1777  
1778 0 my ($description, $ctype, $encoding, $disposition, $content_id, $msg,
1779 $charset);
1780 0 ▶ if (ref $_[0] eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 0 0
1781 0 my $hash = $_[0];
1782 0 $description = $hash->{'description'};
1783 0 $ctype = $hash->{'ctype'};
1784 0 $encoding = $hash->{'encoding'};
1785 0 $disposition = $hash->{'disposition'};
1786 0 $content_id = $hash->{'content_id'};
1787 0 $msg = $hash->{'msg'};
1788 0 $charset = $hash->{'charset'};
1789 }
1790 else {
1791 0 ($description, $ctype, $encoding, $disposition, $content_id, $msg) = @_;
1792 }
1793  
1794 0 ▶ $ctype = "application/octet-stream" unless defined $ctype;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ctype 0 0 0
1795 0 ▶ $disposition = "attachment" unless defined $disposition;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $disposition 0 0 0
1796 0 ▶ $encoding = "7BIT" unless defined $encoding;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $encoding 0 0 0
1797 0 $self->{'encoding'} = $encoding;
1798 0 ▶ if (defined $charset and $charset and $ctype !~ /charset=/i) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $charset and $charset and not $ctype =~ /charset=/i) { } 0 0 0
elsif (not defined $charset and $ctype =~ /charset="([^"]+)"/) { } 0 0 0
Condition0%0/6
defined $charset and $charset and not $ctype =~ /charset=/i
!ll&&!rl&&r
000
defined $charset and $charset
!ll&&!rl&&r
000
MC/DC0%0/3
defined $charset and $charset and not $ctype =~ /charset=/i
defined $charset $charset not $ctype =~ /charset=/i
Truth table0%0/4
A and B and not(C)
A= defined $charsetB= $charsetC= not $ctype =~ /charset=/i
ABCresult
0XX0
10X0
1100
1111
1799 0 $ctype .= qq{; charset="$charset"};
1800 }
1801 ▶ elsif (!defined $charset and $ctype =~ /charset="([^"]+)"/) {
Condition0%0/3
not defined $charset and $ctype =~ /charset="([^"]+)"/
!ll&&!rl&&r
000
MC/DC0%0/2
not defined $charset and $ctype =~ /charset="([^"]+)"/
not defined $charset $ctype =~ /charset="([^"]+)"/
Truth table0%0/3
not(A) and B
A= not defined $charsetB= $ctype =~ /charset="([^"]+)"/
ABresult
0X0
100
111
1802 0 $charset = $1;
1803 }
1804  
1805 0 my $s;
1806 0 ▶ $s = $self->{'socket'} or return $self->Error(_NOTCONNECTED);
Branch: 1 branch
BranchTrueFalseTotal
$s = $self->{"socket"} or return $self->Error(_NOTCONNECTED()) 0 0 0
1807  
1808 0 undef $self->{'chunk_size'};
1809 0 ▶ if ($encoding =~ /Base64/i) {
Branch: 2 branches
BranchTrueFalseTotal
if ($encoding =~ /Base64/i) { } 0 0 0
elsif ($encoding =~ /Quoted[_\-]print/i) { } 0 0 0
1810 0 $self->{'code'} = enc_base64($charset);
1811 0 $self->{'chunk_size'} = $enc_base64_chunk;
1812 }
1813 elsif ($encoding =~ /Quoted[_\-]print/i) {
1814 0 $self->{'code'} = enc_qp($charset);
1815 }
1816 else {
1817 0 $self->{'code'} = enc_plain($charset);
1818 }
1819  
1820 $self->{'socket'}->start_logging()
1821 0 ▶ if ($self->{'debug'} and $self->{'debug_level'} == 3);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} and $self->{"debug_level"} == 3 0 0 0
Condition0%0/3
$self->{"debug"} and $self->{"debug_level"} == 3
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"debug"} and $self->{"debug_level"} == 3
$self->{"debug"} $self->{"debug_level"} == 3
Truth table0%0/3
A and B
A= $self->{"debug"}B= $self->{"debug_level"} == 3
ABresult
0X0
100
111
1822  
1823 0 ▶ if ($ctype =~ m{^multipart/}i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ctype =~ m[^multipart/]i) { } 0 0 0
1824 0 $self->{'_part'} += 2;
1825 0 print $s
1826 "Content-Type: $ctype; boundary=\"Part-$self->{'boundary'}_$self->{'_part'}\"\r\n\r\n";
1827 }
1828 else {
1829 0 $self->{'_part'}++;
1830 0 print $s "Content-Type: $ctype\r\n";
1831 0 ▶ if ($description) { print $s "Content-Description: $description\r\n"; }
Branch: 1 branch
BranchTrueFalseTotal
if ($description) 0 0 0
1832 0 print $s "Content-Transfer-Encoding: $encoding\r\n";
1833 0 ▶ print $s "Content-Disposition: $disposition\r\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $disposition eq "" or uc $disposition eq "NONE" 0 0 0
Condition0%0/3
$disposition eq "" or uc $disposition eq "NONE"
l!l&&r!l&&!r
000
MC/DC0%0/2
$disposition eq "" or uc $disposition eq "NONE"
$disposition eq "" uc $disposition eq "NONE"
Truth table0%0/3
A or B
A= $disposition eq ""B= uc $disposition eq "NONE"
ABresult
1X1
011
000
1834 unless $disposition eq ''
1835 or uc($disposition) eq 'NONE';
1836 0 ▶ print $s "Content-ID: <$content_id>\r\n" if (defined $content_id);
Branch: 1 branch
BranchTrueFalseTotal
if defined $content_id 0 0 0
1837 0 print $s "\r\n";
1838  
1839 $self->{'socket'}->stop_logging("... data skipped ...")
1840 0 ▶ if ($self->{'debug'} and $self->{'debug_level'} == 3);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} and $self->{"debug_level"} == 3 0 0 0
Condition0%0/3
$self->{"debug"} and $self->{"debug_level"} == 3
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"debug"} and $self->{"debug_level"} == 3
$self->{"debug"} $self->{"debug_level"} == 3
Truth table0%0/3
A and B
A= $self->{"debug"}B= $self->{"debug_level"} == 3
ABresult
0X0
100
111
1841 0 ▶ $self->SendEnc($msg) if defined $msg;
Branch: 1 branch
BranchTrueFalseTotal
if defined $msg 0 0 0
1842 }
1843  
1844 #$self->{'_had_newline'} = 1;
1845 0 return $self;
1846 }
1847  
1848 0 ▶sub Body {
Subroutine Body: not called CC=13 SCAR=52.0
Pod documented
1849 0 my $self = shift;
1850 0 ▶ if (!$self->{'multipart'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"multipart"}) 0 0 0
1851  
1852 # ->Body() has no meanin in singlepart messages
1853 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
1854  
1855 # they called it with some parameters? Too late for them, let's scream.
1856 0 return $self->Error(_NOTMULTIPART("\$sender->Body()"));
1857 }
1858 else {
1859 # $sender->Body() ... OK, let's ignore it.
1860 0 return $self;
1861 }
1862 }
1863 0 my $hash;
1864 0 ▶ $hash = shift() if (ref $_[0] eq 'HASH');
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] eq "HASH" 0 0 0
1865 0 ▶ my $charset = shift || $hash->{'charset'} || 'US-ASCII';
Condition0%0/5
shift() || $hash->{'charset'} || 'US-ASCII'
l!l
00
shift() or $hash->{"charset"}
l!l&&r!l&&!r
000
MC/DC0%0/2
shift() || $hash->{'charset'} || 'US-ASCII'
shift() $hash->{"charset"}
Truth table0%0/3
A or B
A= shift()B= $hash->{"charset"}
ABresult
1X1
011
000
1866 my $encoding
1867 0 ▶ = shift || $hash->{'encoding'} || $self->{'encoding'} || '7BIT';
Condition0%0/8
shift() || $hash->{'encoding'} || $self->{'encoding'} || '7BIT'
l!l
00
shift() or $hash->{"encoding"} or $self->{"encoding"}
l!l&&r!l&&!r
000
shift() or $hash->{"encoding"}
l!l&&r!l&&!r
000
MC/DC0%0/3
shift() || $hash->{'encoding'} || $self->{'encoding'} || '7BIT'
shift() $hash->{"encoding"} $self->{"encoding"}
Truth table0%0/4
A or B or C
A= shift()B= $hash->{"encoding"}C= $self->{"encoding"}
ABCresult
1XX1
01X1
0011
0000
1868 0 ▶ my $ctype = shift || $hash->{'ctype'} || $self->{'ctype'} || 'text/plain';
Condition0%0/8
shift() || $hash->{'ctype'} || $self->{'ctype'} || 'text/plain'
l!l
00
shift() or $hash->{"ctype"} or $self->{"ctype"}
l!l&&r!l&&!r
000
shift() or $hash->{"ctype"}
l!l&&r!l&&!r
000
MC/DC0%0/3
shift() || $hash->{'ctype'} || $self->{'ctype'} || 'text/plain'
shift() $hash->{"ctype"} $self->{"ctype"}
Truth table0%0/4
A or B or C
A= shift()B= $hash->{"ctype"}C= $self->{"ctype"}
ABCresult
1XX1
01X1
0011
0000
1869  
1870 0 ▶ $ctype .= qq{; charset="$charset"} unless $ctype =~ /charset=/i;
Branch: 1 branch
BranchTrueFalseTotal
unless $ctype =~ /charset=/i 0 0 0
1871  
1872 0 $self->{'encoding'} = $encoding;
1873 0 $self->{'ctype'} = $ctype;
1874  
1875 $self->Part("Mail message body",
1876 0 $ctype, $encoding, 'inline', undef, $hash->{'msg'});
1877 0 return $self;
1878 }
1879  
1880 0 ▶sub Attach { shift->SendFile(@_) }
Subroutine Attach: not called CC=1 SCAR=6.9
Pod documented
1881  
1882 0 ▶sub SendFile {
Subroutine SendFile: not called CC=35 SCAR=71.4
Pod documented
1883 0 my $self = shift;
1884 0 local $_;
1885 0 ▶ if (!$self->{'multipart'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"multipart"}) 0 0 0
1886 0 return $self->Error(_NOTMULTIPART("\$sender->SendFile()"));
1887 }
1888 0 ▶ if (!$self->{'socket'}) { return $self->Error(_NOTCONNECTED); }
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"socket"}) 0 0 0
1889  
1890 0 my ($description, $ctype, $encoding, $disposition, $file, $content_id,
1891 @files);
1892 0 ▶ if (ref $_[0] eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 0 0
1893 0 my $hash = $_[0];
1894 0 $description = $hash->{'description'};
1895 0 $ctype = $hash->{'ctype'};
1896 0 $encoding = $hash->{'encoding'};
1897 0 $disposition = $hash->{'disposition'};
1898 0 $file = $hash->{'file'};
1899 0 $content_id = $hash->{'content_id'};
1900 }
1901 else {
1902 0 ($description, $ctype, $encoding, $disposition, $file, $content_id)
1903 = @_;
1904 }
1905 0 ▶ return ($self->{'error'} = _NOFILE) unless $file;
Branch: 1 branch
BranchTrueFalseTotal
unless $file 0 0 0
1906  
1907 0 ▶ if (ref $file eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $file eq 'ARRAY') { } 0 0 0
elsif ($file =~ /,/) { } 0 0 0
1908 0 @files = @$file;
1909 }
1910 elsif ($file =~ /,/) {
1911 0 @files = split / *, */, $file;
1912 }
1913 else {
1914 0 @files = ($file);
1915 }
1916 0 foreach $file (@files) {
1917 0 ▶ return $self->Error(_FILENOTFOUND($file))
Branch: 1 branch
BranchTrueFalseTotal
unless $file =~ /^&/ or -e $file 0 0 0
Condition0%0/3
$file =~ /^&/ or -e $file
l!l&&r!l&&!r
000
MC/DC0%0/2
$file =~ /^&/ or -e $file
$file =~ /^&/ -e $file
Truth table0%0/3
A or B
A= $file =~ /^&/B= -e $file
ABresult
1X1
011
000
1918 unless ($file =~ /^&/ or -e $file);
1919 }
1920  
1921 0 ▶ $disposition = "attachment; filename=*" unless defined $disposition;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $disposition 0 0 0
1922 0 ▶ $encoding = 'Base64' unless $encoding;
Branch: 1 branch
BranchTrueFalseTotal
unless $encoding 0 0 0
1923  
1924 0 my $s = $self->{'socket'};
1925  
1926 0 ▶ if ($self->{'_buffer'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_buffer"}) 0 0 0
1927 0 my $code = $self->{'code'};
1928 0 print $s ($code->($self->{'_buffer'}));
1929 0 delete $self->{'_buffer'};
1930 }
1931  
1932 0 my $code;
1933 0 ▶ if ($encoding =~ /Base64/i) {
Branch: 2 branches
BranchTrueFalseTotal
if ($encoding =~ /Base64/i) { } 0 0 0
elsif ($encoding =~ /Quoted[_\-]print/i) { } 0 0 0
1934 0 $code = enc_base64();
1935 }
1936 elsif ($encoding =~ /Quoted[_\-]print/i) {
1937 0 $code = enc_qp();
1938 }
1939 else {
1940 0 $code = enc_plain();
1941 }
1942 0 $self->{'code'} = $code;
1943  
1944 0 foreach $file (@files) {
1945 0 $self->EndPart();
1946 0 $self->{'_part'}++;
1947 0 $self->{'encoding'} = $encoding;
1948 0 my $cnt = '';
1949 0 my $name = File::Basename::basename $file;
1950 0 ▶ my $fctype = $ctype ? $ctype : GuessCType $name, $file;
Branch: 1 branch
BranchTrueFalseTotal
$ctype ? : 0 0 0
1951 0 $self->{'ctype'} = $fctype;
1952  
1953 $self->{'socket'}->start_logging()
1954 0 ▶ if ($self->{'debug'} and $self->{'debug_level'} == 3);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} and $self->{"debug_level"} == 3 0 0 0
Condition0%0/3
$self->{"debug"} and $self->{"debug_level"} == 3
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"debug"} and $self->{"debug_level"} == 3
$self->{"debug"} $self->{"debug_level"} == 3
Truth table0%0/3
A and B
A= $self->{"debug"}B= $self->{"debug_level"} == 3
ABresult
0X0
100
111
1955  
1956 0 ▶ if ($fctype =~ /;\s*name(?:\*(?:0\*?)?)?=/)
Branch: 1 branch
BranchTrueFalseTotal
if ($fctype =~ /;\s*name(?:\*(?:0\*?)?)?=/) { } 0 0 0
1957 { # looking for name=, name*=, name*0= or name*0*=
1958 0 print $s ("Content-Type: $fctype\r\n");
1959 }
1960 else {
1961 0 print $s ("Content-Type: $fctype; name=\"$name\"\r\n");
1962 }
1963  
1964 0 ▶ if ($description) {
Branch: 1 branch
BranchTrueFalseTotal
if ($description) 0 0 0
1965 0 print $s ("Content-Description: $description\r\n");
1966 }
1967 0 print $s ("Content-Transfer-Encoding: $encoding\r\n");
1968  
1969 0 ▶ if ($disposition =~ /^(.*)filename=\*(.*)$/i) {
Branch: 2 branches
BranchTrueFalseTotal
if ($disposition =~ /^(.*)filename=\*(.*)$/i) { } 0 0 0
elsif ($disposition and uc $disposition ne 'NONE') { } 0 0 0
1970 0 print $s ("Content-Disposition: ${1}filename=\"$name\"$2\r\n");
1971 }
1972 ▶ elsif ($disposition and uc($disposition) ne 'NONE') {
Condition0%0/3
$disposition and uc $disposition ne "NONE"
!ll&&!rl&&r
000
MC/DC0%0/2
$disposition and uc $disposition ne "NONE"
$disposition uc $disposition ne "NONE"
Truth table0%0/3
A and B
A= $dispositionB= uc $disposition ne "NONE"
ABresult
0X0
100
111
1973 0 print $s ("Content-Disposition: $disposition\r\n");
1974 }
1975  
1976 0 ▶ if ($content_id) {
Branch: 1 branch
BranchTrueFalseTotal
if ($content_id) 0 0 0
1977 0 ▶ if ($content_id eq '*') {
Branch: 2 branches
BranchTrueFalseTotal
if ($content_id eq '*') { } 0 0 0
elsif ($content_id eq '#') { } 0 0 0
1978 0 print $s ("Content-ID: <$name>\r\n");
1979 }
1980 elsif ($content_id eq '#') {
1981 0 print $s ("Content-ID: <id" . $self->{'idcounter'}++ . ">\r\n");
1982 }
1983 else {
1984 0 print $s ("Content-ID: <$content_id>\r\n");
1985 }
1986 }
1987 0 print $s "\r\n";
1988  
1989 $self->{'socket'}->stop_logging("... data skipped ...")
1990 0 ▶ if ($self->{'debug'} and $self->{'debug_level'} == 3);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} and $self->{"debug_level"} == 3 0 0 0
Condition0%0/3
$self->{"debug"} and $self->{"debug_level"} == 3
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"debug"} and $self->{"debug_level"} == 3
$self->{"debug"} $self->{"debug_level"} == 3
Truth table0%0/3
A and B
A= $self->{"debug"}B= $self->{"debug_level"} == 3
ABresult
0X0
100
111
1991  
1992 0 ▶ open my $FH, "<", $file or return $self->Error(_FILECANTREAD($file));
Branch: 1 branch
BranchTrueFalseTotal
open my $FH, "<", $file or return $self->Error(_FILECANTREAD($file)) 0 0 0
1993 0 ▶ binmode $FH
Branch: 1 branch
BranchTrueFalseTotal
unless $fctype =~ m[^text/]i and $encoding =~ /Quoted[_\-]print|Base64/i 0 0 0
Condition0%0/3
$fctype =~ m[^text/]i and $encoding =~ /Quoted[_\-]print|Base64/i
!ll&&!rl&&r
000
MC/DC0%0/2
$fctype =~ m[^text/]i and $encoding =~ /Quoted[_\-]print|Base64/i
$fctype =~ m[^text/]i $encoding =~ /Quoted[_\-]print|Base64/i
Truth table0%0/3
A and B
A= $fctype =~ m[^text/]iB= $encoding =~ /Quoted[_\-]print|Base64/i
ABresult
0X0
100
111
1994 unless $fctype =~ m#^text/#i
1995 and $encoding =~ /Quoted[_\-]print|Base64/i;
1996  
1997 0 my $mychunksize = $chunksize;
1998 0 ▶ $mychunksize = $chunksize64 if lc($encoding) eq "base64";
Branch: 1 branch
BranchTrueFalseTotal
if lc $encoding eq "base64" 0 0 0
1999 0 my $s;
2000 0 ▶ $s = $self->{'socket'} or return $self->Error(_NOTCONNECTED);
Branch: 1 branch
BranchTrueFalseTotal
$s = $self->{"socket"} or return $self->Error(_NOTCONNECTED()) 0 0 0
2001 0 ▶ while (read $FH, $cnt, $mychunksize) {
Branch: 1 branch
BranchTrueFalseTotal
if (read $FH, $cnt, $mychunksize) 0 0 0
2002 0 print $s ($code->($cnt));
2003 }
2004 0 close $FH;
2005 }
2006  
2007 0 return $self;
2008 }
2009  
2010 0 ▶sub EndPart {
Subroutine EndPart: not called CC=13 SCAR=52.0
Pod documented
2011 0 my $self = shift;
2012 0 ▶ return unless $self->{'_part'};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_part"} 0 0 0
2013 0 my $end = shift();
2014 0 my $s;
2015 0 my $LN = "\x0D\x0A";
2016 0 ▶ $s = $self->{'socket'} or return $self->Error(_NOTCONNECTED);
Branch: 1 branch
BranchTrueFalseTotal
$s = $self->{"socket"} or return $self->Error(_NOTCONNECTED()) 0 0 0
2017  
2018 # flush the buffer (if it contains anything)
2019 0 ▶ if ($self->{'_buffer'}) { # used only for base64
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_buffer"}) 0 0 0
2020 0 my $code = $self->{'code'};
2021 0 ▶ if (defined $code) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $code) { } 0 0 0
2022 0 print $s ($code->($self->{'_buffer'}));
2023 }
2024 else {
2025 0 print $s ($self->{'_buffer'});
2026 }
2027 0 delete $self->{'_buffer'};
2028 }
2029 0 ▶ if ($self->{'_had_newline'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_had_newline'}) { } 0 0 0
2030 0 $LN = '';
2031 }
2032 else {
2033 print $s "="
2034 if !$self->{'bypass_outlook_bug'}
2035 0 ▶ and $self->{'encoding'}
Branch: 1 branch
BranchTrueFalseTotal
if not $self->{"bypass_outlook_bug"} and $self->{"encoding"} =~ /Quoted[_\-]print/i 0 0 0
Condition0%0/3
not $self->{"bypass_outlook_bug"} and $self->{"encoding"} =~ /Quoted[_\-]print/i
!ll&&!rl&&r
000
MC/DC0%0/2
not $self->{"bypass_outlook_bug"} and $self->{"encoding"} =~ /Quoted[_\-]print/i
not $self->{"bypass_outlook_bug"} $self->{"encoding"} =~ /Quoted[_\-]print/i
Truth table0%0/3
not(A) and B
A= not $self->{"bypass_outlook_bug"}B= $self->{"encoding"} =~ /Quoted[_\-]print/i
ABresult
0X0
100
111
2036 =~ /Quoted[_\-]print/i; # make sure we do not add a newline
2037 }
2038  
2039 $self->{'socket'}->start_logging()
2040 0 ▶ if ($self->{'debug'} and $self->{'debug_level'} == 3);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} and $self->{"debug_level"} == 3 0 0 0
Condition0%0/3
$self->{"debug"} and $self->{"debug_level"} == 3
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"debug"} and $self->{"debug_level"} == 3
$self->{"debug"} $self->{"debug_level"} == 3
Truth table0%0/3
A and B
A= $self->{"debug"}B= $self->{"debug_level"} == 3
ABresult
0X0
100
111
2041  
2042 0 ▶ if ($self->{'_part'} > 1) { # end of a subpart
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_part'} > 1) { } 0 0 0
2043 0 ▶ print $s "$LN--Part-$self->{'boundary'}_$self->{'_part'}",
Branch: 1 branch
BranchTrueFalseTotal
$end ? : 0 0 0
2044 ($end ? "--" : ()), "\r\n";
2045 }
2046 else {
2047 0 ▶ print $s "$LN--$self->{'boundary'}", ($end ? "--" : ()), "\r\n";
Branch: 1 branch
BranchTrueFalseTotal
$end ? : 0 0 0
2048 }
2049  
2050 0 $self->{'_part'}--;
2051 0 $self->{'code'} = enc_plain($self->{'charset'});
2052 0 $self->{'encoding'} = '';
2053 0 return $self;
2054 }
2055  
2056 0 ▶sub Close {
Subroutine Close: not called CC=12 SCAR=50.5
Pod documented
2057 0 my $self = shift;
2058 0 local $_;
2059 0 my $s = $self->{'socket'};
2060 0 ▶ return 0 unless $s;
Branch: 1 branch
BranchTrueFalseTotal
unless $s 0 0 0
2061  
2062 0 ▶ if ($self->{'_data'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_data"}) 0 0 0
2063  
2064 # flush the buffer (if it contains anything)
2065 0 ▶ if ($self->{'_buffer'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_buffer"}) 0 0 0
2066 0 my $code = $self->{'code'};
2067 0 ▶ if (defined $code) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $code) { } 0 0 0
2068 0 print $s ($code->($self->{'_buffer'}));
2069 }
2070 else {
2071 0 print $s ($self->{'_buffer'});
2072 }
2073 0 delete $self->{'_buffer'};
2074 }
2075  
2076 0 ▶ if ($self->{'_part'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_part"}) 0 0 0
2077 0 ▶ while ($self->{'_part'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_part"}) 0 0 0
2078 0 $self->EndPart(1);
2079 }
2080 }
2081  
2082 0 ▶ $self->{'socket'}->start_logging() if ($self->{'debug'});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"debug"} 0 0 0
2083 0 print $s "\r\n.\r\n";
2084 0 $self->{'_data'} = 0;
2085 0 $_ = get_response($s);
2086 0 ▶ if (/^[45]\d* (.*)$/) { return $self->Error(_TRANSFAILED($1)); }
Branch: 1 branch
BranchTrueFalseTotal
if (/^[45]\d* (.*)$/) 0 0 0
2087 0 $self->{message_response} = $_;
2088 }
2089  
2090 0 delete $self->{'encoding'};
2091 0 delete $self->{'ctype'};
2092  
2093 0 ▶ if ($_[0] or !$self->{'keepconnection'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] or not $self->{"keepconnection"}) 0 0 0
Condition0%0/3
$_[0] or not $self->{"keepconnection"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[0] or not $self->{"keepconnection"}
$_[0] not $self->{"keepconnection"}
Truth table0%0/3
A or not(B)
A= $_[0]B= not $self->{"keepconnection"}
ABresult
1X1
011
000
2094 0 $_ = send_cmd $s, "QUIT";
2095 0 ▶ if (!/^[123]/) { return $self->Error(_COMMERROR($_)); }
Branch: 1 branch
BranchTrueFalseTotal
unless (/^[123]/) 0 0 0
2096 0 close $s;
2097 0 delete $self->{'socket'};
2098 0 delete $self->{'debug'};
2099 }
2100 0 return $self;
2101 }
2102  
2103 0 ▶sub Cancel {
Subroutine Cancel: not called CC=2 SCAR=17.9
Pod documented
2104 0 my $self = shift;
2105 0 my $s;
2106 0 ▶ $s = $self->{'socket'} or return $self->Error(_NOTCONNECTED);
Branch: 1 branch
BranchTrueFalseTotal
$s = $self->{"socket"} or return $self->Error(_NOTCONNECTED()) 0 0 0
2107 0 close $s;
2108 0 delete $self->{'socket'};
2109 0 delete $self->{'error'};
2110 0 return $self;
2111 }
2112  
2113 19 ▶sub DESTROY {
Subroutine DESTROY: called CC=3 SCAR=13.3
2114 19 ▶ return if ref($_[0]) ne 'Mail::Sender';
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] ne "Mail::Sender" 0 19 19
2115 19 my $self = shift;
2116 19 ▶ if (defined $self->{'socket'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"socket"}) 0 19 19
2117 0 delete $self->{'keepconnection'};
2118 0 $self->Close;
2119 }
2120 }
2121  
2122 0 ▶sub MessageID {
Subroutine MessageID: not called CC=1 SCAR=6.9
Pod documented
2123 0 my $from = shift;
2124 0 my ($sec, $min, $hour, $mday, $mon, $year) = gmtime(time);
2125 0 $mon++;
2126 0 $year += 1900;
2127  
2128 0 return sprintf "<%04d%02d%02d_%02d%02d%02d_%06d.%s>", $year, $mon, $mday,
2129 $hour, $min, $sec, rand(100000), $from;
2130 }
2131  
2132 0 ▶sub QueryAuthProtocols {
Subroutine QueryAuthProtocols: not called CC=18 SCAR=58.3
Pod documented
2133 0 my $self = shift;
2134 0 ▶ Carp::croak(
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self 0 0 0
2135 "Mail::Sender::QueryAuthProtocols() called without any parameter!")
2136 unless defined $self;
2137 0 local $_;
2138 0 ▶ if (ref $self) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $self) { } 0 0 0
elsif ($self =~ /::/) { } 0 0 0
2139  
2140 # $sender->QueryAuthProtocols() or $sender->QueryAuthProtocols('the.server.com)
2141 0 ▶ if ($self->{'socket'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"socket"}) 0 0 0
2142  
2143 # the user did not Close() or Cancel() the previous mail
2144 0 die
2145 "You forgot to close the mail before calling QueryAuthProtocols!\n";
2146 }
2147 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
2148 0 $self->{'smtp'} = shift();
2149 0 $self->{'smtp'} =~ s/^\s+//g; # remove spaces around $smtp
2150 0 $self->{'smtp'} =~ s/\s+$//g;
2151 0 $self->{'smtpaddr'} = Socket::inet_aton($self->{'smtp'});
2152 0 ▶ if (!defined($self->{'smtpaddr'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"smtpaddr"}) 0 0 0
2153 0 return $self->Error(_HOSTNOTFOUND($self->{'smtp'}));
2154 }
2155 $self->{'smtpaddr'} = $1
2156 0 ▶ if ($self->{'smtpaddr'} =~ /(.*)/s); # Untaint
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"smtpaddr"} =~ /(.*)/s 0 0 0
2157 }
2158 }
2159 elsif ($self =~ /::/) { # Mail::Sender->QueryAuthProtocols('the.server.com')
2160 0 ▶ Carp::croak
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
2161 "Mail::Sender->QueryAuthProtocols() called without any parameter!"
2162 if !@_;
2163 0 $self = Mail::Sender->new({smtp => $_[0]});
2164 0 ▶ return unless ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
2165 }
2166 else { # Mail::Sender::QueryAuthProtocols('the.server.com')
2167 0 $self = Mail::Sender->new({smtp => $self});
2168 0 ▶ return unless ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
2169 }
2170  
2171 0 ▶ return $self->Error(_NOSERVER) unless defined $self->{'smtp'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"smtp"} 0 0 0
2172  
2173 my $s = IO::Socket::INET->new(
2174 PeerHost => $self->{'smtp'},
2175 PeerPort => $self->{'port'},
2176 Proto => "tcp",
2177 0 ▶ Timeout => $self->{'timeout'} || 120,
Branch: 1 branch
BranchTrueFalseTotal
my $s = "IO::Socket::INET"->new("PeerHost", $self->{"smtp"}, "PeerPort", $self->{"port"}, "Proto", "tcp", "Timeout", $self->{"timeout"} || 120) or return $self->Error(_CONNFAILED()) 0 0 0
Condition0%0/2
$self->{'timeout'} || 120
l!l
00
MC/DC0%0/1
$self->{'timeout'} || 120
$self->{'timeout'}
Truth table0%0/2
A
A= $self->{'timeout'}
Aresult
11
00
2178 ) or return $self->Error(_CONNFAILED);
2179  
2180 0 $s->autoflush(1);
2181  
2182 0 $_ = get_response($s);
2183 0 ▶ if (not $_ or !/^[123]/) { return $self->Error(_SERVNOTAVAIL($_)); }
Branch: 1 branch
BranchTrueFalseTotal
unless ($_ and /^[123]/) 0 0 0
Condition0%0/3
$_ and /^[123]/
!ll&&!rl&&r
000
MC/DC0%0/2
$_ and /^[123]/
$_ /^[123]/
Truth table0%0/3
A and B
A= $_B= /^[123]/
ABresult
0X0
100
111
2184 0 $self->{'server'} = substr $_, 4;
2185  
2186 {
2187 0 my $res = $self->_say_helo($s);
2188 0 ▶ return $res if $res;
Branch: 1 branch
BranchTrueFalseTotal
if $res 0 0 0
2189 }
2190  
2191 0 $_ = send_cmd $s, "QUIT";
2192 0 close $s;
2193 0 delete $self->{'socket'};
2194  
2195 0 ▶ if (wantarray) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
2196 0 return keys %{$self->{'auth_protocols'}};
2197 }
2198 else {
2199 0 my $key = each %{$self->{'auth_protocols'}};
2200 0 return $key;
2201 }
2202 }
2203  
2204 0 ▶sub printAuthProtocols {
Subroutine printAuthProtocols: not called CC=2 SCAR=17.9
Pod undocumented
2205 0 ▶ print "$_[1] supports: ",
Condition0%0/2
$_[1] || 'localhost'
l!l
00
MC/DC0%0/1
$_[1] || 'localhost'
$_[1]
Truth table0%0/2
A
A= $_[1]
Aresult
11
00
2206 join(", ", Mail::Sender->QueryAuthProtocols($_[1] || 'localhost')),
2207 "\n";
2208 }
2209  
2210 0 ▶sub TestServer {
Subroutine TestServer: not called CC=21 SCAR=61.4
Pod undocumented
2211 0 my $self = shift;
2212 0 local $_;
2213 0 ▶ if (!defined $self) {
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $self) { } 0 0 0
elsif (ref $self) { } 0 0 0
elsif ($self =~ /::/) { } 0 0 0
2214 0 Carp::croak "Mail::Sender::TestServer() called without any parameter!";
2215 }
2216 elsif (ref $self)
2217 { # $sender->TestServer() or $sender->TestServer('the.server.com)
2218 0 ▶ if ($self->{'socket'})
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"socket"}) 0 0 0
2219 { # the user did not Close() or Cancel() the previous mail
2220 0 die "You forgot to close the mail before calling TestServer!\n";
2221 }
2222 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
2223 0 $self->{'smtp'} = shift();
2224 0 $self->{'smtp'} =~ s/^\s+//g; # remove spaces around $smtp
2225 0 $self->{'smtp'} =~ s/\s+$//g;
2226 0 $self->{'smtpaddr'} = Socket::inet_aton($self->{'smtp'});
2227 0 ▶ if (!defined($self->{'smtpaddr'})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"smtpaddr"}) 0 0 0
2228 0 return $self->Error(_HOSTNOTFOUND($self->{'smtp'}));
2229 }
2230 $self->{'smtpaddr'} = $1
2231 0 ▶ if ($self->{'smtpaddr'} =~ /(.*)/s); # Untaint
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"smtpaddr"} =~ /(.*)/s 0 0 0
2232 }
2233 0 $self->{'on_errors'} = 'die';
2234 }
2235 elsif ($self =~ /::/) { # Mail::Sender->TestServer('the.server.com')
2236 0 ▶ Carp::croak("Mail::Sender->TestServer() called without any parameter!")
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
2237 if !@_;
2238 0 $self = Mail::Sender->new({smtp => $_[0], on_errors => 'die'});
2239 0 ▶ return unless ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
2240 }
2241 else { # Mail::Sender::QueryAuthProtocols('the.server.com')
2242 0 $self = Mail::Sender->new({smtp => $self, on_errors => 'die'});
2243 0 ▶ return unless ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
2244 }
2245  
2246 0 ▶ return $self->Error(_NOSERVER) unless defined $self->{'smtp'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"smtp"} 0 0 0
2247  
2248 # if (!defined($self->{'smtpaddr'})) { return $self->Error(_HOSTNOTFOUND($self->{'smtp'})); }
2249  
2250 0 ▶ if (exists $self->{'on_errors'}
Branch: 2 branches
BranchTrueFalseTotal
if (exists $self->{'on_errors'} and !defined($self->{'on_errors'}) || $self->{'on_errors'} eq 'undef') { } 0 0 0
elsif (exists $self->{'on_errors'} and $self->{'on_errors'} eq 'die') { } 0 0 0
Condition0%0/6
exists $self->{"on_errors"} and !defined($self->{"on_errors"}) || $self->{"on_errors"} eq "undef"
!ll&&!rl&&r
000
not defined $self->{"on_errors"} or $self->{"on_errors"} eq "undef"
l!l&&r!l&&!r
000
MC/DC0%0/3
exists $self->{"on_errors"} and !defined($self->{"on_errors"}) || $self->{"on_errors"} eq "undef"
exists $self->{"on_errors"} not defined $self->{"on_errors"} $self->{"on_errors"} eq "undef"
Truth table0%0/4
A and not(B) or C
A= exists $self->{"on_errors"}B= not defined $self->{"on_errors"}C= $self->{"on_errors"} eq "undef"
ABCresult
0XX0
1000
11X1
1011
2251 and (!defined($self->{'on_errors'}) or $self->{'on_errors'} eq 'undef'))
2252 {
2253 0 ▶ return ($self->Connect() and $self->Close() and 1);
Condition0%0/5
$self->Connect && $self->Close && 1
!ll
00
$self->Connect and $self->Close
!ll&&!rl&&r
000
MC/DC0%0/2
$self->Connect && $self->Close && 1
$self->Connect $self->Close
Truth table0%0/3
A and B
A= $self->ConnectB= $self->Close
ABresult
0X0
100
111
2254 }
2255 ▶ elsif (exists $self->{'on_errors'} and $self->{'on_errors'} eq 'die') {
Condition0%0/3
exists $self->{"on_errors"} and $self->{"on_errors"} eq "die"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $self->{"on_errors"} and $self->{"on_errors"} eq "die"
exists $self->{"on_errors"} $self->{"on_errors"} eq "die"
Truth table0%0/3
A and B
A= exists $self->{"on_errors"}B= $self->{"on_errors"} eq "die"
ABresult
0X0
100
111
2256 0 $self->Connect();
2257 0 $self->Close();
2258 0 return 1;
2259 }
2260 else {
2261 0 my $res = $self->Connect();
2262 0 ▶ return $res unless ref $res;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $res 0 0 0
2263 0 $res = $self->Close();
2264 0 ▶ return $res unless ref $res;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $res 0 0 0
2265 0 return $self;
2266 }
2267 }
2268  
2269 #====== Debuging bazmecks
2270  
2271 2 $debug_code = <<'END';
2272 package Mail::Sender::DBIO;
2273 use IO::Handle;
2274 use Tie::Handle;
2275 @Mail::Sender::DBIO::ISA = qw(Tie::Handle);
2276  
2277 sub SOCKET () {0}
2278 sub LOG () {1}
2279 sub ENDLINE () {2}
2280 sub CLOSELOG () {3}
2281 sub OFF () {4}
2282  
2283 sub TIEHANDLE {
2284 my ($pkg,$socket,$debughandle, $mayCloseLog) = @_;
2285 return bless [$socket,$debughandle,1, $mayCloseLog,0], $pkg;
2286 }
2287  
2288 sub PRINT {
2289 my $self = shift;
2290 my $text = join(($\ || ''), @_);
2291 $self->[SOCKET]->print($text);
2292 return if $self->[OFF];
2293 $text =~ s/\x0D\x0A(?=.)/\x0D\x0A<< /g;
2294 $text = "<< ".$text if $self->[ENDLINE];
2295 $self->[ENDLINE] = ($text =~ /\x0D\x0A$/);
2296 $self->[LOG]->print($text);
2297 }
2298  
2299 sub READLINE {
2300 my $self = shift();
2301 my $socket = $self->[SOCKET];
2302 my $line = <$socket>;
2303 $self->[LOG]->print(">> $line") if defined $line and !$self->[OFF];
2304 return $line;
2305 }
2306  
2307 sub CLOSE {
2308 my $self = shift();
2309 $self->[SOCKET]->close();
2310 $self->[LOG]->close() if $self->[CLOSELOG];
2311 return $self->[SOCKET];
2312 }
2313  
2314 sub opened {
2315 our $SOCKET;
2316 local *SOCKET = $_[SOCKET] or return;
2317 $SOCKET->opened();
2318 }
2319  
2320 use Data::Dumper;
2321 sub stop_logging {
2322 my $self = tied(${$_[0]});
2323  
2324 #print "stop_logging( ".$self." )\n";
2325  
2326 return if $self->[OFF];
2327 $self->[OFF] = 1;
2328  
2329 my $text = join(($\ || ''), $_[1])
2330 or return;
2331 $text .= "\x0D\x0A";
2332 $text =~ s/\x0D\x0A(?=.)/\x0D\x0A<< /g;
2333 $text = "<< ".$text if $self->[ENDLINE];
2334 $self->[ENDLINE] = ($text =~ /\x0D\x0A$/);
2335 $self->[LOG]->print($text);
2336 }
2337  
2338 sub start_logging {
2339 my $self = tied(${$_[0]});
2340 $self->[OFF] = 0;
2341 }
2342 END
2343  
2344 2 my $pseudo_handle_code = <<'END';
2345 package Mail::Sender::IO;
2346 use IO::Handle;
2347 use Tie::Handle;
2348 @Mail::Sender::IO::ISA = qw(Tie::Handle);
2349  
2350 sub TIEHANDLE {
2351 my ($pkg,$sender) = @_;
2352 return bless [$sender, $sender->{'_part'}], $pkg;
2353 }
2354  
2355 sub PRINT {
2356 my $self = shift;
2357 $self->[0]->SendEnc(@_);
2358 }
2359  
2360 sub PRINTF {
2361 my $self = shift;
2362 my $format = shift;
2363 $self->[0]->SendEnc( sprintf $format, @_);
2364 }
2365  
2366 sub CLOSE {
2367 my $self = shift();
2368 if ($self->[1]) {
2369 $self->[1]->EndPart();
2370 } else {
2371 $self->[0]->Close();
2372 }
2373 }
2374 END
2375  
2376 package Mail::Sender;
2377  
2378 0 ▶sub GetHandle {
Subroutine GetHandle: not called CC=2 SCAR=17.9
Pod documented
2379 0 my $self = shift();
2380 0 ▶ unless (@Mail::Sender::IO::ISA) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@Mail::Sender::IO::ISA) 0 0 0
2381 0 eval "use Symbol;";
2382 0 eval $pseudo_handle_code;
2383 }
2384 0 my $handle = gensym();
2385 0 tie *$handle, 'Mail::Sender::IO', $self;
2386 0 return $handle;
2387 }
2388  
2389 2 1;
2390  
2391 __END__
↑ Summary Sender/CType/Ext.pm »