line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
755
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
65
|
|
3
|
|
|
|
|
|
|
package Email::Simple::Test::TraceHeaders; |
4
|
|
|
|
|
|
|
{ |
5
|
|
|
|
|
|
|
$Email::Simple::Test::TraceHeaders::VERSION = '0.091702'; |
6
|
|
|
|
|
|
|
} |
7
|
|
|
|
|
|
|
# ABSTRACT: generate sample trace headers for testing |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
4
|
use Carp (); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
19
|
|
10
|
1
|
|
|
1
|
|
754
|
use Email::Date::Format (); |
|
1
|
|
|
|
|
3344
|
|
|
1
|
|
|
|
|
20
|
|
11
|
1
|
|
|
1
|
|
977
|
use Email::Simple; |
|
1
|
|
|
|
|
5534
|
|
|
1
|
|
|
|
|
29
|
|
12
|
1
|
|
|
1
|
|
9
|
use Email::Simple::Creator; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
13
|
1
|
|
|
1
|
|
983
|
use Sub::Exporter::Util (); |
|
1
|
|
|
|
|
16176
|
|
|
1
|
|
|
|
|
47
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
|
|
8
|
use Sub::Exporter -setup => { |
16
|
|
|
|
|
|
|
exports => [ prev => \'_build_prev' ], |
17
|
|
|
|
|
|
|
groups => [ helpers => [ qw(prev) ] ], |
18
|
1
|
|
|
1
|
|
10
|
}; |
|
1
|
|
|
|
|
3
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# For now, we'll only generate one style of Received header: postfix |
21
|
|
|
|
|
|
|
# It's what I encounter the most, and it's simple and straightforward. |
22
|
|
|
|
|
|
|
# In the future, we'll be flexible, maybe. -- rjbs, 2009-06-19 |
23
|
|
|
|
|
|
|
my %POSTFIX_FMT = ( |
24
|
|
|
|
|
|
|
for => q{from %s (%s [%s]) by %s (Postfix) with ESMTP id %s for <%s>; %s}, |
25
|
|
|
|
|
|
|
nofor => q{from %s (%s [%s]) by %s (Postfix) with ESMTP id %s%s; %s}, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub trace_headers { |
30
|
1
|
|
|
1
|
1
|
3
|
my ($self, $arg) = @_; |
31
|
|
|
|
|
|
|
|
32
|
1
|
50
|
|
|
|
5
|
Carp::confess("no hops provided") unless $arg->{hops}; |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
|
|
2
|
my @received; |
35
|
|
|
|
|
|
|
my %last; |
36
|
1
|
|
|
|
|
2
|
for my $hop (@{ $arg->{hops} }) { |
|
1
|
|
|
|
|
4
|
|
37
|
3
|
|
|
|
|
17
|
my %hop = (%$hop); |
38
|
|
|
|
|
|
|
|
39
|
3
|
|
|
|
|
10
|
for my $key (keys %hop) { |
40
|
20
|
100
|
|
|
|
50
|
if (ref $hop->{$key} eq 'CODE') { |
41
|
3
|
|
|
|
|
10
|
$hop{ $key } = $hop{$key}->(\%last); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
3
|
100
|
|
|
|
16
|
my $env_to = ref $hop{env_to} ? $hop{env_to} |
|
|
100
|
|
|
|
|
|
46
|
|
|
|
|
|
|
: $hop{env_to} ? [ $hop{env_to} ] |
47
|
|
|
|
|
|
|
: [ ]; |
48
|
|
|
|
|
|
|
|
49
|
3
|
100
|
|
|
|
10
|
my $fmt = @$env_to == 1 ? $POSTFIX_FMT{for} : $POSTFIX_FMT{nofor}; |
50
|
|
|
|
|
|
|
|
51
|
3
|
100
|
|
|
|
18
|
push @received, sprintf $fmt, |
52
|
|
|
|
|
|
|
$hop{from_helo}, |
53
|
|
|
|
|
|
|
$hop{from_rdns}, |
54
|
|
|
|
|
|
|
$hop{from_ip}, |
55
|
|
|
|
|
|
|
$hop{by_name}, # by_ip someday? |
56
|
|
|
|
|
|
|
$hop{queue_id}, |
57
|
|
|
|
|
|
|
@$env_to == 1 ? $env_to->[0] : '', |
58
|
|
|
|
|
|
|
(Email::Date::Format::email_gmdate($hop{time}) . ' (GMT)'); |
59
|
|
|
|
|
|
|
|
60
|
3
|
|
|
|
|
90
|
%last = %hop; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
1
|
|
|
|
|
7
|
return [ reverse @received ]; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub create_email { |
68
|
1
|
|
|
1
|
1
|
3
|
my ($self, $arg) = @_; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my $email = Email::Simple->create( |
71
|
|
|
|
|
|
|
header => [ |
72
|
1
|
|
|
|
|
2
|
(map {; Received => $_ } @{ $self->trace_headers($arg) }), |
|
3
|
|
|
|
|
16
|
|
|
1
|
|
|
|
|
5
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
From => '"X. Ample" ', |
75
|
|
|
|
|
|
|
To => '"E. Xampe" ', |
76
|
|
|
|
|
|
|
], |
77
|
|
|
|
|
|
|
body => "This is a test message.\n", |
78
|
|
|
|
|
|
|
); |
79
|
|
|
|
|
|
|
|
80
|
1
|
|
|
|
|
750
|
return $email; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub _build_prev { |
85
|
1
|
|
|
1
|
|
221
|
my ($self) = @_; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub { |
88
|
3
|
|
|
3
|
|
35
|
my ($name) = @_; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub { |
91
|
3
|
|
|
3
|
|
5
|
my ($last) = @_; |
92
|
3
|
|
|
|
|
11
|
$last->{ $name }; |
93
|
|
|
|
|
|
|
} |
94
|
3
|
|
|
|
|
46
|
} |
95
|
1
|
|
|
|
|
6
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__END__ |