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
@@ -35,9 +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
|
-
|
41
38
|
# 1. Check some value in mhead using regular expression or "==" operator
|
42
39
|
# whether the bounce message should be parsed by this module or not.
|
43
40
|
# - Matched 1 or more values: Proceed to the step 2.
|
@@ -47,7 +44,7 @@ module Sisimai::Bite::Email
|
|
47
44
|
match += 1 if mhead['subject'].start_with?('Error Mail Report')
|
48
45
|
match += 1 if mhead['from'].include?('Mail System')
|
49
46
|
match += 1 if mhead['x-some-userdefined-header']
|
50
|
-
return nil
|
47
|
+
return nil unless match > 0
|
51
48
|
|
52
49
|
# 2. Parse message body(mbody) of the bounce message. See some modules
|
53
50
|
# in lib/sisimai/bite/email directory to implement codes.
|
@@ -59,7 +56,7 @@ module Sisimai::Bite::Email
|
|
59
56
|
recipients = 0 # (Integer) The number of 'Final-Recipient' header
|
60
57
|
|
61
58
|
while e = hasdivided.shift do
|
62
|
-
if readcursor
|
59
|
+
if readcursor == 0
|
63
60
|
# Beginning of the bounce message or delivery status part
|
64
61
|
if e =~ MarkingsOf[:message]
|
65
62
|
readcursor |= Indicators[:deliverystatus]
|
@@ -67,7 +64,7 @@ module Sisimai::Bite::Email
|
|
67
64
|
end
|
68
65
|
end
|
69
66
|
|
70
|
-
if (readcursor & Indicators[:'message-rfc822'])
|
67
|
+
if (readcursor & Indicators[:'message-rfc822']) == 0
|
71
68
|
# Beginning of the original message part
|
72
69
|
if e =~ MarkingsOf[:rfc822]
|
73
70
|
readcursor |= Indicators[:'message-rfc822']
|
@@ -85,7 +82,7 @@ module Sisimai::Bite::Email
|
|
85
82
|
rfc822list << e
|
86
83
|
else
|
87
84
|
# Before "message/rfc822"
|
88
|
-
next if (readcursor & Indicators[:deliverystatus])
|
85
|
+
next if (readcursor & Indicators[:deliverystatus]) == 0
|
89
86
|
next if e.empty?
|
90
87
|
end
|
91
88
|
end
|
@@ -105,7 +102,7 @@ module Sisimai::Bite::Email
|
|
105
102
|
|
106
103
|
# 3. Return nil when there is no recipient address which is failed to
|
107
104
|
# delivery in the bounce message
|
108
|
-
return nil
|
105
|
+
return nil unless recipients > 0
|
109
106
|
|
110
107
|
# 4. Return the following variable.
|
111
108
|
rfc822part = Sisimai::RFC5322.weedout(rfc822list)
|
@@ -50,9 +50,6 @@ module Sisimai::Bite::Email
|
|
50
50
|
# part or nil if it failed to parse or
|
51
51
|
# the arguments are missing
|
52
52
|
def scan(mhead, mbody)
|
53
|
-
return nil unless mhead
|
54
|
-
return nil unless mbody
|
55
|
-
|
56
53
|
# :from => %r/\AMail Delivery Subsystem/,
|
57
54
|
return nil unless mhead['subject'] =~ /\AReturned mail: [A-Z]/
|
58
55
|
|
@@ -69,7 +66,7 @@ module Sisimai::Bite::Email
|
|
69
66
|
v = nil
|
70
67
|
|
71
68
|
while e = hasdivided.shift do
|
72
|
-
if readcursor
|
69
|
+
if readcursor == 0
|
73
70
|
# Beginning of the bounce message or delivery status part
|
74
71
|
if e.include?(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 =~ MarkingsOf[:rfc822]
|
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
|
# ----- Transcript of session follows -----
|
@@ -147,9 +144,9 @@ module Sisimai::Bite::Email
|
|
147
144
|
end
|
148
145
|
end
|
149
146
|
end
|
150
|
-
return nil if (readcursor & Indicators[:'message-rfc822'])
|
147
|
+
return nil if (readcursor & Indicators[:'message-rfc822']) == 0
|
151
148
|
|
152
|
-
if recipients
|
149
|
+
if recipients == 0
|
153
150
|
# Get the recipient address from the original message
|
154
151
|
rfc822list.each do |e|
|
155
152
|
next unless cv = e.match(/^To: (.+)$/m)
|
@@ -160,10 +157,9 @@ module Sisimai::Bite::Email
|
|
160
157
|
break
|
161
158
|
end
|
162
159
|
end
|
163
|
-
return nil
|
160
|
+
return nil unless recipients > 0
|
164
161
|
|
165
|
-
|
166
|
-
dscontents.map do |e|
|
162
|
+
dscontents.each do |e|
|
167
163
|
errorindex += 1
|
168
164
|
e['agent'] = self.smtpagent
|
169
165
|
e['command'] = commandset[errorindex] || ''
|
@@ -24,22 +24,17 @@ module Sisimai::Bite::Email
|
|
24
24
|
# part or nil if it failed to parse or
|
25
25
|
# the arguments are missing
|
26
26
|
def scan(mhead, mbody)
|
27
|
-
return nil unless mhead
|
28
|
-
return nil unless mbody
|
29
|
-
|
30
27
|
match = -1
|
31
28
|
while true
|
32
29
|
# Check the value of "From" header
|
33
30
|
# :'subject' => %r/Undeliverable Message/,
|
34
|
-
break unless mhead['received'].
|
31
|
+
break unless mhead['received'].any? { |a| a.include?('.vtext.com (') }
|
35
32
|
match = 1 if mhead['from'] == 'post_master@vtext.com'
|
36
33
|
match = 0 if mhead['from'] =~ /[<]?sysadmin[@].+[.]vzwpix[.]com[>]?\z/
|
37
34
|
break
|
38
35
|
end
|
39
36
|
return nil if match < 0
|
40
37
|
|
41
|
-
require 'sisimai/mime'
|
42
|
-
require 'sisimai/address'
|
43
38
|
dscontents = [Sisimai::Bite.DELIVERYSTATUS]
|
44
39
|
hasdivided = mbody.split("\n")
|
45
40
|
rfc822list = [] # (Array) Each line in message/rfc822 part string
|
@@ -66,14 +61,10 @@ module Sisimai::Bite::Email
|
|
66
61
|
userunknown: ['550 - Requested action not taken: no such user here'],
|
67
62
|
}
|
68
63
|
boundary00 = Sisimai::MIME.boundary(mhead['content-type']) || ''
|
69
|
-
|
70
|
-
if boundary00.size > 0
|
71
|
-
# Convert to regular expression
|
72
|
-
markingsof[:rfc822] = Regexp.new('\A' << Regexp.escape('--' << boundary00 << '--') << '\z')
|
73
|
-
end
|
64
|
+
markingsof[:rfc822] = Regexp.new('\A' << Regexp.escape('--' << boundary00 << '--') << '\z') unless boundary00.empty?
|
74
65
|
|
75
66
|
while e = hasdivided.shift do
|
76
|
-
if readcursor
|
67
|
+
if readcursor == 0
|
77
68
|
# Beginning of the bounce message or delivery status part
|
78
69
|
if e =~ markingsof[:message]
|
79
70
|
readcursor |= Indicators[:deliverystatus]
|
@@ -81,7 +72,7 @@ module Sisimai::Bite::Email
|
|
81
72
|
end
|
82
73
|
end
|
83
74
|
|
84
|
-
if (readcursor & Indicators[:'message-rfc822'])
|
75
|
+
if (readcursor & Indicators[:'message-rfc822']) == 0
|
85
76
|
# Beginning of the original message part
|
86
77
|
if e =~ markingsof[:rfc822]
|
87
78
|
readcursor |= Indicators[:'message-rfc822']
|
@@ -99,7 +90,7 @@ module Sisimai::Bite::Email
|
|
99
90
|
rfc822list << e
|
100
91
|
else
|
101
92
|
# Before "message/rfc822"
|
102
|
-
next if (readcursor & Indicators[:deliverystatus])
|
93
|
+
next if (readcursor & Indicators[:deliverystatus]) == 0
|
103
94
|
next if e.empty?
|
104
95
|
|
105
96
|
# Message details:
|
@@ -139,14 +130,10 @@ module Sisimai::Bite::Email
|
|
139
130
|
markingsof = { rfc822: %r/\A__BOUNDARY_STRING_HERE__\z/ }
|
140
131
|
messagesof = { userunknown: ['No valid recipients for this MM'] }
|
141
132
|
boundary00 = Sisimai::MIME.boundary(mhead['content-type'])
|
142
|
-
|
143
|
-
if boundary00.size > 0
|
144
|
-
# Convert to regular expression
|
145
|
-
markingsof[:rfc822] = Regexp.new('\A' << Regexp.escape('--' << boundary00 << '--') << '\z')
|
146
|
-
end
|
133
|
+
markingsof[:rfc822] = Regexp.new('\A' << Regexp.escape('--' << boundary00 << '--') << '\z') unless boundary00.empty?
|
147
134
|
|
148
135
|
while e = hasdivided.shift do
|
149
|
-
if readcursor
|
136
|
+
if readcursor == 0
|
150
137
|
# Beginning of the bounce message or delivery status part
|
151
138
|
if e.start_with?(startingof[:message][0])
|
152
139
|
readcursor |= Indicators[:deliverystatus]
|
@@ -154,7 +141,7 @@ module Sisimai::Bite::Email
|
|
154
141
|
end
|
155
142
|
end
|
156
143
|
|
157
|
-
if (readcursor & Indicators[:'message-rfc822'])
|
144
|
+
if (readcursor & Indicators[:'message-rfc822']) == 0
|
158
145
|
# Beginning of the original message part
|
159
146
|
if e =~ markingsof[:rfc822]
|
160
147
|
readcursor |= Indicators[:'message-rfc822']
|
@@ -172,7 +159,7 @@ module Sisimai::Bite::Email
|
|
172
159
|
rfc822list << e
|
173
160
|
else
|
174
161
|
# Before "message/rfc822"
|
175
|
-
next if (readcursor & Indicators[:deliverystatus])
|
162
|
+
next if (readcursor & Indicators[:deliverystatus]) == 0
|
176
163
|
next if e.empty?
|
177
164
|
|
178
165
|
# Original Message:
|
@@ -206,25 +193,24 @@ module Sisimai::Bite::Email
|
|
206
193
|
end
|
207
194
|
end
|
208
195
|
end
|
209
|
-
return nil
|
196
|
+
return nil unless recipients > 0
|
210
197
|
|
211
|
-
if
|
198
|
+
if rfc822list.none? { |a| a.start_with?('From: ') }
|
212
199
|
# Set the value of "MAIL FROM:" or "From:"
|
213
200
|
rfc822list << ('From: ' << senderaddr)
|
214
201
|
|
215
|
-
elsif
|
202
|
+
elsif rfc822list.none? { |a| a.start_with?('Subject: ') }
|
216
203
|
# Set the value of "Subject:"
|
217
204
|
rfc822list << ('Subject: ' << subjecttxt)
|
218
205
|
end
|
219
206
|
|
220
|
-
|
221
|
-
dscontents.map do |e|
|
207
|
+
dscontents.each do |e|
|
222
208
|
e['agent'] = self.smtpagent
|
223
209
|
e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
|
224
210
|
|
225
211
|
messagesof.each_key do |r|
|
226
212
|
# Verify each regular expression of session errors
|
227
|
-
next unless messagesof[r].
|
213
|
+
next unless messagesof[r].any? { |a| e['diagnosis'].include?(a) }
|
228
214
|
e['reason'] = r.to_s
|
229
215
|
break
|
230
216
|
end
|
@@ -28,8 +28,6 @@ module Sisimai::Bite::Email
|
|
28
28
|
# part or nil if it failed to parse or
|
29
29
|
# the arguments are missing
|
30
30
|
def scan(mhead, mbody)
|
31
|
-
return nil unless mhead
|
32
|
-
return nil unless mbody
|
33
31
|
return nil unless mhead['subject'].start_with?('Returned Mail: ')
|
34
32
|
return nil unless mhead['from'].start_with?('"Mail Deliver System" ')
|
35
33
|
|
@@ -43,7 +41,7 @@ module Sisimai::Bite::Email
|
|
43
41
|
v = nil
|
44
42
|
|
45
43
|
while e = hasdivided.shift do
|
46
|
-
if readcursor
|
44
|
+
if readcursor == 0
|
47
45
|
# Beginning of the bounce message or delivery status part
|
48
46
|
if e =~ MarkingsOf[:message]
|
49
47
|
readcursor |= Indicators[:deliverystatus]
|
@@ -51,7 +49,7 @@ module Sisimai::Bite::Email
|
|
51
49
|
end
|
52
50
|
end
|
53
51
|
|
54
|
-
if (readcursor & Indicators[:'message-rfc822'])
|
52
|
+
if (readcursor & Indicators[:'message-rfc822']) == 0
|
55
53
|
# Beginning of the original message part
|
56
54
|
if e =~ MarkingsOf[:rfc822]
|
57
55
|
readcursor |= Indicators[:'message-rfc822']
|
@@ -69,7 +67,7 @@ module Sisimai::Bite::Email
|
|
69
67
|
rfc822list << e
|
70
68
|
else
|
71
69
|
# Before "message/rfc822"
|
72
|
-
next if (readcursor & Indicators[:deliverystatus])
|
70
|
+
next if (readcursor & Indicators[:deliverystatus]) == 0
|
73
71
|
next if e.empty?
|
74
72
|
|
75
73
|
# The original message was received at Thu, 29 Apr 2010 23:34:45 +0900 (JST)
|
@@ -97,10 +95,9 @@ module Sisimai::Bite::Email
|
|
97
95
|
end
|
98
96
|
end
|
99
97
|
end
|
100
|
-
return nil
|
98
|
+
return nil unless recipients > 0
|
101
99
|
|
102
|
-
|
103
|
-
dscontents.map do |e|
|
100
|
+
dscontents.each do |e|
|
104
101
|
e['agent'] = self.smtpagent
|
105
102
|
e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
|
106
103
|
e['date'] = datestring || ''
|
@@ -28,8 +28,6 @@ module Sisimai::Bite::Email
|
|
28
28
|
# part or nil if it failed to parse or
|
29
29
|
# the arguments are missing
|
30
30
|
def scan(mhead, mbody)
|
31
|
-
return nil unless mhead
|
32
|
-
return nil unless mbody
|
33
31
|
return nil unless mhead['from'].include?('MAILER-DAEMON@')
|
34
32
|
return nil unless mhead['subject'] =~ %r/\A(?>Delivery failure|fail(?:ure|ed) delivery)/
|
35
33
|
|
@@ -42,7 +40,7 @@ module Sisimai::Bite::Email
|
|
42
40
|
v = nil
|
43
41
|
|
44
42
|
while e = hasdivided.shift do
|
45
|
-
if readcursor
|
43
|
+
if readcursor == 0
|
46
44
|
# Beginning of the bounce message or delivery status part
|
47
45
|
if e.start_with?(StartingOf[:message][0])
|
48
46
|
readcursor |= Indicators[:deliverystatus]
|
@@ -50,7 +48,7 @@ module Sisimai::Bite::Email
|
|
50
48
|
end
|
51
49
|
end
|
52
50
|
|
53
|
-
if (readcursor & Indicators[:'message-rfc822'])
|
51
|
+
if (readcursor & Indicators[:'message-rfc822']) == 0
|
54
52
|
# Beginning of the original message part
|
55
53
|
if e.start_with?(StartingOf[:rfc822][0])
|
56
54
|
readcursor |= Indicators[:'message-rfc822']
|
@@ -68,7 +66,7 @@ module Sisimai::Bite::Email
|
|
68
66
|
rfc822list << e
|
69
67
|
else
|
70
68
|
# Before "message/rfc822"
|
71
|
-
next if (readcursor & Indicators[:deliverystatus])
|
69
|
+
next if (readcursor & Indicators[:deliverystatus]) == 0
|
72
70
|
next if e.empty?
|
73
71
|
|
74
72
|
# Message from example.com.
|
@@ -94,10 +92,9 @@ module Sisimai::Bite::Email
|
|
94
92
|
end
|
95
93
|
end
|
96
94
|
end
|
97
|
-
return nil
|
95
|
+
return nil unless recipients > 0
|
98
96
|
|
99
|
-
|
100
|
-
dscontents.map do |e|
|
97
|
+
dscontents.each do |e|
|
101
98
|
e['agent'] = self.smtpagent
|
102
99
|
e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
|
103
100
|
e.each_key { |a| e[a] ||= '' }
|
@@ -28,8 +28,6 @@ module Sisimai::Bite::Email
|
|
28
28
|
# part or nil if it failed to parse or
|
29
29
|
# the arguments are missing
|
30
30
|
def scan(mhead, mbody)
|
31
|
-
return nil unless mhead
|
32
|
-
return nil unless mbody
|
33
31
|
return nil unless mhead['subject'].start_with?('Delivery status notification')
|
34
32
|
return nil unless mhead['from'].start_with?('Mail Delivery System')
|
35
33
|
|
@@ -42,7 +40,7 @@ module Sisimai::Bite::Email
|
|
42
40
|
v = nil
|
43
41
|
|
44
42
|
while e = hasdivided.shift do
|
45
|
-
if readcursor
|
43
|
+
if readcursor == 0
|
46
44
|
# Beginning of the bounce message or delivery status part
|
47
45
|
if e.start_with?(StartingOf[:message][0])
|
48
46
|
readcursor |= Indicators[:deliverystatus]
|
@@ -50,7 +48,7 @@ module Sisimai::Bite::Email
|
|
50
48
|
end
|
51
49
|
end
|
52
50
|
|
53
|
-
if (readcursor & Indicators[:'message-rfc822'])
|
51
|
+
if (readcursor & Indicators[:'message-rfc822']) == 0
|
54
52
|
# Beginning of the original message part
|
55
53
|
if e.start_with?(StartingOf[:rfc822][0])
|
56
54
|
readcursor |= Indicators[:'message-rfc822']
|
@@ -68,7 +66,7 @@ module Sisimai::Bite::Email
|
|
68
66
|
rfc822list << e
|
69
67
|
else
|
70
68
|
# Before "message/rfc822"
|
71
|
-
next if (readcursor & Indicators[:deliverystatus])
|
69
|
+
next if (readcursor & Indicators[:deliverystatus]) == 0
|
72
70
|
next if e.empty?
|
73
71
|
|
74
72
|
# ============================================================================
|
@@ -111,11 +109,9 @@ module Sisimai::Bite::Email
|
|
111
109
|
end
|
112
110
|
end
|
113
111
|
end
|
114
|
-
return nil
|
112
|
+
return nil unless recipients > 0
|
115
113
|
|
116
|
-
|
117
|
-
require 'sisimai/smtp/status'
|
118
|
-
dscontents.map do |e|
|
114
|
+
dscontents.each do |e|
|
119
115
|
e['agent'] = self.smtpagent
|
120
116
|
e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
|
121
117
|
e['status'] = Sisimai::SMTP::Status.find(e['diagnosis'])
|
@@ -135,9 +135,6 @@ module Sisimai::Bite::Email
|
|
135
135
|
# part or nil if it failed to parse or
|
136
136
|
# the arguments are missing
|
137
137
|
def scan(mhead, mbody)
|
138
|
-
return nil unless mhead
|
139
|
-
return nil unless mbody
|
140
|
-
|
141
138
|
# Pre process email headers and the body part of the message which generated
|
142
139
|
# by qmail, see http://cr.yp.to/qmail.html
|
143
140
|
# e.g.) Received: (qmail 12345 invoked for bounce); 29 Apr 2009 12:34:56 -0000
|
@@ -145,8 +142,8 @@ module Sisimai::Bite::Email
|
|
145
142
|
tryto = %r/\A[(]qmail[ ]+\d+[ ]+invoked[ ]+for[ ]+bounce[)]/
|
146
143
|
match = 0
|
147
144
|
match += 1 if mhead['subject'].start_with?('failure notice', 'Permanent Delivery Failure')
|
148
|
-
match += 1 if mhead['received'].
|
149
|
-
return nil
|
145
|
+
match += 1 if mhead['received'].any? { |a| a =~ tryto }
|
146
|
+
return nil unless match > 0
|
150
147
|
|
151
148
|
dscontents = [Sisimai::Bite.DELIVERYSTATUS]
|
152
149
|
hasdivided = mbody.split("\n")
|
@@ -157,7 +154,7 @@ module Sisimai::Bite::Email
|
|
157
154
|
v = nil
|
158
155
|
|
159
156
|
while e = hasdivided.shift do
|
160
|
-
if readcursor
|
157
|
+
if readcursor == 0
|
161
158
|
# Beginning of the bounce message or delivery status part
|
162
159
|
if e =~ MarkingsOf[:message]
|
163
160
|
readcursor |= Indicators[:deliverystatus]
|
@@ -165,7 +162,7 @@ module Sisimai::Bite::Email
|
|
165
162
|
end
|
166
163
|
end
|
167
164
|
|
168
|
-
if (readcursor & Indicators[:'message-rfc822'])
|
165
|
+
if (readcursor & Indicators[:'message-rfc822']) == 0
|
169
166
|
# Beginning of the original message part
|
170
167
|
if e.start_with?(StartingOf[:rfc822][0], StartingOf[:rfc822][1])
|
171
168
|
readcursor |= Indicators[:'message-rfc822']
|
@@ -183,7 +180,7 @@ module Sisimai::Bite::Email
|
|
183
180
|
rfc822list << e
|
184
181
|
else
|
185
182
|
# Before "message/rfc822"
|
186
|
-
next if (readcursor & Indicators[:deliverystatus])
|
183
|
+
next if (readcursor & Indicators[:deliverystatus]) == 0
|
187
184
|
next if e.empty?
|
188
185
|
|
189
186
|
# <kijitora@example.jp>:
|
@@ -216,10 +213,9 @@ module Sisimai::Bite::Email
|
|
216
213
|
end
|
217
214
|
end
|
218
215
|
end
|
219
|
-
return nil
|
216
|
+
return nil unless recipients > 0
|
220
217
|
|
221
|
-
|
222
|
-
dscontents.map do |e|
|
218
|
+
dscontents.each do |e|
|
223
219
|
e['agent'] = self.smtpagent
|
224
220
|
e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
|
225
221
|
|
@@ -260,12 +256,12 @@ module Sisimai::Bite::Email
|
|
260
256
|
# Verify each regular expression of session errors
|
261
257
|
if e['alterrors']
|
262
258
|
# Check the value of "alterrors"
|
263
|
-
next unless MessagesOf[r].
|
259
|
+
next unless MessagesOf[r].any? { |a| e['alterrors'].include?(a) }
|
264
260
|
e['reason'] = r.to_s
|
265
261
|
end
|
266
262
|
break if e['reason']
|
267
263
|
|
268
|
-
next unless MessagesOf[r].
|
264
|
+
next unless MessagesOf[r].any? { |a| e['diagnosis'].include?(a) }
|
269
265
|
e['reason'] = r.to_s
|
270
266
|
break
|
271
267
|
end
|
@@ -273,7 +269,7 @@ module Sisimai::Bite::Email
|
|
273
269
|
unless e['reason']
|
274
270
|
FailOnLDAP.each_key do |r|
|
275
271
|
# Verify each regular expression of LDAP errors
|
276
|
-
next unless FailOnLDAP[r].
|
272
|
+
next unless FailOnLDAP[r].any? { |a| e['diagnosis'].include?(a) }
|
277
273
|
e['reason'] = r.to_s
|
278
274
|
break
|
279
275
|
end
|