| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# This code is part of Perl distribution Mail-Message version 4.04. |
|
2
|
|
|
|
|
|
|
# The POD got stripped from this file by OODoc version 3.06. |
|
3
|
|
|
|
|
|
|
# For contributors see file ChangeLog. |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# This software is copyright (c) 2001-2026 by Mark Overmeer. |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under |
|
8
|
|
|
|
|
|
|
# the same terms as the Perl 5 programming language system itself. |
|
9
|
|
|
|
|
|
|
# SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package Mail::Message::Head::ResentGroup;{ |
|
13
|
|
|
|
|
|
|
our $VERSION = '4.04'; |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
|
|
16
|
3
|
|
|
3
|
|
3387
|
use parent 'Mail::Message::Head::FieldGroup'; |
|
|
3
|
|
|
|
|
8
|
|
|
|
3
|
|
|
|
|
26
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
3
|
|
|
3
|
|
211
|
use strict; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
64
|
|
|
19
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
225
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
3
|
|
|
3
|
|
16
|
use Log::Report 'mail-message', import => [ qw// ]; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
22
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
3
|
|
|
3
|
|
571
|
use Scalar::Util qw/weaken/; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
194
|
|
|
24
|
3
|
|
|
3
|
|
384
|
use Sys::Hostname qw/hostname/; |
|
|
3
|
|
|
|
|
1250
|
|
|
|
3
|
|
|
|
|
168
|
|
|
25
|
3
|
|
|
3
|
|
496
|
use Mail::Address (); |
|
|
3
|
|
|
|
|
2649
|
|
|
|
3
|
|
|
|
|
65
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
3
|
|
|
3
|
|
463
|
use Mail::Message::Field::Fast (); |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
7533
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
#-------------------- |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# all lower cased! |
|
32
|
|
|
|
|
|
|
my @ordered_field_names = ( |
|
33
|
|
|
|
|
|
|
'return-path', 'delivered-to' , 'received', 'resent-date', |
|
34
|
|
|
|
|
|
|
'resent-from', 'resent-sender', , 'resent-to', 'resent-cc', |
|
35
|
|
|
|
|
|
|
'resent-bcc', 'resent-message-id' |
|
36
|
|
|
|
|
|
|
); |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my %resent_field_names = map +($_ => 1), @ordered_field_names; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub init($$) |
|
41
|
6
|
|
|
6
|
0
|
12
|
{ my ($self, $args) = @_; |
|
42
|
|
|
|
|
|
|
|
|
43
|
6
|
|
|
|
|
27
|
$self->SUPER::init($args); |
|
44
|
|
|
|
|
|
|
|
|
45
|
6
|
|
|
|
|
32
|
$self->{MMHR_real} = $args->{message_head}; |
|
46
|
|
|
|
|
|
|
|
|
47
|
6
|
50
|
33
|
|
|
15
|
$self->set(Received => $self->createReceived) |
|
48
|
|
|
|
|
|
|
if $self->orderedFields && ! $self->received; |
|
49
|
|
|
|
|
|
|
|
|
50
|
6
|
|
|
|
|
30
|
$self; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub from($@) |
|
55
|
4
|
100
|
|
4
|
1
|
1656
|
{ @_==1 and return $_[0]->resentFrom; # backwards compat |
|
56
|
|
|
|
|
|
|
|
|
57
|
3
|
|
|
|
|
6
|
my ($class, $from, %args) = @_; |
|
58
|
3
|
50
|
|
|
|
17
|
my $head = $from->isa('Mail::Message::Head') ? $from : $from->head; |
|
59
|
|
|
|
|
|
|
|
|
60
|
3
|
|
|
|
|
4
|
my (@groups, $group, $return_path, $delivered_to); |
|
61
|
|
|
|
|
|
|
|
|
62
|
3
|
|
|
|
|
20
|
foreach my $field ($head->orderedFields) |
|
63
|
24
|
|
|
|
|
42
|
{ my $name = $field->name; |
|
64
|
24
|
100
|
|
|
|
43
|
$resent_field_names{$name} or next; |
|
65
|
|
|
|
|
|
|
|
|
66
|
12
|
100
|
|
|
|
30
|
if($name eq 'return-path') { $return_path = $field } |
|
|
1
|
50
|
|
|
|
2
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
0
|
elsif($name eq 'delivered-to') { $delivered_to = $field } |
|
68
|
|
|
|
|
|
|
elsif(substr($name, 0, 7) eq 'resent-') |
|
69
|
8
|
50
|
|
|
|
12
|
{ $group->add($field) if defined $group; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
elsif($name eq 'received') |
|
72
|
|
|
|
|
|
|
{ |
|
73
|
3
|
|
|
|
|
7
|
$group = Mail::Message::Head::ResentGroup ->new($field, message_head => $head); |
|
74
|
3
|
|
|
|
|
6
|
push @groups, $group; |
|
75
|
|
|
|
|
|
|
|
|
76
|
3
|
50
|
|
|
|
5
|
$group->add($delivered_to) if defined $delivered_to; |
|
77
|
3
|
|
|
|
|
4
|
undef $delivered_to; |
|
78
|
|
|
|
|
|
|
|
|
79
|
3
|
100
|
|
|
|
6
|
$group->add($return_path) if defined $return_path; |
|
80
|
3
|
|
|
|
|
5
|
undef $return_path; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
3
|
|
|
|
|
17
|
@groups; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
#-------------------- |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub messageHead(;$) |
|
90
|
4
|
|
|
4
|
1
|
7
|
{ my $self = shift; |
|
91
|
4
|
100
|
|
|
|
33
|
@_ ? $self->{MMHR_real} = shift : $self->{MMHR_real}; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub orderedFields() |
|
96
|
14
|
|
|
14
|
1
|
1088
|
{ my $head = shift->head; |
|
97
|
14
|
100
|
|
|
|
28
|
map { $head->get($_) || () } @ordered_field_names; |
|
|
140
|
|
|
|
|
206
|
|
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub set($;$) |
|
102
|
27
|
|
|
27
|
1
|
29
|
{ my $self = shift; |
|
103
|
27
|
|
|
|
|
26
|
my $field; |
|
104
|
|
|
|
|
|
|
|
|
105
|
27
|
100
|
|
|
|
47
|
if(@_==1) { $field = shift } |
|
|
12
|
|
|
|
|
13
|
|
|
106
|
|
|
|
|
|
|
else |
|
107
|
15
|
|
|
|
|
25
|
{ my ($fn, $value) = @_; |
|
108
|
15
|
100
|
|
|
|
39
|
my $name = $resent_field_names{lc $fn} ? $fn : "Resent-$fn"; |
|
109
|
15
|
|
|
|
|
50
|
$field = Mail::Message::Field::Fast->new($name, $value); |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
27
|
|
|
|
|
48
|
$self->head->set($field); |
|
113
|
27
|
|
|
|
|
57
|
$field; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
1
|
|
|
1
|
1
|
2
|
sub fields() { $_[0]->orderedFields } |
|
117
|
1
|
|
|
1
|
1
|
592
|
sub fieldNames() { map $_->Name, $_[0]->orderedFields } |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub delete() |
|
120
|
1
|
|
|
1
|
1
|
470
|
{ my $self = shift; |
|
121
|
1
|
|
|
|
|
3
|
my $head = $self->messageHead; |
|
122
|
1
|
|
|
|
|
4
|
$head->removeField($_) for $self->fields; |
|
123
|
1
|
|
|
|
|
8
|
$self; |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
|
127
|
27
|
|
|
27
|
1
|
48
|
sub add(@) { shift->set(@_) } |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
|
130
|
0
|
|
|
0
|
1
|
0
|
sub addFields(@) { $_[0]->notImplemented } |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
#-------------------- |
|
133
|
|
|
|
|
|
|
|
|
134
|
0
|
|
|
0
|
1
|
0
|
sub returnPath() { $_[0]->{MMHR_return_path} } |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
|
137
|
0
|
|
|
0
|
1
|
0
|
sub deliveredTo() { $_[0]->head->get('Delivered-To') } |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
|
140
|
6
|
|
|
6
|
1
|
12
|
sub received() { $_[0]->head->get('Received') } |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub receivedTimestamp() |
|
144
|
0
|
0
|
|
0
|
1
|
0
|
{ my $received = $_[0]->received or return; |
|
145
|
0
|
0
|
|
|
|
0
|
my $comment = $received->comment or return; |
|
146
|
0
|
|
|
|
|
0
|
Mail::Message::Field->dateToTimestamp($comment); |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
|
150
|
1
|
|
|
1
|
1
|
3
|
sub date($) { $_[0]->head->get('resent-date') } |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub dateTimestamp() |
|
154
|
0
|
0
|
|
0
|
1
|
0
|
{ my $date = $_[0]->date or return; |
|
155
|
0
|
|
|
|
|
0
|
Mail::Message::Field->dateToTimestamp($date->unfoldedBody); |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub resentFrom() |
|
160
|
1
|
50
|
|
1
|
1
|
6
|
{ my $from = $_[0]->head->get('resent-from') or return (); |
|
161
|
1
|
50
|
|
|
|
4
|
wantarray ? $from->addresses : $from; |
|
162
|
|
|
|
|
|
|
} |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub sender() |
|
166
|
0
|
0
|
|
0
|
1
|
0
|
{ my $sender = $_[0]->head->get('resent-sender') or return (); |
|
167
|
0
|
0
|
|
|
|
0
|
wantarray ? $sender->addresses : $sender; |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub to() |
|
172
|
0
|
0
|
|
0
|
1
|
0
|
{ my $to = $_[0]->head->get('resent-to') or return (); |
|
173
|
0
|
0
|
|
|
|
0
|
wantarray ? $to->addresses : $to; |
|
174
|
|
|
|
|
|
|
} |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
sub cc() |
|
178
|
0
|
0
|
|
0
|
1
|
0
|
{ my $cc = $_[0]->head->get('resent-cc') or return (); |
|
179
|
0
|
0
|
|
|
|
0
|
wantarray ? $cc->addresses : $cc; |
|
180
|
|
|
|
|
|
|
} |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub bcc() |
|
184
|
0
|
0
|
|
0
|
1
|
0
|
{ my $bcc = $_[0]->head->get('resent-bcc') or return (); |
|
185
|
0
|
0
|
|
|
|
0
|
wantarray ? $bcc->addresses : $bcc; |
|
186
|
|
|
|
|
|
|
} |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub destinations() |
|
190
|
0
|
|
|
0
|
1
|
0
|
{ my $self = shift; |
|
191
|
0
|
|
|
|
|
0
|
($self->to, $self->cc, $self->bcc); |
|
192
|
|
|
|
|
|
|
} |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
|
|
195
|
2
|
|
|
2
|
1
|
1124
|
sub messageId() { $_[0]->head->get('resent-message-id') } |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
|
|
198
|
13
|
|
|
13
|
1
|
33
|
sub isResentGroupFieldName($) { $resent_field_names{lc $_[1]} } |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
#-------------------- |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
my $unique_received_id = 'rc'.time; |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
sub createReceived(;$) |
|
205
|
0
|
|
|
0
|
1
|
|
{ my ($self, $domain) = @_; |
|
206
|
|
|
|
|
|
|
|
|
207
|
0
|
0
|
|
|
|
|
unless(defined $domain) |
|
208
|
0
|
|
0
|
|
|
|
{ my $sender = ($self->sender)[0] || ($self->resentFrom)[0]; |
|
209
|
0
|
0
|
|
|
|
|
$domain = $sender->host if defined $sender; |
|
210
|
|
|
|
|
|
|
} |
|
211
|
|
|
|
|
|
|
|
|
212
|
0
|
|
|
|
|
|
my $received |
|
213
|
|
|
|
|
|
|
= "from $domain by ". hostname . ' with SMTP id ' . $unique_received_id++ |
|
214
|
|
|
|
|
|
|
. ' for ' . $self->head->get('Resent-To') # may be wrong |
|
215
|
|
|
|
|
|
|
. '; '. Mail::Message::Field->toDate; |
|
216
|
|
|
|
|
|
|
|
|
217
|
0
|
|
|
|
|
|
$received; |
|
218
|
|
|
|
|
|
|
} |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
#-------------------- |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
1; |