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