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
@@ -33,9 +33,6 @@ module Sisimai::Bite::Email
|
|
33
33
|
# part or nil if it failed to parse or
|
34
34
|
# the arguments are missing
|
35
35
|
def scan(mhead, mbody)
|
36
|
-
return nil unless mhead
|
37
|
-
return nil unless mbody
|
38
|
-
|
39
36
|
# :'subject' => %r/Delivery[_ ]Status[_ ]Notification[_ ].+Failure/,
|
40
37
|
# :'received' => %r/.+[.]smtp-out[.].+[.]amazonses[.]com\b/,
|
41
38
|
# :'x-mailer' => %r/\AAmazon WorkMail\z/,
|
@@ -63,7 +60,7 @@ module Sisimai::Bite::Email
|
|
63
60
|
v = nil
|
64
61
|
|
65
62
|
while e = hasdivided.shift do
|
66
|
-
if readcursor
|
63
|
+
if readcursor == 0
|
67
64
|
# Beginning of the bounce message or delivery status part
|
68
65
|
if e == StartingOf[:message][0]
|
69
66
|
readcursor |= Indicators[:deliverystatus]
|
@@ -71,7 +68,7 @@ module Sisimai::Bite::Email
|
|
71
68
|
end
|
72
69
|
end
|
73
70
|
|
74
|
-
if (readcursor & Indicators[:'message-rfc822'])
|
71
|
+
if (readcursor & Indicators[:'message-rfc822']) == 0
|
75
72
|
# Beginning of the original message part
|
76
73
|
if e == StartingOf[:rfc822][0]
|
77
74
|
readcursor |= Indicators[:'message-rfc822']
|
@@ -89,7 +86,7 @@ module Sisimai::Bite::Email
|
|
89
86
|
rfc822list << e
|
90
87
|
else
|
91
88
|
# Before "message/rfc822"
|
92
|
-
next if (readcursor & Indicators[:deliverystatus])
|
89
|
+
next if (readcursor & Indicators[:deliverystatus]) == 0
|
93
90
|
next if e.empty?
|
94
91
|
|
95
92
|
if connvalues == connheader.keys.size
|
@@ -130,7 +127,7 @@ module Sisimai::Bite::Email
|
|
130
127
|
#
|
131
128
|
if cv = e.match(/\AReporting-MTA:[ ]*[DNSdns]+;[ ]*(.+)\z/)
|
132
129
|
# Reporting-MTA: dns; mx.example.jp
|
133
|
-
next
|
130
|
+
next unless connheader['lhost'].empty?
|
134
131
|
connheader['lhost'] = cv[1].downcase
|
135
132
|
connvalues += 1
|
136
133
|
end
|
@@ -143,11 +140,9 @@ module Sisimai::Bite::Email
|
|
143
140
|
break if e.start_with?('<!DOCTYPE HTML><html>')
|
144
141
|
end
|
145
142
|
end
|
146
|
-
return nil
|
143
|
+
return nil unless recipients > 0
|
147
144
|
|
148
|
-
|
149
|
-
require 'sisimai/smtp/status'
|
150
|
-
dscontents.map do |e|
|
145
|
+
dscontents.each do |e|
|
151
146
|
# Set default values if each value is empty.
|
152
147
|
connheader.each_key { |a| e[a] ||= connheader[a] || '' }
|
153
148
|
|
@@ -162,7 +157,7 @@ module Sisimai::Bite::Email
|
|
162
157
|
end
|
163
158
|
|
164
159
|
pseudostatus = Sisimai::SMTP::Status.find(errormessage)
|
165
|
-
e['status'] = pseudostatus
|
160
|
+
e['status'] = pseudostatus unless pseudostatus.empty?
|
166
161
|
end
|
167
162
|
|
168
163
|
if cv = e['diagnosis'].match(/[<]([245]\d\d)[ ].+[>]/)
|
@@ -43,9 +43,6 @@ module Sisimai::Bite::Email
|
|
43
43
|
# part or nil if it failed to parse or
|
44
44
|
# the arguments are missing
|
45
45
|
def scan(mhead, mbody)
|
46
|
-
return nil unless mhead
|
47
|
-
return nil unless mbody
|
48
|
-
|
49
46
|
# :from => %r/\APostmaster [<]Postmaster[@]AOL[.]com[>]\z/,
|
50
47
|
# :subject => %r/\AUndeliverable: /,
|
51
48
|
return nil unless mhead['x-aol-ip']
|
@@ -69,7 +66,7 @@ module Sisimai::Bite::Email
|
|
69
66
|
havepassed << e
|
70
67
|
p = havepassed[-2]
|
71
68
|
|
72
|
-
if readcursor
|
69
|
+
if readcursor == 0
|
73
70
|
# Beginning of the bounce message or delivery status part
|
74
71
|
if e.start_with?(StartingOf[:message][0])
|
75
72
|
readcursor |= Indicators[:deliverystatus]
|
@@ -77,7 +74,7 @@ module Sisimai::Bite::Email
|
|
77
74
|
end
|
78
75
|
end
|
79
76
|
|
80
|
-
if (readcursor & Indicators[:'message-rfc822'])
|
77
|
+
if (readcursor & Indicators[:'message-rfc822']) == 0
|
81
78
|
# Beginning of the original message part
|
82
79
|
if e.start_with?(StartingOf[:rfc822][0])
|
83
80
|
readcursor |= Indicators[:'message-rfc822']
|
@@ -95,7 +92,7 @@ module Sisimai::Bite::Email
|
|
95
92
|
rfc822list << e
|
96
93
|
else
|
97
94
|
# Before "message/rfc822"
|
98
|
-
next if (readcursor & Indicators[:deliverystatus])
|
95
|
+
next if (readcursor & Indicators[:deliverystatus]) == 0
|
99
96
|
next if e.empty?
|
100
97
|
|
101
98
|
if connvalues == connheader.keys.size
|
@@ -151,13 +148,13 @@ module Sisimai::Bite::Email
|
|
151
148
|
# Arrival-Date: Fri, 21 Nov 2014 17:14:34 -0500 (EST)
|
152
149
|
if cv = e.match(/\AReporting-MTA:[ ]*(?:DNS|dns);[ ]*(.+)\z/)
|
153
150
|
# Reporting-MTA: dns; mx.example.jp
|
154
|
-
next
|
151
|
+
next unless connheader['lhost'].empty?
|
155
152
|
connheader['lhost'] = cv[1].downcase
|
156
153
|
connvalues += 1
|
157
154
|
|
158
155
|
elsif cv = e.match(/\AArrival-Date:[ ]*(.+)\z/)
|
159
156
|
# Arrival-Date: Wed, 29 Apr 2009 16:03:18 +0900
|
160
|
-
next
|
157
|
+
next unless connheader['date'].empty?
|
161
158
|
connheader['date'] = cv[1]
|
162
159
|
connvalues += 1
|
163
160
|
end
|
@@ -165,21 +162,18 @@ module Sisimai::Bite::Email
|
|
165
162
|
end
|
166
163
|
end
|
167
164
|
end
|
168
|
-
return nil
|
165
|
+
return nil unless recipients > 0
|
169
166
|
|
170
|
-
|
171
|
-
require 'sisimai/smtp/status'
|
172
|
-
dscontents.map do |e|
|
167
|
+
dscontents.each do |e|
|
173
168
|
# Set default values if each value is empty.
|
174
169
|
connheader.each_key { |a| e[a] ||= connheader[a] || '' }
|
175
170
|
|
176
171
|
e['agent'] = self.smtpagent
|
177
|
-
e['diagnosis'] = e['diagnosis'].gsub(/\\n/, ' ')
|
178
|
-
e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
|
172
|
+
e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'].gsub(/\\n/, ' '))
|
179
173
|
|
180
174
|
MessagesOf.each_key do |r|
|
181
175
|
# Verify each regular expression of session errors
|
182
|
-
next unless MessagesOf[r].
|
176
|
+
next unless MessagesOf[r].any? { |a| e['diagnosis'].include?(a) }
|
183
177
|
e['reason'] = r.to_s
|
184
178
|
break
|
185
179
|
end
|
@@ -187,7 +181,7 @@ module Sisimai::Bite::Email
|
|
187
181
|
if e['status'].empty? || e['status'].end_with?('.0.0')
|
188
182
|
# There is no value of Status header or the value is 5.0.0, 4.0.0
|
189
183
|
pseudostatus = Sisimai::SMTP::Status.find(e['diagnosis'])
|
190
|
-
e['status'] = pseudostatus
|
184
|
+
e['status'] = pseudostatus unless pseudostatus.empty?
|
191
185
|
end
|
192
186
|
end
|
193
187
|
|
@@ -32,14 +32,11 @@ module Sisimai::Bite::Email
|
|
32
32
|
# part or nil if it failed to parse or
|
33
33
|
# the arguments are missing
|
34
34
|
def scan(mhead, mbody)
|
35
|
-
return nil unless mhead
|
36
|
-
return nil unless mbody
|
37
|
-
|
38
35
|
match = 0
|
39
36
|
match += 1 if mhead['subject'] == '[BOUNCE]'
|
40
37
|
match += 1 if mhead['message-id'].to_s.include?('.JavaMail.')
|
41
|
-
match += 1 if mhead['received'].
|
42
|
-
return
|
38
|
+
match += 1 if mhead['received'].any? { |a| a.include?('JAMES SMTP Server') }
|
39
|
+
return nil unless match > 0
|
43
40
|
|
44
41
|
dscontents = [Sisimai::Bite.DELIVERYSTATUS]
|
45
42
|
hasdivided = mbody.split("\n")
|
@@ -53,7 +50,7 @@ module Sisimai::Bite::Email
|
|
53
50
|
v = nil
|
54
51
|
|
55
52
|
while e = hasdivided.shift do
|
56
|
-
if readcursor
|
53
|
+
if readcursor == 0
|
57
54
|
# Beginning of the bounce message or delivery status part
|
58
55
|
if e.start_with?(StartingOf[:message][0])
|
59
56
|
readcursor |= Indicators[:deliverystatus]
|
@@ -61,7 +58,7 @@ module Sisimai::Bite::Email
|
|
61
58
|
end
|
62
59
|
end
|
63
60
|
|
64
|
-
if (readcursor & Indicators[:'message-rfc822'])
|
61
|
+
if (readcursor & Indicators[:'message-rfc822']) == 0
|
65
62
|
# Beginning of the original message part
|
66
63
|
if e.start_with?(StartingOf[:rfc822][0])
|
67
64
|
readcursor |= Indicators[:'message-rfc822']
|
@@ -79,7 +76,7 @@ module Sisimai::Bite::Email
|
|
79
76
|
rfc822list << e
|
80
77
|
else
|
81
78
|
# Before "message/rfc822"
|
82
|
-
next if (readcursor & Indicators[:deliverystatus])
|
79
|
+
next if (readcursor & Indicators[:deliverystatus]) == 0
|
83
80
|
next if e.empty?
|
84
81
|
|
85
82
|
# Message details:
|
@@ -133,16 +130,15 @@ module Sisimai::Bite::Email
|
|
133
130
|
end
|
134
131
|
end
|
135
132
|
end
|
136
|
-
return nil
|
133
|
+
return nil unless recipients > 0
|
137
134
|
|
138
|
-
unless rfc822list.
|
135
|
+
unless rfc822list.any? { |a| a.start_with?('Subject:') }
|
139
136
|
# Set the value of subjecttxt as a Subject if there is no original
|
140
137
|
# message in the bounce mail.
|
141
138
|
rfc822list << ('Subject: ' << subjecttxt)
|
142
139
|
end
|
143
140
|
|
144
|
-
|
145
|
-
dscontents.map do |e|
|
141
|
+
dscontents.each do |e|
|
146
142
|
e['agent'] = self.smtpagent
|
147
143
|
e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'] || diagnostic)
|
148
144
|
e.each_key { |a| e[a] ||= '' }
|
@@ -26,16 +26,12 @@ module Sisimai::Bite::Email
|
|
26
26
|
# part or nil if it failed to parse or
|
27
27
|
# the arguments are missing
|
28
28
|
def scan(mhead, mbody)
|
29
|
-
return nil unless mhead
|
30
|
-
return nil unless mbody
|
31
|
-
|
32
29
|
# :subject => %r/\AReturned mail: /,
|
33
30
|
match = 0
|
34
31
|
match += 1 if mhead['from'].include?('@bigfoot.com>')
|
35
|
-
match += 1 if mhead['received'].
|
36
|
-
return nil
|
32
|
+
match += 1 if mhead['received'].any? { |a| a.include?('.bigfoot.com') }
|
33
|
+
return nil unless match > 0
|
37
34
|
|
38
|
-
require 'sisimai/address'
|
39
35
|
dscontents = [Sisimai::Bite.DELIVERYSTATUS]
|
40
36
|
hasdivided = mbody.split("\n")
|
41
37
|
havepassed = ['']
|
@@ -57,7 +53,7 @@ module Sisimai::Bite::Email
|
|
57
53
|
havepassed << e
|
58
54
|
p = havepassed[-2]
|
59
55
|
|
60
|
-
if readcursor
|
56
|
+
if readcursor == 0
|
61
57
|
# Beginning of the bounce message or delivery status part
|
62
58
|
if e =~ MarkingsOf[:message]
|
63
59
|
readcursor |= Indicators[:deliverystatus]
|
@@ -65,7 +61,7 @@ module Sisimai::Bite::Email
|
|
65
61
|
end
|
66
62
|
end
|
67
63
|
|
68
|
-
if (readcursor & Indicators[:'message-rfc822'])
|
64
|
+
if (readcursor & Indicators[:'message-rfc822']) == 0
|
69
65
|
# Beginning of the original message part
|
70
66
|
if e.start_with?(StartingOf[:rfc822][0])
|
71
67
|
readcursor |= Indicators[:'message-rfc822']
|
@@ -83,7 +79,7 @@ module Sisimai::Bite::Email
|
|
83
79
|
rfc822list << e
|
84
80
|
else
|
85
81
|
# Before "message/rfc822"
|
86
|
-
next if (readcursor & Indicators[:deliverystatus])
|
82
|
+
next if (readcursor & Indicators[:deliverystatus]) == 0
|
87
83
|
next if e.empty?
|
88
84
|
|
89
85
|
if connvalues == connheader.keys.size
|
@@ -142,13 +138,13 @@ module Sisimai::Bite::Email
|
|
142
138
|
#
|
143
139
|
if cv = e.match(/\AReporting-MTA:[ ]*(?:DNS|dns);[ ]*(.+)\z/)
|
144
140
|
# Reporting-MTA: dns; mx.example.jp
|
145
|
-
next
|
141
|
+
next unless connheader['lhost'].empty?
|
146
142
|
connheader['lhost'] = cv[1].downcase
|
147
143
|
connvalues += 1
|
148
144
|
|
149
145
|
elsif cv = e.match(/\AArrival-Date:[ ]*(.+)\z/)
|
150
146
|
# Arrival-Date: Wed, 29 Apr 2009 16:03:18 +0900
|
151
|
-
next
|
147
|
+
next unless connheader['date'].empty?
|
152
148
|
connheader['date'] = cv[1]
|
153
149
|
connvalues += 1
|
154
150
|
else
|
@@ -169,10 +165,9 @@ module Sisimai::Bite::Email
|
|
169
165
|
end
|
170
166
|
end
|
171
167
|
end
|
172
|
-
return nil
|
168
|
+
return nil unless recipients > 0
|
173
169
|
|
174
|
-
|
175
|
-
dscontents.map do |e|
|
170
|
+
dscontents.each do |e|
|
176
171
|
# Set default values if each value is empty.
|
177
172
|
connheader.each_key { |a| e[a] ||= connheader[a] || '' }
|
178
173
|
|
@@ -180,7 +175,7 @@ module Sisimai::Bite::Email
|
|
180
175
|
e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
|
181
176
|
e['command'] = commandtxt
|
182
177
|
if e['command'].empty?
|
183
|
-
e['command'] = 'EHLO'
|
178
|
+
e['command'] = 'EHLO' unless esmtpreply.empty?
|
184
179
|
end
|
185
180
|
end
|
186
181
|
|
@@ -33,12 +33,9 @@ module Sisimai::Bite::Email
|
|
33
33
|
# part or nil if it failed to parse or
|
34
34
|
# the arguments are missing
|
35
35
|
def scan(mhead, mbody)
|
36
|
-
return nil unless mhead
|
37
|
-
return nil unless mbody
|
38
36
|
return nil unless mhead['from'] =~ /postmaster[@](?:biglobe|inacatv|tmtv|ttv)[.]ne[.]jp/
|
39
37
|
return nil unless mhead['subject'].start_with?('Returned mail:')
|
40
38
|
|
41
|
-
require 'sisimai/address'
|
42
39
|
dscontents = [Sisimai::Bite.DELIVERYSTATUS]
|
43
40
|
hasdivided = mbody.split("\n")
|
44
41
|
rfc822list = [] # (Array) Each line in message/rfc822 part string
|
@@ -48,7 +45,7 @@ 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
|
if e == StartingOf[:message][0]
|
54
51
|
readcursor |= Indicators[:deliverystatus]
|
@@ -56,7 +53,7 @@ module Sisimai::Bite::Email
|
|
56
53
|
end
|
57
54
|
end
|
58
55
|
|
59
|
-
if (readcursor & Indicators[:'message-rfc822'])
|
56
|
+
if (readcursor & Indicators[:'message-rfc822']) == 0
|
60
57
|
# Beginning of the original message part
|
61
58
|
if e == StartingOf[:rfc822][0]
|
62
59
|
readcursor |= Indicators[:'message-rfc822']
|
@@ -74,7 +71,7 @@ module Sisimai::Bite::Email
|
|
74
71
|
rfc822list << e
|
75
72
|
else
|
76
73
|
# Before "message/rfc822"
|
77
|
-
next if (readcursor & Indicators[:deliverystatus])
|
74
|
+
next if (readcursor & Indicators[:deliverystatus]) == 0
|
78
75
|
next if e.empty?
|
79
76
|
|
80
77
|
# This is a MIME-encapsulated message.
|
@@ -98,7 +95,7 @@ module Sisimai::Bite::Email
|
|
98
95
|
# ********@***.biglobe.ne.jp
|
99
96
|
if v['recipient']
|
100
97
|
# There are multiple recipient addresses in the message body.
|
101
|
-
|
98
|
+
dscontents << Sisimai::Bite.DELIVERYSTATUS
|
102
99
|
v = dscontents[-1]
|
103
100
|
end
|
104
101
|
|
@@ -114,16 +111,15 @@ module Sisimai::Bite::Email
|
|
114
111
|
end
|
115
112
|
end
|
116
113
|
end
|
117
|
-
return nil
|
114
|
+
return nil unless recipients > 0
|
118
115
|
|
119
|
-
|
120
|
-
dscontents.map do |e|
|
116
|
+
dscontents.each do |e|
|
121
117
|
e['agent'] = self.smtpagent
|
122
118
|
e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
|
123
119
|
|
124
120
|
MessagesOf.each_key do |r|
|
125
121
|
# Verify each regular expression of session errors
|
126
|
-
next unless MessagesOf[r].
|
122
|
+
next unless MessagesOf[r].any? { |a| e['diagnosis'].include?(a) }
|
127
123
|
e['reason'] = r.to_s
|
128
124
|
break
|
129
125
|
end
|
@@ -40,9 +40,6 @@ module Sisimai::Bite::Email
|
|
40
40
|
# part or nil if it failed to parse or
|
41
41
|
# the arguments are missing
|
42
42
|
def scan(mhead, mbody)
|
43
|
-
return nil unless mhead
|
44
|
-
return nil unless mbody
|
45
|
-
|
46
43
|
match = 0
|
47
44
|
match += 1 if mhead['from'].include?('Courier mail server at ')
|
48
45
|
match += 1 if mhead['subject'] =~ /(?:NOTICE: mail delivery status[.]|WARNING: delayed mail[.])/
|
@@ -50,7 +47,7 @@ module Sisimai::Bite::Email
|
|
50
47
|
# Message-ID: <courier.4D025E3A.00001792@5jo.example.org>
|
51
48
|
match += 1 if mhead['message-id'] =~ /\A[<]courier[.][0-9A-F]+[.]/
|
52
49
|
end
|
53
|
-
return nil
|
50
|
+
return nil unless match > 0
|
54
51
|
|
55
52
|
dscontents = [Sisimai::Bite.DELIVERYSTATUS]
|
56
53
|
hasdivided = mbody.split("\n")
|
@@ -73,7 +70,7 @@ module Sisimai::Bite::Email
|
|
73
70
|
havepassed << e
|
74
71
|
p = havepassed[-2]
|
75
72
|
|
76
|
-
if readcursor
|
73
|
+
if readcursor == 0
|
77
74
|
# Beginning of the bounce message or delivery status part
|
78
75
|
if e.include?(StartingOf[:message][0]) || e.include?(StartingOf[:message][1])
|
79
76
|
readcursor |= Indicators[:deliverystatus]
|
@@ -81,7 +78,7 @@ module Sisimai::Bite::Email
|
|
81
78
|
end
|
82
79
|
end
|
83
80
|
|
84
|
-
if (readcursor & Indicators[:'message-rfc822'])
|
81
|
+
if (readcursor & Indicators[:'message-rfc822']) == 0
|
85
82
|
# Beginning of the original message part
|
86
83
|
if e.start_with?(StartingOf[:rfc822][0], StartingOf[:rfc822][1])
|
87
84
|
readcursor |= Indicators[:'message-rfc822']
|
@@ -99,7 +96,7 @@ module Sisimai::Bite::Email
|
|
99
96
|
rfc822list << e
|
100
97
|
else
|
101
98
|
# Before "message/rfc822"
|
102
|
-
next if (readcursor & Indicators[:deliverystatus])
|
99
|
+
next if (readcursor & Indicators[:deliverystatus]) == 0
|
103
100
|
next if e.empty?
|
104
101
|
|
105
102
|
if connvalues == connheader.keys.size
|
@@ -176,41 +173,40 @@ module Sisimai::Bite::Email
|
|
176
173
|
# ---------------------------------------------------------------------------
|
177
174
|
if cv = e.match(/\A[>]{3}[ ]+([A-Z]{4})[ ]?/)
|
178
175
|
# >>> DATA
|
179
|
-
next
|
176
|
+
next unless commandtxt.empty?
|
180
177
|
commandtxt = cv[1]
|
181
178
|
|
182
179
|
elsif cv = e.match(/\AReporting-MTA:[ ]*(?:DNS|dns);[ ]*(.+)\z/)
|
183
180
|
# Reporting-MTA: dns; mx.example.jp
|
184
|
-
next
|
181
|
+
next unless connheader['rhost'].empty?
|
185
182
|
connheader['rhost'] = cv[1].downcase
|
186
183
|
connvalues += 1
|
187
184
|
|
188
185
|
elsif cv = e.match(/\AReceived-From-MTA:[ ]*(?:DNS|dns);[ ]*(.+)\z/)
|
189
186
|
# Received-From-MTA: DNS; x1x2x3x4.dhcp.example.ne.jp
|
190
|
-
next
|
187
|
+
next unless connheader['lhost'].empty?
|
191
188
|
connheader['lhost'] = cv[1].downcase
|
192
189
|
connvalues += 1
|
193
190
|
|
194
191
|
elsif cv = e.match(/\AArrival-Date:[ ]*(.+)\z/)
|
195
192
|
# Arrival-Date: Wed, 29 Apr 2009 16:03:18 +0900
|
196
|
-
next
|
193
|
+
next unless connheader['date'].empty?
|
197
194
|
connheader['date'] = cv[1]
|
198
195
|
connvalues += 1
|
199
196
|
end
|
200
197
|
end
|
201
198
|
end
|
202
199
|
end
|
203
|
-
return nil
|
200
|
+
return nil unless recipients > 0
|
204
201
|
|
205
|
-
|
206
|
-
dscontents.map do |e|
|
202
|
+
dscontents.each do |e|
|
207
203
|
# Set default values if each value is empty.
|
208
204
|
connheader.each_key { |a| e[a] ||= connheader[a] || '' }
|
209
205
|
e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
|
210
206
|
|
211
207
|
MessagesOf.each_key do |r|
|
212
208
|
# Verify each regular expression of session errors
|
213
|
-
next unless MessagesOf[r].
|
209
|
+
next unless MessagesOf[r].any? { |a| e['diagnosis'].include?(a) }
|
214
210
|
e['reason'] = r.to_s
|
215
211
|
break
|
216
212
|
end
|