| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Copyrights 2001-2023 by [Mark Overmeer ]. |
|
2
|
|
|
|
|
|
|
# For other contributors see ChangeLog. |
|
3
|
|
|
|
|
|
|
# See the manual pages for details on the licensing terms. |
|
4
|
|
|
|
|
|
|
# Pod stripped from pm file by OODoc 2.03. |
|
5
|
|
|
|
|
|
|
# This code is part of distribution Mail-Message. Meta-POD processed with |
|
6
|
|
|
|
|
|
|
# OODoc into POD and HTML manual-pages. See README.md |
|
7
|
|
|
|
|
|
|
# Copyright Mark Overmeer. Licensed under the same terms as Perl itself. |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package Mail::Message; |
|
10
|
6
|
|
|
6
|
|
1370
|
use vars '$VERSION'; |
|
|
6
|
|
|
|
|
15
|
|
|
|
6
|
|
|
|
|
376
|
|
|
11
|
|
|
|
|
|
|
$VERSION = '3.013'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
6
|
|
|
6
|
|
45
|
use strict; |
|
|
6
|
|
|
|
|
14
|
|
|
|
6
|
|
|
|
|
170
|
|
|
15
|
6
|
|
|
6
|
|
32
|
use warnings; |
|
|
6
|
|
|
|
|
13
|
|
|
|
6
|
|
|
|
|
174
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
6
|
|
|
6
|
|
37
|
use Mail::Box::FastScalar; |
|
|
6
|
|
|
|
|
15
|
|
|
|
6
|
|
|
|
|
185
|
|
|
18
|
6
|
|
|
6
|
|
2553
|
use Mail::Box::Parser::Perl (); |
|
|
6
|
|
|
|
|
17
|
|
|
|
6
|
|
|
|
|
1988
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub read($@) |
|
22
|
12
|
|
|
12
|
1
|
1245
|
{ my ($class, $from, %args) = @_; |
|
23
|
|
|
|
|
|
|
|
|
24
|
12
|
|
|
|
|
23
|
my ($filename, $file); |
|
25
|
12
|
|
|
|
|
27
|
my $ref = ref $from; |
|
26
|
12
|
100
|
33
|
|
|
67
|
if(!$ref) |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
27
|
8
|
|
|
|
|
14
|
{ $filename = 'scalar'; |
|
28
|
8
|
|
|
|
|
54
|
$file = Mail::Box::FastScalar->new(\$from); |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
elsif($ref eq 'SCALAR') |
|
31
|
1
|
|
|
|
|
3
|
{ $filename = 'ref scalar'; |
|
32
|
1
|
|
|
|
|
6
|
$file = Mail::Box::FastScalar->new($from); |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
elsif($ref eq 'ARRAY') |
|
35
|
1
|
|
|
|
|
2
|
{ $filename = 'array of lines'; |
|
36
|
1
|
|
|
|
|
6
|
my $buffer= join '', @$from; |
|
37
|
1
|
|
|
|
|
7
|
$file = Mail::Box::FastScalar->new(\$buffer); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
elsif($ref eq 'GLOB') |
|
40
|
1
|
|
|
|
|
3
|
{ $filename = 'file (GLOB)'; |
|
41
|
1
|
|
|
|
|
5
|
local $/; |
|
42
|
1
|
|
|
|
|
23
|
my $buffer= <$from>; |
|
43
|
1
|
|
|
|
|
6
|
$file = Mail::Box::FastScalar->new(\$buffer); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
elsif($ref && $from->isa('IO::Handle')) |
|
46
|
1
|
|
|
|
|
7
|
{ $filename = 'file ('.ref($from).')'; |
|
47
|
1
|
|
|
|
|
30
|
my $buffer= join '', $from->getlines; |
|
48
|
1
|
|
|
|
|
84
|
$file = Mail::Box::FastScalar->new(\$buffer); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
else |
|
51
|
0
|
|
|
|
|
0
|
{ $class->log(ERROR => "Cannot read from $from"); |
|
52
|
0
|
|
|
|
|
0
|
return undef; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $strip_status |
|
56
|
|
|
|
|
|
|
= exists $args{strip_status_fields} |
|
57
|
|
|
|
|
|
|
? delete $args{strip_status_fields} |
|
58
|
12
|
100
|
|
|
|
40
|
: 1; |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# Not parseable by the C implementation |
|
61
|
12
|
|
|
|
|
87
|
my $parser = Mail::Box::Parser::Perl->new |
|
62
|
|
|
|
|
|
|
( %args |
|
63
|
|
|
|
|
|
|
, filename => $filename |
|
64
|
|
|
|
|
|
|
, file => $file |
|
65
|
|
|
|
|
|
|
, trusted => 1 |
|
66
|
|
|
|
|
|
|
); |
|
67
|
|
|
|
|
|
|
|
|
68
|
12
|
|
|
|
|
53
|
my $self = $class->new(%args); |
|
69
|
12
|
|
|
|
|
71
|
$self->readFromParser($parser, $args{body_type}); |
|
70
|
12
|
|
|
|
|
113
|
$self->addReport($parser); |
|
71
|
|
|
|
|
|
|
|
|
72
|
12
|
|
|
|
|
76
|
$parser->stop; |
|
73
|
|
|
|
|
|
|
|
|
74
|
12
|
|
|
|
|
35
|
my $head = $self->head; |
|
75
|
12
|
100
|
|
|
|
46
|
$head->get('Message-ID') |
|
76
|
|
|
|
|
|
|
or $head->set('Message-ID' => '<'.$self->messageId.'>'); |
|
77
|
|
|
|
|
|
|
|
|
78
|
12
|
100
|
|
|
|
70
|
$head->delete('Status', 'X-Status') if $strip_status; |
|
79
|
|
|
|
|
|
|
|
|
80
|
12
|
|
|
|
|
64
|
$self; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |