sisimai 4.22.7 → 4.23.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sisimai might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/ChangeLog.md +15 -0
- data/README-JA.md +13 -8
- data/README.md +14 -9
- data/lib/sisimai.rb +11 -12
- data/lib/sisimai/address.rb +13 -23
- data/lib/sisimai/arf.rb +10 -12
- data/lib/sisimai/bite/email/activehunter.rb +5 -9
- data/lib/sisimai/bite/email/amazonses.rb +12 -18
- data/lib/sisimai/bite/email/amazonworkmail.rb +7 -12
- data/lib/sisimai/bite/email/aol.rb +10 -16
- data/lib/sisimai/bite/email/apachejames.rb +8 -12
- data/lib/sisimai/bite/email/bigfoot.rb +10 -15
- data/lib/sisimai/bite/email/biglobe.rb +7 -11
- data/lib/sisimai/bite/email/courier.rb +11 -15
- data/lib/sisimai/bite/email/domino.rb +8 -13
- data/lib/sisimai/bite/email/einsundeins.rb +7 -11
- data/lib/sisimai/bite/email/exchange2003.rb +11 -15
- data/lib/sisimai/bite/email/exchange2007.rb +7 -11
- data/lib/sisimai/bite/email/exim.rb +20 -27
- data/lib/sisimai/bite/email/ezweb.rb +13 -22
- data/lib/sisimai/bite/email/facebook.rb +7 -10
- data/lib/sisimai/bite/email/fml.rb +4 -7
- data/lib/sisimai/bite/email/gmx.rb +7 -12
- data/lib/sisimai/bite/email/google.rb +6 -12
- data/lib/sisimai/bite/email/gsuite.rb +11 -18
- data/lib/sisimai/bite/email/imailserver.rb +6 -10
- data/lib/sisimai/bite/email/interscanmss.rb +7 -11
- data/lib/sisimai/bite/email/kddi.rb +10 -16
- data/lib/sisimai/bite/email/mailfoundry.rb +6 -9
- data/lib/sisimai/bite/email/mailmarshalsmtp.rb +6 -10
- data/lib/sisimai/bite/email/mailru.rb +12 -16
- data/lib/sisimai/bite/email/mcafee.rb +5 -9
- data/lib/sisimai/bite/email/messagelabs.rb +7 -10
- data/lib/sisimai/bite/email/messagingserver.rb +8 -14
- data/lib/sisimai/bite/email/mfilter.rb +6 -10
- data/lib/sisimai/bite/email/mxlogic.rb +11 -17
- data/lib/sisimai/bite/email/notes.rb +9 -13
- data/lib/sisimai/bite/email/office365.rb +8 -13
- data/lib/sisimai/bite/email/opensmtpd.rb +7 -11
- data/lib/sisimai/bite/email/outlook.rb +9 -13
- data/lib/sisimai/bite/email/postfix.rb +12 -18
- data/lib/sisimai/bite/email/qmail.rb +10 -15
- data/lib/sisimai/bite/email/receivingses.rb +10 -17
- data/lib/sisimai/bite/email/sendgrid.rb +8 -14
- data/lib/sisimai/bite/email/sendmail.rb +8 -12
- data/lib/sisimai/bite/email/surfcontrol.rb +5 -9
- data/lib/sisimai/bite/email/userdefined.rb +5 -8
- data/lib/sisimai/bite/email/v5sendmail.rb +7 -11
- data/lib/sisimai/bite/email/verizon.rb +14 -28
- data/lib/sisimai/bite/email/x1.rb +5 -8
- data/lib/sisimai/bite/email/x2.rb +5 -8
- data/lib/sisimai/bite/email/x3.rb +5 -9
- data/lib/sisimai/bite/email/x4.rb +10 -14
- data/lib/sisimai/bite/email/x5.rb +6 -11
- data/lib/sisimai/bite/email/yahoo.rb +6 -11
- data/lib/sisimai/bite/email/yandex.rb +8 -12
- data/lib/sisimai/bite/email/zoho.rb +7 -12
- data/lib/sisimai/bite/json/amazonses.rb +6 -12
- data/lib/sisimai/bite/json/sendgrid.rb +1 -7
- data/lib/sisimai/data.rb +26 -34
- data/lib/sisimai/datetime.rb +5 -5
- data/lib/sisimai/mail.rb +9 -3
- data/lib/sisimai/mail/maildir.rb +1 -3
- data/lib/sisimai/mail/mbox.rb +1 -1
- data/lib/sisimai/mail/memory.rb +47 -0
- data/lib/sisimai/mail/stdin.rb +1 -1
- data/lib/sisimai/mda.rb +7 -10
- data/lib/sisimai/message.rb +4 -6
- data/lib/sisimai/message/email.rb +16 -24
- data/lib/sisimai/message/json.rb +3 -5
- data/lib/sisimai/mime.rb +13 -18
- data/lib/sisimai/order/email.rb +5 -8
- data/lib/sisimai/order/json.rb +2 -2
- data/lib/sisimai/reason.rb +3 -7
- data/lib/sisimai/reason/blocked.rb +0 -4
- data/lib/sisimai/reason/contenterror.rb +1 -1
- data/lib/sisimai/reason/exceedlimit.rb +2 -5
- data/lib/sisimai/reason/expired.rb +1 -1
- data/lib/sisimai/reason/filtered.rb +1 -4
- data/lib/sisimai/reason/hasmoved.rb +1 -4
- data/lib/sisimai/reason/hostunknown.rb +1 -4
- data/lib/sisimai/reason/mailboxfull.rb +2 -5
- data/lib/sisimai/reason/mesgtoobig.rb +1 -4
- data/lib/sisimai/reason/networkerror.rb +1 -1
- data/lib/sisimai/reason/norelaying.rb +1 -4
- data/lib/sisimai/reason/notaccept.rb +1 -3
- data/lib/sisimai/reason/onhold.rb +1 -5
- data/lib/sisimai/reason/policyviolation.rb +1 -1
- data/lib/sisimai/reason/rejected.rb +2 -6
- data/lib/sisimai/reason/spamdetected.rb +1 -5
- data/lib/sisimai/reason/suspend.rb +2 -5
- data/lib/sisimai/reason/syntaxerror.rb +0 -3
- data/lib/sisimai/reason/systemerror.rb +1 -1
- data/lib/sisimai/reason/systemfull.rb +1 -1
- data/lib/sisimai/reason/toomanyconn.rb +1 -5
- data/lib/sisimai/reason/userunknown.rb +1 -4
- data/lib/sisimai/reason/vacation.rb +1 -1
- data/lib/sisimai/reason/virusdetected.rb +1 -1
- data/lib/sisimai/rfc2606.rb +3 -3
- data/lib/sisimai/rfc3464.rb +12 -20
- data/lib/sisimai/rfc3834.rb +1 -10
- data/lib/sisimai/rfc5322.rb +4 -6
- data/lib/sisimai/rhost.rb +0 -4
- data/lib/sisimai/rhost/exchangeonline.rb +5 -7
- data/lib/sisimai/rhost/franceptt.rb +1 -3
- data/lib/sisimai/rhost/godaddy.rb +2 -4
- data/lib/sisimai/rhost/googleapps.rb +2 -4
- data/lib/sisimai/rhost/kddi.rb +0 -3
- data/lib/sisimai/smtp/error.rb +0 -3
- data/lib/sisimai/smtp/reply.rb +5 -8
- data/lib/sisimai/smtp/status.rb +3 -4
- data/lib/sisimai/string.rb +13 -20
- data/lib/sisimai/version.rb +1 -1
- data/set-of-emails/maildir/bsd/email-office365-09.eml +596 -0
- data/set-of-emails/maildir/bsd/email-office365-10.eml +594 -0
- data/set-of-emails/maildir/bsd/email-postfix-45.eml +76 -0
- metadata +6 -2
@@ -5,8 +5,7 @@ module Sisimai::Bite::Email
|
|
5
5
|
module MessagingServer
|
6
6
|
class << self
|
7
7
|
# Imported from p5-Sisimail/lib/Sisimai/Bite/Email/MessagingServer.pm
|
8
|
-
require 'sisimai/bite'
|
9
|
-
require 'sisimai/rfc5322'
|
8
|
+
require 'sisimai/bite/email'
|
10
9
|
|
11
10
|
Indicators = Sisimai::Bite::Email.INDICATORS
|
12
11
|
StartingOf = { message: ['This report relates to a message you sent with the following header fields:'] }.freeze
|
@@ -29,16 +28,12 @@ module Sisimai::Bite::Email
|
|
29
28
|
# part or nil if it failed to parse or
|
30
29
|
# the arguments are missing
|
31
30
|
def scan(mhead, mbody)
|
32
|
-
return nil unless mhead
|
33
|
-
return nil unless mbody
|
34
|
-
|
35
31
|
# :received => %r/[ ][(]MessagingServer[)][ ]with[ ]/,
|
36
32
|
match = 0
|
37
33
|
match += 1 if mhead['content-type'].include?('Boundary_(ID_')
|
38
34
|
match += 1 if mhead['subject'].start_with?('Delivery Notification: ')
|
39
|
-
return nil
|
35
|
+
return nil unless match > 0
|
40
36
|
|
41
|
-
require 'sisimai/address'
|
42
37
|
dscontents = [Sisimai::Bite.DELIVERYSTATUS]
|
43
38
|
hasdivided = mbody.split("\n")
|
44
39
|
rfc822list = [] # (Array) Each line in message/rfc822 part string
|
@@ -48,7 +43,7 @@ module Sisimai::Bite::Email
|
|
48
43
|
v = nil
|
49
44
|
|
50
45
|
while e = hasdivided.shift do
|
51
|
-
if readcursor
|
46
|
+
if readcursor == 0
|
52
47
|
# Beginning of the bounce message or delivery status part
|
53
48
|
if e.start_with?(StartingOf[:message][0])
|
54
49
|
readcursor |= Indicators[:deliverystatus]
|
@@ -56,7 +51,7 @@ module Sisimai::Bite::Email
|
|
56
51
|
end
|
57
52
|
end
|
58
53
|
|
59
|
-
if (readcursor & Indicators[:'message-rfc822'])
|
54
|
+
if (readcursor & Indicators[:'message-rfc822']) == 0
|
60
55
|
# Beginning of the original message part
|
61
56
|
if e =~ MarkingsOf[:rfc822]
|
62
57
|
readcursor |= Indicators[:'message-rfc822']
|
@@ -74,7 +69,7 @@ module Sisimai::Bite::Email
|
|
74
69
|
rfc822list << e
|
75
70
|
else
|
76
71
|
# Before "message/rfc822"
|
77
|
-
next if (readcursor & Indicators[:deliverystatus])
|
72
|
+
next if (readcursor & Indicators[:deliverystatus]) == 0
|
78
73
|
next if e.empty?
|
79
74
|
|
80
75
|
# --Boundary_(ID_0000000000000000000000)
|
@@ -168,16 +163,15 @@ module Sisimai::Bite::Email
|
|
168
163
|
end
|
169
164
|
end
|
170
165
|
end
|
171
|
-
return nil
|
166
|
+
return nil unless recipients > 0
|
172
167
|
|
173
|
-
|
174
|
-
dscontents.map do |e|
|
168
|
+
dscontents.each do |e|
|
175
169
|
e['agent'] = self.smtpagent
|
176
170
|
e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
|
177
171
|
|
178
172
|
MessagesOf.each_key do |r|
|
179
173
|
# Verify each regular expression of session errors
|
180
|
-
next unless MessagesOf[r].
|
174
|
+
next unless MessagesOf[r].any? { |a| e['diagnosis'].include?(a) }
|
181
175
|
e['reason'] = r.to_s
|
182
176
|
break
|
183
177
|
end
|
@@ -31,9 +31,6 @@ module Sisimai::Bite::Email
|
|
31
31
|
# part or nil if it failed to parse or
|
32
32
|
# the arguments are missing
|
33
33
|
def scan(mhead, mbody)
|
34
|
-
return nil unless mhead
|
35
|
-
return nil unless mbody
|
36
|
-
|
37
34
|
# :'from' => %r/\AMailer Daemon [<]MAILER-DAEMON[@]/,
|
38
35
|
return nil unless mhead['x-mailer'].to_s == 'm-FILTER'
|
39
36
|
return nil unless mhead['subject'] == 'failure notice'
|
@@ -48,12 +45,12 @@ module Sisimai::Bite::Email
|
|
48
45
|
v = nil
|
49
46
|
|
50
47
|
while e = hasdivided.shift do
|
51
|
-
if readcursor
|
48
|
+
if readcursor == 0
|
52
49
|
# Beginning of the bounce message or delivery status part
|
53
50
|
readcursor |= Indicators[:deliverystatus] if e =~ MarkingsOf[:message]
|
54
51
|
end
|
55
52
|
|
56
|
-
if (readcursor & Indicators[:'message-rfc822'])
|
53
|
+
if (readcursor & Indicators[:'message-rfc822']) == 0
|
57
54
|
# Beginning of the original message part
|
58
55
|
if e.start_with?(StartingOf[:rfc822][0], StartingOf[:rfc822][1])
|
59
56
|
readcursor |= Indicators[:'message-rfc822']
|
@@ -71,7 +68,7 @@ module Sisimai::Bite::Email
|
|
71
68
|
rfc822list << e
|
72
69
|
else
|
73
70
|
# Before "message/rfc822"
|
74
|
-
next if (readcursor & Indicators[:deliverystatus])
|
71
|
+
next if (readcursor & Indicators[:deliverystatus]) == 0
|
75
72
|
next if e.empty?
|
76
73
|
|
77
74
|
# このメールは「m-FILTER」が自動的に生成して送信しています。
|
@@ -125,11 +122,10 @@ module Sisimai::Bite::Email
|
|
125
122
|
end
|
126
123
|
end
|
127
124
|
end
|
128
|
-
return nil
|
125
|
+
return nil unless recipients > 0
|
129
126
|
|
130
|
-
|
131
|
-
|
132
|
-
if mhead['received'].size > 0
|
127
|
+
dscontents.each do |e|
|
128
|
+
unless mhead['received'].empty?
|
133
129
|
# Get localhost and remote host name from Received header.
|
134
130
|
rheads = mhead['received']
|
135
131
|
rhosts = Sisimai::RFC5322.received(rheads[-1])
|
@@ -91,9 +91,6 @@ module Sisimai::Bite::Email
|
|
91
91
|
# part or nil if it failed to parse or
|
92
92
|
# the arguments are missing
|
93
93
|
def scan(mhead, mbody)
|
94
|
-
return nil unless mhead
|
95
|
-
return nil unless mbody
|
96
|
-
|
97
94
|
# :'message-id' => %r/\A[<]mxl[~][0-9a-f]+/,
|
98
95
|
match = 0
|
99
96
|
match += 1 if mhead['x-mx-bounce']
|
@@ -106,7 +103,7 @@ module Sisimai::Bite::Email
|
|
106
103
|
|Delivery[ ]Status[ ]Notification
|
107
104
|
)
|
108
105
|
}x
|
109
|
-
return nil
|
106
|
+
return nil unless match > 0
|
110
107
|
|
111
108
|
dscontents = [Sisimai::Bite.DELIVERYSTATUS]
|
112
109
|
hasdivided = mbody.split("\n")
|
@@ -118,7 +115,7 @@ module Sisimai::Bite::Email
|
|
118
115
|
v = nil
|
119
116
|
|
120
117
|
while e = hasdivided.shift do
|
121
|
-
if readcursor
|
118
|
+
if readcursor == 0
|
122
119
|
# Beginning of the bounce message or delivery status part
|
123
120
|
if e == StartingOf[:message][0]
|
124
121
|
readcursor |= Indicators[:deliverystatus]
|
@@ -126,7 +123,7 @@ module Sisimai::Bite::Email
|
|
126
123
|
end
|
127
124
|
end
|
128
125
|
|
129
|
-
if (readcursor & Indicators[:'message-rfc822'])
|
126
|
+
if (readcursor & Indicators[:'message-rfc822']) == 0
|
130
127
|
# Beginning of the original message part
|
131
128
|
if e == StartingOf[:rfc822][0]
|
132
129
|
readcursor |= Indicators[:'message-rfc822']
|
@@ -144,7 +141,7 @@ module Sisimai::Bite::Email
|
|
144
141
|
rfc822list << e
|
145
142
|
else
|
146
143
|
# Before "message/rfc822"
|
147
|
-
next if (readcursor & Indicators[:deliverystatus])
|
144
|
+
next if (readcursor & Indicators[:deliverystatus]) == 0
|
148
145
|
next if e.empty?
|
149
146
|
|
150
147
|
# This message was created automatically by mail delivery software.
|
@@ -178,9 +175,9 @@ module Sisimai::Bite::Email
|
|
178
175
|
end
|
179
176
|
end
|
180
177
|
end
|
181
|
-
return nil
|
178
|
+
return nil unless recipients > 0
|
182
179
|
|
183
|
-
|
180
|
+
unless mhead['received'].empty?
|
184
181
|
# Get the name of local MTA
|
185
182
|
# Received: from marutamachi.example.org (c192128.example.net [192.0.2.128])
|
186
183
|
if cv = mhead['received'][-1].match(/from[ ]([^ ]+) /)
|
@@ -188,13 +185,10 @@ module Sisimai::Bite::Email
|
|
188
185
|
end
|
189
186
|
end
|
190
187
|
|
191
|
-
|
192
|
-
dscontents.map do |e|
|
188
|
+
dscontents.each do |e|
|
193
189
|
e['agent'] = self.smtpagent
|
194
190
|
e['lhost'] = localhost0
|
195
|
-
|
196
|
-
e['diagnosis'] = e['diagnosis'].gsub(/[-]{2}.*\z/, '')
|
197
|
-
e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
|
191
|
+
e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'].gsub(/[-]{2}.*\z/, ''))
|
198
192
|
|
199
193
|
unless e['rhost']
|
200
194
|
# Get the remote host name
|
@@ -205,7 +199,7 @@ module Sisimai::Bite::Email
|
|
205
199
|
|
206
200
|
unless e['rhost']
|
207
201
|
# Get localhost and remote host name from Received header.
|
208
|
-
e['rhost'] = Sisimai::RFC5322.received(mhead['received'][-1]).pop
|
202
|
+
e['rhost'] = Sisimai::RFC5322.received(mhead['received'][-1]).pop unless mhead['received'].empty?
|
209
203
|
end
|
210
204
|
end
|
211
205
|
|
@@ -231,14 +225,14 @@ module Sisimai::Bite::Email
|
|
231
225
|
# Verify each regular expression of session errors
|
232
226
|
MessagesOf.each_key do |r|
|
233
227
|
# Check each regular expression
|
234
|
-
next unless MessagesOf[r].
|
228
|
+
next unless MessagesOf[r].any? { |a| e['diagnosis'].include?(a) }
|
235
229
|
e['reason'] = r.to_s
|
236
230
|
break
|
237
231
|
end
|
238
232
|
|
239
233
|
unless e['reason']
|
240
234
|
# The reason "expired"
|
241
|
-
e['reason'] = 'expired' if DelayedFor.
|
235
|
+
e['reason'] = 'expired' if DelayedFor.any? { |a| e['diagnosis'].include?(a) }
|
242
236
|
end
|
243
237
|
end
|
244
238
|
end
|
@@ -35,8 +35,6 @@ module Sisimai::Bite::Email
|
|
35
35
|
# part or nil if it failed to parse or
|
36
36
|
# the arguments are missing
|
37
37
|
def scan(mhead, mbody)
|
38
|
-
return nil unless mhead
|
39
|
-
return nil unless mbody
|
40
38
|
return nil unless mhead['subject'].start_with?('Undeliverable message')
|
41
39
|
|
42
40
|
dscontents = [Sisimai::Bite.DELIVERYSTATUS]
|
@@ -51,7 +49,7 @@ module Sisimai::Bite::Email
|
|
51
49
|
v = nil
|
52
50
|
|
53
51
|
while e = hasdivided.shift do
|
54
|
-
if readcursor
|
52
|
+
if readcursor == 0
|
55
53
|
# Beginning of the bounce message or delivery status part
|
56
54
|
if e.start_with?(StartingOf[:message][0])
|
57
55
|
readcursor |= Indicators[:deliverystatus]
|
@@ -59,7 +57,7 @@ module Sisimai::Bite::Email
|
|
59
57
|
end
|
60
58
|
end
|
61
59
|
|
62
|
-
if (readcursor & Indicators[:'message-rfc822'])
|
60
|
+
if (readcursor & Indicators[:'message-rfc822']) == 0
|
63
61
|
# Beginning of the original message part
|
64
62
|
if e.start_with?(StartingOf[:rfc822][0])
|
65
63
|
readcursor |= Indicators[:'message-rfc822']
|
@@ -85,7 +83,7 @@ module Sisimai::Bite::Email
|
|
85
83
|
rfc822list << e
|
86
84
|
else
|
87
85
|
# Before "message/rfc822"
|
88
|
-
next if (readcursor & Indicators[:deliverystatus])
|
86
|
+
next if (readcursor & Indicators[:deliverystatus]) == 0
|
89
87
|
|
90
88
|
# ------- Failure Reasons --------
|
91
89
|
#
|
@@ -132,31 +130,29 @@ module Sisimai::Bite::Email
|
|
132
130
|
end
|
133
131
|
end
|
134
132
|
|
135
|
-
|
133
|
+
unless recipients > 0
|
136
134
|
# Fallback: Get the recpient address from RFC822 part
|
137
135
|
rfc822list.each do |e|
|
138
136
|
next unless cv = e.match(/^To:[ ]*(.+)$/m)
|
139
137
|
|
140
138
|
v['recipient'] = Sisimai::Address.s3s4(cv[1])
|
141
|
-
recipients += 1
|
139
|
+
recipients += 1 unless v['recipient'].empty?
|
142
140
|
break
|
143
141
|
end
|
144
142
|
end
|
145
|
-
return nil
|
143
|
+
return nil unless recipients > 0
|
146
144
|
|
147
|
-
|
148
|
-
require 'sisimai/smtp/status'
|
149
|
-
dscontents.map do |e|
|
145
|
+
dscontents.each do |e|
|
150
146
|
e['agent'] = self.smtpagent
|
151
147
|
e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
|
152
148
|
e['recipient'] = Sisimai::Address.s3s4(e['recipient'])
|
153
149
|
|
154
150
|
MessagesOf.each_key do |r|
|
155
151
|
# Check each regular expression of Notes error messages
|
156
|
-
next unless MessagesOf[r].
|
152
|
+
next unless MessagesOf[r].any? { |a| e['diagnosis'].include?(a) }
|
157
153
|
e['reason'] = r.to_s
|
158
154
|
pseudostatus = Sisimai::SMTP::Status.code(r.to_s)
|
159
|
-
e['status'] = pseudostatus
|
155
|
+
e['status'] = pseudostatus unless pseudostatus.empty?
|
160
156
|
break
|
161
157
|
end
|
162
158
|
e.each_key { |a| e[a] ||= '' }
|
@@ -51,7 +51,7 @@ module Sisimai::Bite::Email
|
|
51
51
|
%r/\A5[.]7[.]7[0-4]\d\z/ => 'toomanyconn',
|
52
52
|
}.freeze
|
53
53
|
ReCommands = {
|
54
|
-
RCPT: %r/unknown recipient or mailbox unavailable ->.+[<]
|
54
|
+
RCPT: %r/unknown recipient or mailbox unavailable ->.+[<]?.+[@].+[.][a-zA-Z]+[>]?/,
|
55
55
|
}.freeze
|
56
56
|
|
57
57
|
def description; return 'Microsoft Office 365: http://office.microsoft.com/'; end
|
@@ -88,9 +88,6 @@ module Sisimai::Bite::Email
|
|
88
88
|
# part or nil if it failed to parse or
|
89
89
|
# the arguments are missing
|
90
90
|
def scan(mhead, mbody)
|
91
|
-
return nil unless mhead
|
92
|
-
return nil unless mbody
|
93
|
-
|
94
91
|
tryto = %r/.+[.](?:outbound[.]protection|prod)[.]outlook[.]com\b/
|
95
92
|
match = 0
|
96
93
|
match += 1 if mhead['subject'].include?('Undeliverable:')
|
@@ -101,7 +98,7 @@ module Sisimai::Bite::Email
|
|
101
98
|
match += 1 if mhead['x-ms-exchange-crosstenant-originalarrivaltime']
|
102
99
|
match += 1 if mhead['x-ms-exchange-crosstenant-fromentityheader']
|
103
100
|
match += 1 if mhead['x-ms-exchange-transport-crosstenantheadersstamped']
|
104
|
-
match += 1 if mhead['received'].
|
101
|
+
match += 1 if mhead['received'].any? { |a| a =~ tryto }
|
105
102
|
if mhead['message-id']
|
106
103
|
# Message-ID: <00000000-0000-0000-0000-000000000000@*.*.prod.outlook.com>
|
107
104
|
match += 1 if mhead['message-id'] =~ tryto
|
@@ -120,7 +117,7 @@ module Sisimai::Bite::Email
|
|
120
117
|
v = nil
|
121
118
|
|
122
119
|
while e = hasdivided.shift do
|
123
|
-
if readcursor
|
120
|
+
if readcursor == 0
|
124
121
|
# Beginning of the bounce message or delivery status part
|
125
122
|
if e =~ MarkingsOf[:message]
|
126
123
|
readcursor |= Indicators[:deliverystatus]
|
@@ -128,7 +125,7 @@ module Sisimai::Bite::Email
|
|
128
125
|
end
|
129
126
|
end
|
130
127
|
|
131
|
-
if (readcursor & Indicators[:'message-rfc822'])
|
128
|
+
if (readcursor & Indicators[:'message-rfc822']) == 0
|
132
129
|
# Beginning of the original message part
|
133
130
|
if e == StartingOf[:rfc822][0]
|
134
131
|
readcursor |= Indicators[:'message-rfc822']
|
@@ -146,7 +143,7 @@ module Sisimai::Bite::Email
|
|
146
143
|
rfc822list << e
|
147
144
|
else
|
148
145
|
# Before "message/rfc822"
|
149
|
-
next if (readcursor & Indicators[:deliverystatus])
|
146
|
+
next if (readcursor & Indicators[:deliverystatus]) == 0
|
150
147
|
next if e.empty?
|
151
148
|
|
152
149
|
# kijitora@example.com<mailto:kijitora@example.com>
|
@@ -221,11 +218,9 @@ module Sisimai::Bite::Email
|
|
221
218
|
|
222
219
|
end
|
223
220
|
end
|
224
|
-
return nil
|
221
|
+
return nil unless recipients > 0
|
225
222
|
|
226
|
-
|
227
|
-
require 'sisimai/smtp/status'
|
228
|
-
dscontents.map do |e|
|
223
|
+
dscontents.each do |e|
|
229
224
|
# Set default values if each value is empty.
|
230
225
|
connheader.each_key { |a| e[a] ||= connheader[a] || '' }
|
231
226
|
|
@@ -236,7 +231,7 @@ module Sisimai::Bite::Email
|
|
236
231
|
if e['status'].empty? || e['status'].end_with?('.0.0')
|
237
232
|
# There is no value of Status header or the value is 5.0.0, 4.0.0
|
238
233
|
pseudostatus = Sisimai::SMTP::Status.find(e['diagnosis'])
|
239
|
-
e['status'] = pseudostatus
|
234
|
+
e['status'] = pseudostatus unless pseudostatus.empty?
|
240
235
|
end
|
241
236
|
|
242
237
|
ReCommands.each_key do |p|
|
@@ -81,12 +81,9 @@ module Sisimai::Bite::Email
|
|
81
81
|
# part or nil if it failed to parse or
|
82
82
|
# the arguments are missing
|
83
83
|
def scan(mhead, mbody)
|
84
|
-
return nil unless mhead
|
85
|
-
return nil unless mbody
|
86
|
-
|
87
84
|
return nil unless mhead['subject'].start_with?('Delivery status notification')
|
88
85
|
return nil unless mhead['from'].start_with?('Mailer Daemon <')
|
89
|
-
return nil unless mhead['received'].
|
86
|
+
return nil unless mhead['received'].any? { |a| a.include?(' (OpenSMTPD) with ') }
|
90
87
|
|
91
88
|
dscontents = [Sisimai::Bite.DELIVERYSTATUS]
|
92
89
|
hasdivided = mbody.split("\n")
|
@@ -97,7 +94,7 @@ module Sisimai::Bite::Email
|
|
97
94
|
v = nil
|
98
95
|
|
99
96
|
while e = hasdivided.shift do
|
100
|
-
if readcursor
|
97
|
+
if readcursor == 0
|
101
98
|
# Beginning of the bounce message or delivery status part
|
102
99
|
if e.start_with?(StartingOf[:message][0])
|
103
100
|
readcursor |= Indicators[:deliverystatus]
|
@@ -105,7 +102,7 @@ module Sisimai::Bite::Email
|
|
105
102
|
end
|
106
103
|
end
|
107
104
|
|
108
|
-
if (readcursor & Indicators[:'message-rfc822'])
|
105
|
+
if (readcursor & Indicators[:'message-rfc822']) == 0
|
109
106
|
# Beginning of the original message part
|
110
107
|
if e.start_with?(StartingOf[:rfc822][0])
|
111
108
|
readcursor |= Indicators[:'message-rfc822']
|
@@ -123,7 +120,7 @@ module Sisimai::Bite::Email
|
|
123
120
|
rfc822list << e
|
124
121
|
else
|
125
122
|
# Before "message/rfc822"
|
126
|
-
next if (readcursor & Indicators[:deliverystatus])
|
123
|
+
next if (readcursor & Indicators[:deliverystatus]) == 0
|
127
124
|
next if e.empty?
|
128
125
|
|
129
126
|
# Hi!
|
@@ -151,16 +148,15 @@ module Sisimai::Bite::Email
|
|
151
148
|
end
|
152
149
|
end
|
153
150
|
end
|
154
|
-
return nil
|
151
|
+
return nil unless recipients > 0
|
155
152
|
|
156
|
-
|
157
|
-
dscontents.map do |e|
|
153
|
+
dscontents.each do |e|
|
158
154
|
e['agent'] = self.smtpagent
|
159
155
|
e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
|
160
156
|
|
161
157
|
MessagesOf.each_key do |r|
|
162
158
|
# Verify each regular expression of session errors
|
163
|
-
next unless MessagesOf[r].
|
159
|
+
next unless MessagesOf[r].any? { |a| e['diagnosis'].include?(a) }
|
164
160
|
e['reason'] = r.to_s
|
165
161
|
break
|
166
162
|
end
|
@@ -36,15 +36,12 @@ module Sisimai::Bite::Email
|
|
36
36
|
# part or nil if it failed to parse or
|
37
37
|
# the arguments are missing
|
38
38
|
def scan(mhead, mbody)
|
39
|
-
return nil unless mhead
|
40
|
-
return nil unless mbody
|
41
|
-
|
42
39
|
# :from => %r/postmaster[@]/,
|
43
40
|
match = 0
|
44
41
|
match += 1 if mhead['subject'].start_with?('Delivery Status Notification')
|
45
42
|
match += 1 if mhead['x-message-delivery']
|
46
43
|
match += 1 if mhead['x-message-info']
|
47
|
-
match += 1 if mhead['received'].
|
44
|
+
match += 1 if mhead['received'].any? { |a| a.include?('.hotmail.com') }
|
48
45
|
return nil if match < 2
|
49
46
|
|
50
47
|
dscontents = [Sisimai::Bite.DELIVERYSTATUS]
|
@@ -66,7 +63,7 @@ module Sisimai::Bite::Email
|
|
66
63
|
havepassed << e
|
67
64
|
p = havepassed[-2]
|
68
65
|
|
69
|
-
if readcursor
|
66
|
+
if readcursor == 0
|
70
67
|
# Beginning of the bounce message or delivery status part
|
71
68
|
if e.start_with?(StartingOf[:message][0])
|
72
69
|
readcursor |= Indicators[:deliverystatus]
|
@@ -74,7 +71,7 @@ module Sisimai::Bite::Email
|
|
74
71
|
end
|
75
72
|
end
|
76
73
|
|
77
|
-
if (readcursor & Indicators[:'message-rfc822'])
|
74
|
+
if (readcursor & Indicators[:'message-rfc822']) == 0
|
78
75
|
# Beginning of the original message part
|
79
76
|
if e == StartingOf[:rfc822][0]
|
80
77
|
readcursor |= Indicators[:'message-rfc822']
|
@@ -92,7 +89,7 @@ module Sisimai::Bite::Email
|
|
92
89
|
rfc822list << e
|
93
90
|
else
|
94
91
|
# Before "message/rfc822"
|
95
|
-
next if (readcursor & Indicators[:deliverystatus])
|
92
|
+
next if (readcursor & Indicators[:deliverystatus]) == 0
|
96
93
|
next if e.empty?
|
97
94
|
|
98
95
|
if connvalues == connheader.keys.size
|
@@ -143,23 +140,22 @@ module Sisimai::Bite::Email
|
|
143
140
|
# Arrival-Date: Fri, 21 Nov 2014 14:17:34 -0800
|
144
141
|
if cv = e.match(/\AReporting-MTA:[ ]*(?:DNS|dns);[ ]*(.+)\z/)
|
145
142
|
# Reporting-MTA: dns;BLU004-OMC3S13.hotmail.example.com
|
146
|
-
next
|
143
|
+
next unless connheader['lhost'].empty?
|
147
144
|
connheader['lhost'] = cv[1].downcase
|
148
145
|
connvalues += 1
|
149
146
|
|
150
147
|
elsif cv = e.match(/\AArrival-Date:[ ]*(.+)\z/)
|
151
148
|
# Arrival-Date: Wed, 29 Apr 2009 16:03:18 +0900
|
152
|
-
next
|
149
|
+
next unless connheader['date'].empty?
|
153
150
|
connheader['date'] = cv[1]
|
154
151
|
connvalues += 1
|
155
152
|
end
|
156
153
|
end
|
157
154
|
end
|
158
155
|
end
|
159
|
-
return nil
|
156
|
+
return nil unless recipients > 0
|
160
157
|
|
161
|
-
|
162
|
-
dscontents.map do |e|
|
158
|
+
dscontents.each do |e|
|
163
159
|
# Set default values if each value is empty.
|
164
160
|
connheader.each_key { |a| e[a] ||= connheader[a] || '' }
|
165
161
|
e['agent'] = self.smtpagent
|
@@ -179,7 +175,7 @@ module Sisimai::Bite::Email
|
|
179
175
|
|
180
176
|
MessagesOf.each_key do |r|
|
181
177
|
# Verify each regular expression of session errors
|
182
|
-
next unless MessagesOf[r].
|
178
|
+
next unless MessagesOf[r].any? { |a| e['diagnosis'].include?(a) }
|
183
179
|
e['reason'] = r.to_s
|
184
180
|
break
|
185
181
|
end
|