line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2001-2022 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
|
4
|
|
|
4
|
|
1092
|
use vars '$VERSION'; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
268
|
|
11
|
|
|
|
|
|
|
$VERSION = '3.012'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
4
|
|
|
4
|
|
35
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
114
|
|
15
|
4
|
|
|
4
|
|
22
|
use warnings; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
120
|
|
16
|
|
|
|
|
|
|
|
17
|
4
|
|
|
4
|
|
22
|
use Mail::Box::FastScalar; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
1401
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub read($@) |
21
|
7
|
|
|
7
|
1
|
403
|
{ my ($class, $from, %args) = @_; |
22
|
7
|
|
|
|
|
13
|
my ($filename, $file); |
23
|
7
|
|
|
|
|
15
|
my $ref = ref $from; |
24
|
|
|
|
|
|
|
|
25
|
7
|
100
|
33
|
|
|
44
|
if(!$ref) |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
26
|
3
|
|
|
|
|
6
|
{ $filename = 'scalar'; |
27
|
3
|
|
|
|
|
18
|
$file = Mail::Box::FastScalar->new(\$from); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
elsif($ref eq 'SCALAR') |
30
|
1
|
|
|
|
|
3
|
{ $filename = 'ref scalar'; |
31
|
1
|
|
|
|
|
5
|
$file = Mail::Box::FastScalar->new($from); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
elsif($ref eq 'ARRAY') |
34
|
1
|
|
|
|
|
2
|
{ $filename = 'array of lines'; |
35
|
1
|
|
|
|
|
4
|
my $buffer= join '', @$from; |
36
|
1
|
|
|
|
|
5
|
$file = Mail::Box::FastScalar->new(\$buffer); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
elsif($ref eq 'GLOB') |
39
|
1
|
|
|
|
|
1
|
{ $filename = 'file (GLOB)'; |
40
|
1
|
|
|
|
|
4
|
local $/; |
41
|
1
|
|
|
|
|
19
|
my $buffer= <$from>; |
42
|
1
|
|
|
|
|
7
|
$file = Mail::Box::FastScalar->new(\$buffer); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
elsif($ref && $from->isa('IO::Handle')) |
45
|
1
|
|
|
|
|
4
|
{ $filename = 'file ('.ref($from).')'; |
46
|
1
|
|
|
|
|
30
|
my $buffer= join '', $from->getlines; |
47
|
1
|
|
|
|
|
67
|
$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
|
|
|
|
22
|
: 1; |
57
|
|
|
|
|
|
|
|
58
|
7
|
|
|
|
|
1456
|
require Mail::Box::Parser::Perl; # not parseable by C parser |
59
|
|
|
|
|
|
|
|
60
|
7
|
|
|
|
|
46
|
my $parser = Mail::Box::Parser::Perl->new |
61
|
|
|
|
|
|
|
( %args |
62
|
|
|
|
|
|
|
, filename => $filename |
63
|
|
|
|
|
|
|
, file => $file |
64
|
|
|
|
|
|
|
, trusted => 1 |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
|
67
|
7
|
|
|
|
|
37
|
my $self = $class->new(%args); |
68
|
7
|
|
|
|
|
39
|
$self->readFromParser($parser, $args{body_type}); |
69
|
7
|
|
|
|
|
60
|
$self->addReport($parser); |
70
|
|
|
|
|
|
|
|
71
|
7
|
|
|
|
|
34
|
$parser->stop; |
72
|
|
|
|
|
|
|
|
73
|
7
|
|
|
|
|
16
|
my $head = $self->head; |
74
|
7
|
100
|
|
|
|
21
|
$head->set('Message-ID' => '<'.$self->messageId.'>') |
75
|
|
|
|
|
|
|
unless $head->get('Message-ID'); |
76
|
|
|
|
|
|
|
|
77
|
7
|
100
|
|
|
|
33
|
$head->delete('Status', 'X-Status') if $strip_status; |
78
|
|
|
|
|
|
|
|
79
|
7
|
|
|
|
|
28
|
$self; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |