line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sisimai::Lhost::Outlook; |
2
|
25
|
|
|
25
|
|
5832
|
use parent 'Sisimai::Lhost'; |
|
25
|
|
|
|
|
59
|
|
|
25
|
|
|
|
|
150
|
|
3
|
25
|
|
|
25
|
|
1506
|
use feature ':5.10'; |
|
25
|
|
|
|
|
49
|
|
|
25
|
|
|
|
|
1722
|
|
4
|
25
|
|
|
25
|
|
140
|
use strict; |
|
25
|
|
|
|
|
55
|
|
|
25
|
|
|
|
|
606
|
|
5
|
25
|
|
|
25
|
|
122
|
use warnings; |
|
25
|
|
|
|
|
36
|
|
|
25
|
|
|
|
|
23762
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
1
|
1143
|
sub description { 'Microsoft Outlook.com: https://www.outlook.com/' } |
8
|
|
|
|
|
|
|
sub make { |
9
|
|
|
|
|
|
|
# Detect an error from Microsoft Outlook.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.3 |
15
|
618
|
|
|
618
|
1
|
1371
|
my $class = shift; |
16
|
618
|
|
100
|
|
|
1381
|
my $mhead = shift // return undef; |
17
|
617
|
|
50
|
|
|
1411
|
my $mbody = shift // return undef; |
18
|
617
|
|
|
|
|
894
|
my $match = 0; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# X-Message-Delivery: Vj0xLjE7RD0wO0dEPTA7U0NMPTk7bD0xO3VzPTE= |
21
|
|
|
|
|
|
|
# X-Message-Info: AuEzbeVr9u5fkDpn2vR5iCu5wb6HBeY4iruBjnutBzpStnUabbM... |
22
|
617
|
100
|
|
|
|
1920
|
$match++ if index($mhead->{'subject'}, 'Delivery Status Notification') > -1; |
23
|
617
|
100
|
|
|
|
1538
|
$match++ if $mhead->{'x-message-delivery'}; |
24
|
617
|
100
|
|
|
|
1283
|
$match++ if $mhead->{'x-message-info'}; |
25
|
617
|
100
|
|
|
|
838
|
$match++ if grep { rindex($_, '.hotmail.com') > -1 } @{ $mhead->{'received'} }; |
|
1151
|
|
|
|
|
3452
|
|
|
617
|
|
|
|
|
1670
|
|
26
|
617
|
100
|
|
|
|
1851
|
return undef if $match < 2; |
27
|
|
|
|
|
|
|
|
28
|
41
|
|
|
|
|
119
|
state $indicators = __PACKAGE__->INDICATORS; |
29
|
41
|
|
|
|
|
130
|
state $rebackbone = qr|^Content-Type:[ ]message/rfc822|m; |
30
|
41
|
|
|
|
|
104
|
state $startingof = { 'message' => ['This is an automatically generated Delivery Status Notification'] }; |
31
|
41
|
|
|
|
|
93
|
state $messagesof = { |
32
|
|
|
|
|
|
|
'hostunknown' => ['The mail could not be delivered to the recipient because the domain is not reachable'], |
33
|
|
|
|
|
|
|
'userunknown' => ['Requested action not taken: mailbox unavailable'], |
34
|
|
|
|
|
|
|
}; |
35
|
|
|
|
|
|
|
|
36
|
41
|
|
|
|
|
517
|
require Sisimai::RFC1894; |
37
|
41
|
|
|
|
|
221
|
my $fieldtable = Sisimai::RFC1894->FIELDTABLE; |
38
|
41
|
|
|
|
|
155
|
my $permessage = {}; # (Hash) Store values of each Per-Message field |
39
|
|
|
|
|
|
|
|
40
|
41
|
|
|
|
|
178
|
my $dscontents = [__PACKAGE__->DELIVERYSTATUS]; |
41
|
41
|
|
|
|
|
248
|
my $emailsteak = Sisimai::RFC5322->fillet($mbody, $rebackbone); |
42
|
41
|
|
|
|
|
155
|
my $readcursor = 0; # (Integer) Points the current cursor position |
43
|
41
|
|
|
|
|
104
|
my $recipients = 0; # (Integer) The number of 'Final-Recipient' header |
44
|
41
|
|
|
|
|
93
|
my $v = undef; |
45
|
41
|
|
|
|
|
122
|
my $p = ''; |
46
|
|
|
|
|
|
|
|
47
|
41
|
|
|
|
|
504
|
for my $e ( split("\n", $emailsteak->[0]) ) { |
48
|
|
|
|
|
|
|
# Read error messages and delivery status lines from the head of the email |
49
|
|
|
|
|
|
|
# to the previous line of the beginning of the original message. |
50
|
783
|
100
|
|
|
|
1138
|
unless( $readcursor ) { |
51
|
|
|
|
|
|
|
# Beginning of the bounce message or message/delivery-status part |
52
|
164
|
100
|
|
|
|
566
|
$readcursor |= $indicators->{'deliverystatus'} if index($e, $startingof->{'message'}->[0]) == 0; |
53
|
164
|
|
|
|
|
216
|
next; |
54
|
|
|
|
|
|
|
} |
55
|
619
|
50
|
|
|
|
1044
|
next unless $readcursor & $indicators->{'deliverystatus'}; |
56
|
619
|
100
|
|
|
|
953
|
next unless length $e; |
57
|
|
|
|
|
|
|
|
58
|
440
|
100
|
|
|
|
879
|
if( my $f = Sisimai::RFC1894->match($e) ) { |
59
|
|
|
|
|
|
|
# $e matched with any field defined in RFC3464 |
60
|
297
|
50
|
|
|
|
595
|
next unless my $o = Sisimai::RFC1894->field($e); |
61
|
297
|
|
|
|
|
434
|
$v = $dscontents->[-1]; |
62
|
|
|
|
|
|
|
|
63
|
297
|
100
|
|
|
|
739
|
if( $o->[-1] eq 'addr' ) { |
|
|
100
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Final-Recipient: rfc822; kijitora@example.jp |
65
|
|
|
|
|
|
|
# X-Actual-Recipient: rfc822; kijitora@example.co.jp |
66
|
46
|
50
|
|
|
|
338
|
if( $o->[0] eq 'final-recipient' ) { |
67
|
|
|
|
|
|
|
# Final-Recipient: rfc822; kijitora@example.jp |
68
|
46
|
100
|
|
|
|
191
|
if( $v->{'recipient'} ) { |
69
|
|
|
|
|
|
|
# There are multiple recipient addresses in the message body. |
70
|
5
|
|
|
|
|
26
|
push @$dscontents, __PACKAGE__->DELIVERYSTATUS; |
71
|
5
|
|
|
|
|
17
|
$v = $dscontents->[-1]; |
72
|
|
|
|
|
|
|
} |
73
|
46
|
|
|
|
|
100
|
$v->{'recipient'} = $o->[2]; |
74
|
46
|
|
|
|
|
102
|
$recipients++; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
} else { |
77
|
|
|
|
|
|
|
# X-Actual-Recipient: rfc822; kijitora@example.co.jp |
78
|
0
|
|
|
|
|
0
|
$v->{'alias'} = $o->[2]; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} elsif( $o->[-1] eq 'code' ) { |
81
|
|
|
|
|
|
|
# Diagnostic-Code: SMTP; 550 5.1.1 ... User Unknown |
82
|
36
|
|
|
|
|
188
|
$v->{'spec'} = $o->[1]; |
83
|
36
|
|
|
|
|
107
|
$v->{'diagnosis'} = $o->[2]; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
} else { |
86
|
|
|
|
|
|
|
# Other DSN fields defined in RFC3464 |
87
|
215
|
50
|
|
|
|
440
|
next unless exists $fieldtable->{ $o->[0] }; |
88
|
215
|
|
|
|
|
506
|
$v->{ $fieldtable->{ $o->[0] } } = $o->[2]; |
89
|
|
|
|
|
|
|
|
90
|
215
|
100
|
|
|
|
475
|
next unless $f == 1; |
91
|
123
|
|
|
|
|
386
|
$permessage->{ $fieldtable->{ $o->[0] } } = $o->[2]; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} else { |
94
|
|
|
|
|
|
|
# Continued line of the value of Diagnostic-Code field |
95
|
143
|
50
|
|
|
|
393
|
next unless index($p, 'Diagnostic-Code:') == 0; |
96
|
0
|
0
|
|
|
|
0
|
next unless $e =~ /\A[ \t]+(.+)\z/; |
97
|
0
|
|
|
|
|
0
|
$v->{'diagnosis'} .= ' '.$1; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} continue { |
100
|
|
|
|
|
|
|
# Save the current line for the next loop |
101
|
783
|
|
|
|
|
1101
|
$p = $e; |
102
|
|
|
|
|
|
|
} |
103
|
41
|
50
|
|
|
|
209
|
return undef unless $recipients; |
104
|
|
|
|
|
|
|
|
105
|
41
|
|
|
|
|
158
|
for my $e ( @$dscontents ) { |
106
|
|
|
|
|
|
|
# Set default values if each value is empty. |
107
|
46
|
|
66
|
|
|
194
|
$e->{'lhost'} ||= $permessage->{'rhost'}; |
108
|
46
|
|
50
|
|
|
400
|
$e->{ $_ } ||= $permessage->{ $_ } || '' for keys %$permessage; |
|
|
|
66
|
|
|
|
|
109
|
46
|
|
|
|
|
347
|
$e->{'diagnosis'} = Sisimai::String->sweep($e->{'diagnosis'}); |
110
|
|
|
|
|
|
|
|
111
|
46
|
100
|
|
|
|
303
|
unless( $e->{'diagnosis'} ) { |
112
|
|
|
|
|
|
|
# No message in 'diagnosis' |
113
|
10
|
100
|
|
|
|
55
|
if( $e->{'action'} eq 'delayed' ) { |
114
|
|
|
|
|
|
|
# Set pseudo diagnostic code message for delaying |
115
|
5
|
|
|
|
|
17
|
$e->{'diagnosis'} = 'Delivery to the following recipients has been delayed.'; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
} else { |
118
|
|
|
|
|
|
|
# Set pseudo diagnostic code message |
119
|
5
|
|
|
|
|
13
|
$e->{'diagnosis'} = 'Unable to deliver message to the following recipients, '; |
120
|
5
|
|
|
|
|
20
|
$e->{'diagnosis'} .= 'due to being unable to connect successfully to the destination mail server.'; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
46
|
|
|
|
|
170
|
SESSION: for my $r ( keys %$messagesof ) { |
125
|
|
|
|
|
|
|
# Verify each regular expression of session errors |
126
|
87
|
100
|
|
|
|
131
|
next unless grep { index($e->{'diagnosis'}, $_) > -1 } @{ $messagesof->{ $r } }; |
|
87
|
|
|
|
|
436
|
|
|
87
|
|
|
|
|
172
|
|
127
|
10
|
|
|
|
|
41
|
$e->{'reason'} = $r; |
128
|
10
|
|
|
|
|
34
|
last; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
} |
131
|
41
|
|
|
|
|
367
|
return { 'ds' => $dscontents, 'rfc822' => $emailsteak->[1] }; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
1; |
135
|
|
|
|
|
|
|
__END__ |