line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sisimai::Lhost::GMX; |
2
|
21
|
|
|
21
|
|
6095
|
use parent 'Sisimai::Lhost'; |
|
21
|
|
|
|
|
41
|
|
|
21
|
|
|
|
|
138
|
|
3
|
21
|
|
|
21
|
|
1312
|
use feature ':5.10'; |
|
21
|
|
|
|
|
40
|
|
|
21
|
|
|
|
|
1487
|
|
4
|
21
|
|
|
21
|
|
122
|
use strict; |
|
21
|
|
|
|
|
43
|
|
|
21
|
|
|
|
|
422
|
|
5
|
21
|
|
|
21
|
|
93
|
use warnings; |
|
21
|
|
|
|
|
46
|
|
|
21
|
|
|
|
|
18095
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
1
|
1190
|
sub description { 'GMX: https://www.gmx.net' } |
8
|
|
|
|
|
|
|
sub make { |
9
|
|
|
|
|
|
|
# Detect an error from GMX and mail.com |
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.4 |
15
|
267
|
|
|
267
|
1
|
828
|
my $class = shift; |
16
|
267
|
|
100
|
|
|
652
|
my $mhead = shift // return undef; |
17
|
266
|
|
50
|
|
|
643
|
my $mbody = shift // return undef; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Envelope-To: |
20
|
|
|
|
|
|
|
# X-GMX-Antispam: 0 (Mail was not recognized as spam); Detail=V3; |
21
|
|
|
|
|
|
|
# X-GMX-Antivirus: 0 (no virus found) |
22
|
|
|
|
|
|
|
# X-UI-Out-Filterresults: unknown:0; |
23
|
266
|
100
|
|
|
|
832
|
return undef unless defined $mhead->{'x-gmx-antispam'}; |
24
|
|
|
|
|
|
|
|
25
|
21
|
|
|
|
|
79
|
state $indicators = __PACKAGE__->INDICATORS; |
26
|
21
|
|
|
|
|
57
|
state $rebackbone = qr|^---[ ]The[ ]header[ ]of[ ]the[ ]original[ ]message[ ]is[ ]following[.][ ]---|m; |
27
|
21
|
|
|
|
|
50
|
state $startingof = { 'message' => ['This message was created automatically by mail delivery software'] }; |
28
|
21
|
|
|
|
|
40
|
state $messagesof = { 'expired' => ['delivery retry timeout exceeded'] }; |
29
|
|
|
|
|
|
|
|
30
|
21
|
|
|
|
|
71
|
my $dscontents = [__PACKAGE__->DELIVERYSTATUS]; |
31
|
21
|
|
|
|
|
114
|
my $emailsteak = Sisimai::RFC5322->fillet($mbody, $rebackbone); |
32
|
21
|
|
|
|
|
86
|
my $readcursor = 0; # (Integer) Points the current cursor position |
33
|
21
|
|
|
|
|
64
|
my $recipients = 0; # (Integer) The number of 'Final-Recipient' header |
34
|
21
|
|
|
|
|
80
|
my $v = undef; |
35
|
|
|
|
|
|
|
|
36
|
21
|
|
|
|
|
228
|
for my $e ( split("\n", $emailsteak->[0]) ) { |
37
|
|
|
|
|
|
|
# Read error messages and delivery status lines from the head of the email |
38
|
|
|
|
|
|
|
# to the previous line of the beginning of the original message. |
39
|
230
|
100
|
|
|
|
368
|
unless( $readcursor ) { |
40
|
|
|
|
|
|
|
# Beginning of the bounce message or message/delivery-status part |
41
|
21
|
50
|
|
|
|
151
|
$readcursor |= $indicators->{'deliverystatus'} if index($e, $startingof->{'message'}->[0]) == 0; |
42
|
21
|
|
|
|
|
59
|
next; |
43
|
|
|
|
|
|
|
} |
44
|
209
|
50
|
|
|
|
335
|
next unless $readcursor & $indicators->{'deliverystatus'}; |
45
|
209
|
100
|
|
|
|
334
|
next unless length $e; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# This message was created automatically by mail delivery software. |
48
|
|
|
|
|
|
|
# |
49
|
|
|
|
|
|
|
# A message that you sent could not be delivered to one or more of |
50
|
|
|
|
|
|
|
# its recipients. This is a permanent error. The following address |
51
|
|
|
|
|
|
|
# failed: |
52
|
|
|
|
|
|
|
# |
53
|
|
|
|
|
|
|
# "shironeko@example.jp": |
54
|
|
|
|
|
|
|
# SMTP error from remote server after RCPT command: |
55
|
|
|
|
|
|
|
# host: mx.example.jp |
56
|
|
|
|
|
|
|
# 5.1.1 ... User Unknown |
57
|
162
|
|
|
|
|
200
|
$v = $dscontents->[-1]; |
58
|
|
|
|
|
|
|
|
59
|
162
|
100
|
100
|
|
|
1001
|
if( $e =~ /\A["]([^ ]+[@][^ ]+)["]:\z/ || $e =~ /\A[<]([^ ]+[@][^ ]+)[>]\z/ ) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# "shironeko@example.jp": |
61
|
|
|
|
|
|
|
# ---- OR ---- |
62
|
|
|
|
|
|
|
# |
63
|
|
|
|
|
|
|
# |
64
|
|
|
|
|
|
|
# Reason: |
65
|
|
|
|
|
|
|
# delivery retry timeout exceeded |
66
|
26
|
100
|
|
|
|
93
|
if( $v->{'recipient'} ) { |
67
|
|
|
|
|
|
|
# There are multiple recipient addresses in the message body. |
68
|
5
|
|
|
|
|
28
|
push @$dscontents, __PACKAGE__->DELIVERYSTATUS; |
69
|
5
|
|
|
|
|
21
|
$v = $dscontents->[-1]; |
70
|
|
|
|
|
|
|
} |
71
|
26
|
|
|
|
|
100
|
$v->{'recipient'} = $1; |
72
|
26
|
|
|
|
|
40
|
$recipients++; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
} elsif( $e =~ /\ASMTP error .+ ([A-Z]{4}) command:\z/ ) { |
75
|
|
|
|
|
|
|
# SMTP error from remote server after RCPT command: |
76
|
21
|
|
|
|
|
89
|
$v->{'command'} = $1; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
} elsif( $e =~ /\Ahost:[ \t]*(.+)\z/ ) { |
79
|
|
|
|
|
|
|
# host: mx.example.jp |
80
|
21
|
|
|
|
|
60
|
$v->{'rhost'} = $1; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
} else { |
83
|
|
|
|
|
|
|
# Get error message |
84
|
94
|
100
|
66
|
|
|
568
|
if( $e =~ /\b[45][.]\d[.]\d\b/ || $e =~ /[<][^ ]+[@][^ ]+[>]/ || $e =~ /\b[45]\d{2}\b/ ) { |
|
|
|
66
|
|
|
|
|
85
|
21
|
|
33
|
|
|
122
|
$v->{'diagnosis'} ||= $e; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
} else { |
88
|
73
|
50
|
|
|
|
160
|
next if $e eq ''; |
89
|
73
|
100
|
|
|
|
220
|
if( $e eq 'Reason:' ) { |
|
|
100
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# Reason: |
91
|
|
|
|
|
|
|
# delivery retry timeout exceeded |
92
|
5
|
|
|
|
|
43
|
$v->{'diagnosis'} = $e; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
} elsif( $v->{'diagnosis'} eq 'Reason:' ) { |
95
|
5
|
|
|
|
|
15
|
$v->{'diagnosis'} = $e; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
21
|
50
|
|
|
|
87
|
return undef unless $recipients; |
101
|
|
|
|
|
|
|
|
102
|
21
|
|
|
|
|
73
|
for my $e ( @$dscontents ) { |
103
|
26
|
|
|
|
|
65
|
$e->{'diagnosis'} =~ y/\n/ /; |
104
|
26
|
|
|
|
|
153
|
$e->{'diagnosis'} = Sisimai::String->sweep($e->{'diagnosis'}); |
105
|
|
|
|
|
|
|
|
106
|
26
|
|
|
|
|
174
|
SESSION: for my $r ( keys %$messagesof ) { |
107
|
|
|
|
|
|
|
# Verify each regular expression of session errors |
108
|
26
|
100
|
|
|
|
48
|
next unless grep { index($e->{'diagnosis'}, $_) > -1 } @{ $messagesof->{ $r } }; |
|
26
|
|
|
|
|
186
|
|
|
26
|
|
|
|
|
74
|
|
109
|
5
|
|
|
|
|
16
|
$e->{'reason'} = $r; |
110
|
5
|
|
|
|
|
12
|
last; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
} |
113
|
21
|
|
|
|
|
123
|
return { 'ds' => $dscontents, 'rfc822' => $emailsteak->[1] }; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; |
117
|
|
|
|
|
|
|
__END__ |