line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sisimai::Lhost::X3; |
2
|
14
|
|
|
14
|
|
7189
|
use parent 'Sisimai::Lhost'; |
|
14
|
|
|
|
|
29
|
|
|
14
|
|
|
|
|
75
|
|
3
|
14
|
|
|
14
|
|
866
|
use feature ':5.10'; |
|
14
|
|
|
|
|
39
|
|
|
14
|
|
|
|
|
910
|
|
4
|
14
|
|
|
14
|
|
74
|
use strict; |
|
14
|
|
|
|
|
27
|
|
|
14
|
|
|
|
|
278
|
|
5
|
14
|
|
|
14
|
|
86
|
use warnings; |
|
14
|
|
|
|
|
29
|
|
|
14
|
|
|
|
|
9097
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
1
|
1173
|
sub description { 'Unknown MTA #3' } |
8
|
|
|
|
|
|
|
sub make { |
9
|
|
|
|
|
|
|
# Detect an error from Unknown MTA #3 |
10
|
|
|
|
|
|
|
# @param [Hash] mhead Message headers of a bounce email |
11
|
|
|
|
|
|
|
# @param [String] mbody Message body of a bounce email |
12
|
|
|
|
|
|
|
# @return [Hash] Bounce data list and message/rfc822 part |
13
|
|
|
|
|
|
|
# @return [Undef] failed to parse or the arguments are missing |
14
|
|
|
|
|
|
|
# @since v4.1.9 |
15
|
208
|
|
|
208
|
1
|
702
|
my $class = shift; |
16
|
208
|
|
100
|
|
|
600
|
my $mhead = shift // return undef; |
17
|
207
|
|
50
|
|
|
612
|
my $mbody = shift // return undef; |
18
|
|
|
|
|
|
|
|
19
|
207
|
100
|
|
|
|
795
|
return undef unless index($mhead->{'from'}, 'Mail Delivery System') == 0; |
20
|
26
|
50
|
|
|
|
115
|
return undef unless index($mhead->{'subject'}, 'Delivery status notification') == 0; |
21
|
|
|
|
|
|
|
|
22
|
26
|
|
|
|
|
84
|
state $indicators = __PACKAGE__->INDICATORS; |
23
|
26
|
|
|
|
|
53
|
state $rebackbone = qr|^Content-Type:[ ]message/rfc822|m; |
24
|
26
|
|
|
|
|
55
|
state $startingof = { 'message' => [' This is an automatically generated Delivery Status Notification.'] }; |
25
|
|
|
|
|
|
|
|
26
|
26
|
|
|
|
|
107
|
my $dscontents = [__PACKAGE__->DELIVERYSTATUS]; |
27
|
26
|
|
|
|
|
172
|
my $emailsteak = Sisimai::RFC5322->fillet($mbody, $rebackbone); |
28
|
26
|
|
|
|
|
63
|
my $readcursor = 0; # (Integer) Points the current cursor position |
29
|
26
|
|
|
|
|
64
|
my $recipients = 0; # (Integer) The number of 'Final-Recipient' header |
30
|
26
|
|
|
|
|
49
|
my $v = undef; |
31
|
|
|
|
|
|
|
|
32
|
26
|
|
|
|
|
216
|
for my $e ( split("\n", $emailsteak->[0]) ) { |
33
|
|
|
|
|
|
|
# Read error messages and delivery status lines from the head of the email |
34
|
|
|
|
|
|
|
# to the previous line of the beginning of the original message. |
35
|
415
|
100
|
|
|
|
568
|
unless( $readcursor ) { |
36
|
|
|
|
|
|
|
# Beginning of the bounce message or message/delivery-status part |
37
|
94
|
100
|
|
|
|
290
|
$readcursor |= $indicators->{'deliverystatus'} if index($e, $startingof->{'message'}->[0]) == 0; |
38
|
94
|
|
|
|
|
138
|
next; |
39
|
|
|
|
|
|
|
} |
40
|
321
|
50
|
|
|
|
487
|
next unless $readcursor & $indicators->{'deliverystatus'}; |
41
|
321
|
100
|
|
|
|
462
|
next unless length $e; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# ============================================================================ |
44
|
|
|
|
|
|
|
# This is an automatically generated Delivery Status Notification. |
45
|
|
|
|
|
|
|
# |
46
|
|
|
|
|
|
|
# Delivery to the following recipients failed permanently: |
47
|
|
|
|
|
|
|
# |
48
|
|
|
|
|
|
|
# * kijitora@example.com |
49
|
|
|
|
|
|
|
# |
50
|
|
|
|
|
|
|
# |
51
|
|
|
|
|
|
|
# ============================================================================ |
52
|
|
|
|
|
|
|
# Technical details: |
53
|
|
|
|
|
|
|
# |
54
|
|
|
|
|
|
|
# SMTP:RCPT host 192.0.2.8: 553 5.3.0 ... No such user here |
55
|
|
|
|
|
|
|
# |
56
|
|
|
|
|
|
|
# |
57
|
|
|
|
|
|
|
# ============================================================================ |
58
|
196
|
|
|
|
|
218
|
$v = $dscontents->[-1]; |
59
|
|
|
|
|
|
|
|
60
|
196
|
100
|
|
|
|
414
|
if( $e =~ /\A[ \t]+[*][ \t]([^ ]+[@][^ ]+)\z/ ) { |
61
|
|
|
|
|
|
|
# * kijitora@example.com |
62
|
26
|
50
|
|
|
|
83
|
if( $v->{'recipient'} ) { |
63
|
|
|
|
|
|
|
# There are multiple recipient addresses in the message body. |
64
|
0
|
|
|
|
|
0
|
push @$dscontents, __PACKAGE__->DELIVERYSTATUS; |
65
|
0
|
|
|
|
|
0
|
$v = $dscontents->[-1]; |
66
|
|
|
|
|
|
|
} |
67
|
26
|
|
|
|
|
84
|
$v->{'recipient'} = $1; |
68
|
26
|
|
|
|
|
49
|
$recipients++; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
} else { |
71
|
|
|
|
|
|
|
# Detect error message |
72
|
170
|
100
|
|
|
|
537
|
if( $e =~ /\ASMTP:([^ ]+)[ \t](.+)\z/ ) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# SMTP:RCPT host 192.0.2.8: 553 5.3.0 ... No such user here |
74
|
11
|
|
|
|
|
53
|
$v->{'command'} = uc $1; |
75
|
11
|
|
|
|
|
33
|
$v->{'diagnosis'} = $2; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
} elsif( $e =~ /\ARouting: (.+)/ ) { |
78
|
|
|
|
|
|
|
# Routing: Could not find a gateway for kijitora@example.co.jp |
79
|
5
|
|
|
|
|
21
|
$v->{'diagnosis'} = $1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
} elsif( $e =~ /\ADiagnostic-Code: smtp; (.+)/ ) { |
82
|
|
|
|
|
|
|
# Diagnostic-Code: smtp; 552 5.2.2 Over quota |
83
|
5
|
|
|
|
|
18
|
$v->{'diagnosis'} = $1; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
26
|
50
|
|
|
|
109
|
return undef unless $recipients; |
88
|
|
|
|
|
|
|
|
89
|
26
|
|
|
|
|
73
|
for my $e ( @$dscontents ) { |
90
|
26
|
|
|
|
|
172
|
$e->{'diagnosis'} = Sisimai::String->sweep($e->{'diagnosis'}); |
91
|
26
|
|
100
|
|
|
197
|
$e->{'status'} = Sisimai::SMTP::Status->find($e->{'diagnosis'}) || ''; |
92
|
|
|
|
|
|
|
} |
93
|
26
|
|
|
|
|
148
|
return { 'ds' => $dscontents, 'rfc822' => $emailsteak->[1] }; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
97
|
|
|
|
|
|
|
__END__ |