sisimai 4.22.3-java → 4.22.4-java

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.

Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/Benchmarks.mk +54 -0
  4. data/ChangeLog.md +23 -2
  5. data/Developers.mk +42 -35
  6. data/Makefile +10 -0
  7. data/README-JA.md +13 -13
  8. data/README.md +14 -14
  9. data/lib/sisimai.rb +12 -18
  10. data/lib/sisimai/address.rb +64 -82
  11. data/lib/sisimai/arf.rb +27 -42
  12. data/lib/sisimai/bite/email.rb +2 -4
  13. data/lib/sisimai/bite/email/activehunter.rb +12 -17
  14. data/lib/sisimai/bite/email/amazonses.rb +30 -48
  15. data/lib/sisimai/bite/email/amazonworkmail.rb +20 -27
  16. data/lib/sisimai/bite/email/aol.rb +27 -35
  17. data/lib/sisimai/bite/email/apachejames.rb +17 -28
  18. data/lib/sisimai/bite/email/bigfoot.rb +20 -33
  19. data/lib/sisimai/bite/email/biglobe.rb +15 -24
  20. data/lib/sisimai/bite/email/courier.rb +37 -61
  21. data/lib/sisimai/bite/email/domino.rb +19 -28
  22. data/lib/sisimai/bite/email/einsundeins.rb +20 -34
  23. data/lib/sisimai/bite/email/exchange2003.rb +25 -43
  24. data/lib/sisimai/bite/email/exchange2007.rb +15 -23
  25. data/lib/sisimai/bite/email/exim.rb +101 -120
  26. data/lib/sisimai/bite/email/ezweb.rb +28 -44
  27. data/lib/sisimai/bite/email/facebook.rb +26 -37
  28. data/lib/sisimai/bite/email/fml.rb +11 -20
  29. data/lib/sisimai/bite/email/gmx.rb +17 -27
  30. data/lib/sisimai/bite/email/google.rb +19 -29
  31. data/lib/sisimai/bite/email/gsuite.rb +39 -48
  32. data/lib/sisimai/bite/email/imailserver.rb +25 -39
  33. data/lib/sisimai/bite/email/interscanmss.rb +19 -26
  34. data/lib/sisimai/bite/email/kddi.rb +20 -33
  35. data/lib/sisimai/bite/email/mailfoundry.rb +14 -24
  36. data/lib/sisimai/bite/email/mailmarshalsmtp.rb +15 -24
  37. data/lib/sisimai/bite/email/mailru.rb +40 -59
  38. data/lib/sisimai/bite/email/mcafee.rb +21 -35
  39. data/lib/sisimai/bite/email/messagelabs.rb +23 -38
  40. data/lib/sisimai/bite/email/messagingserver.rb +15 -27
  41. data/lib/sisimai/bite/email/mfilter.rb +19 -28
  42. data/lib/sisimai/bite/email/mxlogic.rb +31 -49
  43. data/lib/sisimai/bite/email/notes.rb +16 -24
  44. data/lib/sisimai/bite/email/office365.rb +29 -38
  45. data/lib/sisimai/bite/email/opensmtpd.rb +50 -67
  46. data/lib/sisimai/bite/email/outlook.rb +24 -36
  47. data/lib/sisimai/bite/email/postfix.rb +33 -42
  48. data/lib/sisimai/bite/email/qmail.rb +44 -59
  49. data/lib/sisimai/bite/email/receivingses.rb +28 -36
  50. data/lib/sisimai/bite/email/sendgrid.rb +28 -37
  51. data/lib/sisimai/bite/email/sendmail.rb +35 -51
  52. data/lib/sisimai/bite/email/surfcontrol.rb +17 -25
  53. data/lib/sisimai/bite/email/userdefined.rb +17 -28
  54. data/lib/sisimai/bite/email/v5sendmail.rb +32 -41
  55. data/lib/sisimai/bite/email/verizon.rb +31 -56
  56. data/lib/sisimai/bite/email/x1.rb +11 -18
  57. data/lib/sisimai/bite/email/x2.rb +11 -23
  58. data/lib/sisimai/bite/email/x3.rb +10 -19
  59. data/lib/sisimai/bite/email/x4.rb +46 -65
  60. data/lib/sisimai/bite/email/x5.rb +26 -37
  61. data/lib/sisimai/bite/email/yahoo.rb +11 -19
  62. data/lib/sisimai/bite/email/yandex.rb +19 -30
  63. data/lib/sisimai/bite/email/zoho.rb +21 -30
  64. data/lib/sisimai/bite/json.rb +1 -2
  65. data/lib/sisimai/bite/json/amazonses.rb +20 -25
  66. data/lib/sisimai/bite/json/sendgrid.rb +1 -1
  67. data/lib/sisimai/data.rb +36 -55
  68. data/lib/sisimai/data/json.rb +3 -3
  69. data/lib/sisimai/data/yaml.rb +1 -1
  70. data/lib/sisimai/datetime.rb +5 -21
  71. data/lib/sisimai/mail.rb +4 -6
  72. data/lib/sisimai/mail/maildir.rb +1 -1
  73. data/lib/sisimai/mda.rb +41 -44
  74. data/lib/sisimai/message.rb +2 -3
  75. data/lib/sisimai/message/email.rb +42 -52
  76. data/lib/sisimai/message/json.rb +7 -7
  77. data/lib/sisimai/mime.rb +25 -23
  78. data/lib/sisimai/order/email.rb +2 -2
  79. data/lib/sisimai/order/json.rb +2 -7
  80. data/lib/sisimai/reason.rb +41 -46
  81. data/lib/sisimai/reason/blocked.rb +60 -71
  82. data/lib/sisimai/reason/contenterror.rb +4 -8
  83. data/lib/sisimai/reason/delivered.rb +1 -3
  84. data/lib/sisimai/reason/exceedlimit.rb +10 -20
  85. data/lib/sisimai/reason/expired.rb +5 -9
  86. data/lib/sisimai/reason/feedback.rb +1 -3
  87. data/lib/sisimai/reason/filtered.rb +19 -38
  88. data/lib/sisimai/reason/hasmoved.rb +5 -8
  89. data/lib/sisimai/reason/hostunknown.rb +11 -18
  90. data/lib/sisimai/reason/mailboxfull.rb +14 -24
  91. data/lib/sisimai/reason/mailererror.rb +3 -5
  92. data/lib/sisimai/reason/mesgtoobig.rb +15 -25
  93. data/lib/sisimai/reason/networkerror.rb +8 -10
  94. data/lib/sisimai/reason/norelaying.rb +9 -14
  95. data/lib/sisimai/reason/notaccept.rb +9 -21
  96. data/lib/sisimai/reason/onhold.rb +3 -8
  97. data/lib/sisimai/reason/policyviolation.rb +8 -10
  98. data/lib/sisimai/reason/rejected.rb +36 -49
  99. data/lib/sisimai/reason/securityerror.rb +11 -13
  100. data/lib/sisimai/reason/spamdetected.rb +23 -37
  101. data/lib/sisimai/reason/suspend.rb +9 -10
  102. data/lib/sisimai/reason/syntaxerror.rb +3 -4
  103. data/lib/sisimai/reason/systemerror.rb +7 -9
  104. data/lib/sisimai/reason/systemfull.rb +2 -4
  105. data/lib/sisimai/reason/toomanyconn.rb +17 -30
  106. data/lib/sisimai/reason/undefined.rb +1 -3
  107. data/lib/sisimai/reason/userunknown.rb +28 -38
  108. data/lib/sisimai/reason/vacation.rb +4 -6
  109. data/lib/sisimai/reason/virusdetected.rb +4 -6
  110. data/lib/sisimai/rfc2606.rb +1 -2
  111. data/lib/sisimai/rfc3464.rb +87 -101
  112. data/lib/sisimai/rfc3834.rb +29 -39
  113. data/lib/sisimai/rfc5322.rb +17 -24
  114. data/lib/sisimai/rhost.rb +10 -7
  115. data/lib/sisimai/rhost/exchangeonline.rb +124 -255
  116. data/lib/sisimai/rhost/franceptt.rb +2 -2
  117. data/lib/sisimai/rhost/godaddy.rb +12 -25
  118. data/lib/sisimai/rhost/googleapps.rb +82 -183
  119. data/lib/sisimai/smtp.rb +4 -4
  120. data/lib/sisimai/smtp/error.rb +8 -8
  121. data/lib/sisimai/smtp/reply.rb +1 -1
  122. data/lib/sisimai/smtp/status.rb +1 -0
  123. data/lib/sisimai/string.rb +5 -7
  124. data/lib/sisimai/version.rb +1 -1
  125. data/set-of-emails/README.md +1 -1
  126. data/set-of-emails/maildir/bsd/README.md +50 -50
  127. data/sisimai-java.gemspec +1 -1
  128. data/sisimai.gemspec +1 -1
  129. metadata +4 -4
  130. data/lib/sisimai/skeleton.rb +0 -43
@@ -6,28 +6,11 @@ module Sisimai::Bite::Email
6
6
  class << self
7
7
  # Imported from p5-Sisimail/lib/Sisimai/Bite/Email/Verizon.pm
8
8
  require 'sisimai/bite/email'
9
-
10
- Re0 = {
11
- :'received' => %r/by .+[.]vtext[.]com /,
12
- :'vtext.com' => {
13
- :'from' => %r/\Apost_master[@]vtext[.]com\z/,
14
- },
15
- :'vzwpix.com' => {
16
- :'from' => %r/[<]?sysadmin[@].+[.]vzwpix[.]com[>]?\z/,
17
- :'subject' => %r/Undeliverable Message/,
18
- },
19
- }.freeze
20
9
  Indicators = Sisimai::Bite::Email.INDICATORS
21
10
 
22
11
  def description; return 'Verizon Wireless: http://www.verizonwireless.com'; end
23
12
  def smtpagent; return Sisimai::Bite.smtpagent(self); end
24
13
  def headerlist; return []; end
25
- def pattern
26
- return {
27
- :from => %r/(?:\Apost_master[@]vtext[.]com|[<]?sysadmin[@].+[.]vzwpix[.]com[>]?)\z/,
28
- :subject => Re0[:'vzwpix.com'][:subject],
29
- }
30
- end
31
14
 
32
15
  # Parse bounce messages from Verizon
33
16
  # @param [Hash] mhead Message headers of a bounce email
@@ -45,11 +28,12 @@ module Sisimai::Bite::Email
45
28
  return nil unless mbody
46
29
 
47
30
  match = -1
48
- loop do
31
+ while true
49
32
  # Check the value of "From" header
50
- break unless mhead['received'].find { |a| a =~ Re0[:received] }
51
- match = 1 if mhead['from'] =~ Re0[:'vtext.com'][:from]
52
- match = 0 if mhead['from'] =~ Re0[:'vzwpix.com'][:from]
33
+ # :'subject' => %r/Undeliverable Message/,
34
+ break unless mhead['received'].find { |a| a.include?('.vtext.com (') }
35
+ match = 1 if mhead['from'] == 'post_master@vtext.com'
36
+ match = 0 if mhead['from'] =~ /[<]?sysadmin[@].+[.]vzwpix[.]com[>]?\z/
53
37
  break
54
38
  end
55
39
  return nil if match < 0
@@ -65,33 +49,33 @@ module Sisimai::Bite::Email
65
49
  senderaddr = '' # (String) Sender address in the message body
66
50
  subjecttxt = '' # (String) Subject of the original message
67
51
 
68
- re1 = {} # (Ref->Hash) Delimiter patterns
69
- reFailure = {} # (Ref->Hash) Error message patterns
52
+ markingsof = {} # (Hash) Delimiter patterns
53
+ startingof = {} # (Hash) Delimiter strings
54
+ reFailures = {} # (Hash) Error message patterns
70
55
  boundary00 = '' # (String) Boundary string
71
56
  v = nil
72
57
 
73
58
  if match == 1
74
59
  # vtext.com
75
- re1 = {
76
- :begin => %r/\AError:[ \t]/,
77
- :rfc822 => %r/\A__BOUNDARY_STRING_HERE__\z/,
78
- :endof => %r/\A__END_OF_EMAIL_MESSAGE__\z/,
60
+ markingsof = {
61
+ message: %r/\AError:[ \t]/,
62
+ rfc822: %r/\A__BOUNDARY_STRING_HERE__\z/,
79
63
  }
80
- reFailure = {
64
+ reFailures = {
81
65
  # The attempted recipient address does not exist.
82
- userunknown: %r/550[ ][-][ ]Requested[ ]action[ ]not[ ]taken:[ ]no[ ]such[ ]user[ ]here/x,
66
+ userunknown: %r/550 [-] Requested action not taken: no such user here/,
83
67
  }
84
68
  boundary00 = Sisimai::MIME.boundary(mhead['content-type']) || ''
85
69
 
86
70
  if boundary00.size > 0
87
71
  # Convert to regular expression
88
- re1['rfc822'] = Regexp.new('\A' + Regexp.escape('--' + boundary00 + '--') + '\z')
72
+ markingsof[:rfc822] = Regexp.new('\A' << Regexp.escape('--' << boundary00 << '--') << '\z')
89
73
  end
90
74
 
91
- hasdivided.each do |e|
75
+ while e = hasdivided.shift do
92
76
  if readcursor.zero?
93
77
  # Beginning of the bounce message or delivery status part
94
- if e =~ re1[:begin]
78
+ if e =~ markingsof[:message]
95
79
  readcursor |= Indicators[:deliverystatus]
96
80
  next
97
81
  end
@@ -99,7 +83,7 @@ module Sisimai::Bite::Email
99
83
 
100
84
  if (readcursor & Indicators[:'message-rfc822']).zero?
101
85
  # Beginning of the original message part
102
- if e =~ re1[:rfc822]
86
+ if e =~ markingsof[:rfc822]
103
87
  readcursor |= Indicators[:'message-rfc822']
104
88
  next
105
89
  end
@@ -113,7 +97,6 @@ module Sisimai::Bite::Email
113
97
  next
114
98
  end
115
99
  rfc822list << e
116
-
117
100
  else
118
101
  # Before "message/rfc822"
119
102
  next if (readcursor & Indicators[:deliverystatus]).zero?
@@ -143,7 +126,6 @@ module Sisimai::Bite::Email
143
126
  elsif cv = e.match(/\A[ \t]+Subject:[ \t](.+)\z/)
144
127
  # Subject:
145
128
  subjecttxt = cv[1] if subjecttxt.empty?
146
-
147
129
  else
148
130
  # 550 - Requested action not taken: no such user here
149
131
  v['diagnosis'] = e if e =~ /\A(\d{3})[ \t][-][ \t](.*)\z/
@@ -153,24 +135,20 @@ module Sisimai::Bite::Email
153
135
 
154
136
  else
155
137
  # vzwpix.com
156
- re1 = {
157
- :begin => %r/\AMessage could not be delivered to mobile/,
158
- :rfc822 => %r/\A__BOUNDARY_STRING_HERE__\z/,
159
- :endof => %r/\A__END_OF_EMAIL_MESSAGE__\z/,
160
- }
161
- reFailure = {
162
- userunknown: %r/No[ ]valid[ ]recipients[ ]for[ ]this[ ]MM/x,
163
- }
138
+ startingof = { message: ['Message could not be delivered to mobile'] }
139
+ markingsof = { rfc822: %r/\A__BOUNDARY_STRING_HERE__\z/ }
140
+ reFailures = { userunknown: %r/No valid recipients for this MM/ }
164
141
  boundary00 = Sisimai::MIME.boundary(mhead['content-type'])
142
+
165
143
  if boundary00.size > 0
166
144
  # Convert to regular expression
167
- re1['rfc822'] = Regexp.new('\A' + Regexp.escape('--' + boundary00 + '--') + '\z')
145
+ markingsof[:rfc822] = Regexp.new('\A' << Regexp.escape('--' << boundary00 << '--') << '\z')
168
146
  end
169
147
 
170
- hasdivided.each do |e|
148
+ while e = hasdivided.shift do
171
149
  if readcursor.zero?
172
150
  # Beginning of the bounce message or delivery status part
173
- if e =~ re1[:begin]
151
+ if e.start_with?(startingof[:message][0])
174
152
  readcursor |= Indicators[:deliverystatus]
175
153
  next
176
154
  end
@@ -178,7 +156,7 @@ module Sisimai::Bite::Email
178
156
 
179
157
  if (readcursor & Indicators[:'message-rfc822']).zero?
180
158
  # Beginning of the original message part
181
- if e =~ re1[:rfc822]
159
+ if e =~ markingsof[:rfc822]
182
160
  readcursor |= Indicators[:'message-rfc822']
183
161
  next
184
162
  end
@@ -192,7 +170,6 @@ module Sisimai::Bite::Email
192
170
  next
193
171
  end
194
172
  rfc822list << e
195
-
196
173
  else
197
174
  # Before "message/rfc822"
198
175
  next if (readcursor & Indicators[:deliverystatus]).zero?
@@ -221,7 +198,6 @@ module Sisimai::Bite::Email
221
198
  elsif cv = e.match(/\ASubject:[ \t](.+)\z/)
222
199
  # Subject:
223
200
  subjecttxt = cv[1] if subjecttxt.empty?
224
-
225
201
  else
226
202
  # Message could not be delivered to mobile.
227
203
  # Error: No valid recipients for this MM
@@ -230,16 +206,15 @@ module Sisimai::Bite::Email
230
206
  end
231
207
  end
232
208
  end
233
-
234
209
  return nil if recipients.zero?
235
210
 
236
- if !rfc822list.find { |a| a =~ /^From: / }
211
+ if !rfc822list.find { |a| a.start_with?('From: ') }
237
212
  # Set the value of "MAIL FROM:" or "From:"
238
- rfc822list << sprintf('From: %s', senderaddr)
213
+ rfc822list << ('From: ' << senderaddr)
239
214
 
240
- elsif !rfc822list.find { |a| a =~ /^Subject: / }
215
+ elsif !rfc822list.find { |a| a.start_with?('Subject: ') }
241
216
  # Set the value of "Subject:"
242
- rfc822list << sprintf('Subject: %s', subjecttxt)
217
+ rfc822list << ('Subject: ' << subjecttxt)
243
218
  end
244
219
 
245
220
  require 'sisimai/string'
@@ -247,9 +222,9 @@ module Sisimai::Bite::Email
247
222
  e['agent'] = self.smtpagent
248
223
  e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
249
224
 
250
- reFailure.each_key do |r|
225
+ reFailures.each_key do |r|
251
226
  # Verify each regular expression of session errors
252
- next unless e['diagnosis'] =~ reFailure[r]
227
+ next unless e['diagnosis'] =~ reFailures[r]
253
228
  e['reason'] = r.to_s
254
229
  break
255
230
  end
@@ -6,21 +6,15 @@ module Sisimai::Bite::Email
6
6
  # Imported from p5-Sisimail/lib/Sisimai/Bite/Email/X1.pm
7
7
  require 'sisimai/bite/email'
8
8
 
9
- Re0 = {
10
- :from => %r/["]Mail Deliver System["] /,
11
- :subject => %r/\AReturned Mail: /,
12
- }.freeze
13
- Re1 = {
14
- :begin => %r/\AThe original message was received at (.+)\z/,
15
- :endof => %r/\A__END_OF_EMAIL_MESSAGE__\z/,
16
- :rfc822 => %r/\AReceived: from \d+[.]\d+[.]\d+[.]\d/,
17
- }.freeze
18
9
  Indicators = Sisimai::Bite::Email.INDICATORS
10
+ MarkingsOf = {
11
+ message: %r/\AThe original message was received at (.+)\z/,
12
+ rfc822: %r/\AReceived: from \d+[.]\d+[.]\d+[.]\d/,
13
+ }.freeze
19
14
 
20
15
  def description; return 'Unknown MTA #1'; end
21
16
  def smtpagent; return Sisimai::Bite.smtpagent(self); end
22
17
  def headerlist; return []; end
23
- def pattern; return Re0; end
24
18
 
25
19
  # Parse bounce messages from Unknown MTA #1
26
20
  # @param [Hash] mhead Message headers of a bounce email
@@ -36,8 +30,8 @@ module Sisimai::Bite::Email
36
30
  def scan(mhead, mbody)
37
31
  return nil unless mhead
38
32
  return nil unless mbody
39
- return nil unless mhead['subject'] =~ Re0[:subject]
40
- return nil unless mhead['from'] =~ Re0[:from]
33
+ return nil unless mhead['subject'].start_with?('Returned Mail: ')
34
+ return nil unless mhead['from'].include?('"Mail Deliver System" ')
41
35
 
42
36
  dscontents = [Sisimai::Bite.DELIVERYSTATUS]
43
37
  hasdivided = mbody.split("\n")
@@ -48,10 +42,10 @@ module Sisimai::Bite::Email
48
42
  datestring = '' # (String) Date string
49
43
  v = nil
50
44
 
51
- hasdivided.each do |e|
45
+ while e = hasdivided.shift do
52
46
  if readcursor.zero?
53
47
  # Beginning of the bounce message or delivery status part
54
- if e =~ Re1[:begin]
48
+ if e =~ MarkingsOf[:message]
55
49
  readcursor |= Indicators[:deliverystatus]
56
50
  next
57
51
  end
@@ -59,7 +53,7 @@ module Sisimai::Bite::Email
59
53
 
60
54
  if (readcursor & Indicators[:'message-rfc822']).zero?
61
55
  # Beginning of the original message part
62
- if e =~ Re1[:rfc822]
56
+ if e =~ MarkingsOf[:rfc822]
63
57
  readcursor |= Indicators[:'message-rfc822']
64
58
  next
65
59
  end
@@ -73,7 +67,6 @@ module Sisimai::Bite::Email
73
67
  next
74
68
  end
75
69
  rfc822list << e
76
-
77
70
  else
78
71
  # Before "message/rfc822"
79
72
  next if (readcursor & Indicators[:deliverystatus]).zero?
@@ -98,15 +91,15 @@ module Sisimai::Bite::Email
98
91
  v['diagnosis'] = cv[2]
99
92
  recipients += 1
100
93
 
101
- elsif cv = e.match(Re1[:begin])
94
+ elsif cv = e.match(MarkingsOf[:message])
102
95
  # The original message was received at Thu, 29 Apr 2010 23:34:45 +0900 (JST)
103
96
  datestring = cv[1]
104
97
  end
105
98
  end
106
99
  end
107
100
  return nil if recipients.zero?
108
- require 'sisimai/string'
109
101
 
102
+ require 'sisimai/string'
110
103
  dscontents.map do |e|
111
104
  e['agent'] = self.smtpagent
112
105
  e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
@@ -6,25 +6,15 @@ module Sisimai::Bite::Email
6
6
  # Imported from p5-Sisimail/lib/Sisimai/Bite/Email/X2.pm
7
7
  require 'sisimai/bite/email'
8
8
 
9
- Re0 = {
10
- :from => %r/MAILER-DAEMON[@]/,
11
- :subject => %r{\A(?>
12
- Delivery[ ]failure
13
- |fail(?:ure|ed)[ ]delivery
14
- )
15
- }x,
16
- }.freeze
17
- Re1 = {
18
- :begin => %r/\AUnable to deliver message to the following address/,
19
- :rfc822 => %r/\A--- Original message follows/,
20
- :endof => %r/\A__END_OF_EMAIL_MESSAGE__\z/,
21
- }.freeze
22
9
  Indicators = Sisimai::Bite::Email.INDICATORS
10
+ StartingOf = {
11
+ message: ['Unable to deliver message to the following address'],
12
+ rfc822: ['--- Original message follows'],
13
+ }.freeze
23
14
 
24
15
  def description; return 'Unknown MTA #2'; end
25
16
  def smtpagent; return Sisimai::Bite.smtpagent(self); end
26
17
  def headerlist; return []; end
27
- def pattern; return Re0; end
28
18
 
29
19
  # Parse bounce messages from Unknown MTA #2
30
20
  # @param [Hash] mhead Message headers of a bounce email
@@ -40,8 +30,8 @@ module Sisimai::Bite::Email
40
30
  def scan(mhead, mbody)
41
31
  return nil unless mhead
42
32
  return nil unless mbody
43
- return nil unless mhead['subject'] =~ Re0[:subject]
44
- return nil unless mhead['from'] =~ Re0[:from]
33
+ return nil unless mhead['from'].include?('MAILER-DAEMON@')
34
+ return nil unless mhead['subject'] =~ %r/\A(?>Delivery failure|fail(?:ure|ed) delivery)/
45
35
 
46
36
  dscontents = [Sisimai::Bite.DELIVERYSTATUS]
47
37
  hasdivided = mbody.split("\n")
@@ -51,10 +41,10 @@ module Sisimai::Bite::Email
51
41
  recipients = 0 # (Integer) The number of 'Final-Recipient' header
52
42
  v = nil
53
43
 
54
- hasdivided.each do |e|
44
+ while e = hasdivided.shift do
55
45
  if readcursor.zero?
56
46
  # Beginning of the bounce message or delivery status part
57
- if e =~ Re1[:begin]
47
+ if e.start_with?(StartingOf[:message][0])
58
48
  readcursor |= Indicators[:deliverystatus]
59
49
  next
60
50
  end
@@ -62,7 +52,7 @@ module Sisimai::Bite::Email
62
52
 
63
53
  if (readcursor & Indicators[:'message-rfc822']).zero?
64
54
  # Beginning of the original message part
65
- if e =~ Re1[:rfc822]
55
+ if e.start_with?(StartingOf[:rfc822][0])
66
56
  readcursor |= Indicators[:'message-rfc822']
67
57
  next
68
58
  end
@@ -76,7 +66,6 @@ module Sisimai::Bite::Email
76
66
  next
77
67
  end
78
68
  rfc822list << e
79
-
80
69
  else
81
70
  # Before "message/rfc822"
82
71
  next if (readcursor & Indicators[:deliverystatus]).zero?
@@ -98,17 +87,16 @@ module Sisimai::Bite::Email
98
87
  end
99
88
  v['recipient'] = cv[1]
100
89
  recipients += 1
101
-
102
90
  else
103
91
  # This user doesn't have a example.com account (kijitora@example.com) [0]
104
92
  v['diagnosis'] ||= ''
105
- v['diagnosis'] += ' ' + e
93
+ v['diagnosis'] << ' ' << e
106
94
  end
107
95
  end
108
96
  end
109
97
  return nil if recipients.zero?
110
- require 'sisimai/string'
111
98
 
99
+ require 'sisimai/string'
112
100
  dscontents.map do |e|
113
101
  e['agent'] = self.smtpagent
114
102
  e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
@@ -6,21 +6,15 @@ module Sisimai::Bite::Email
6
6
  # Imported from p5-Sisimail/lib/Sisimai/Bite/Email/X3.pm
7
7
  require 'sisimai/bite/email'
8
8
 
9
- Re0 = {
10
- :from => %r/\AMail Delivery System/,
11
- :subject => %r/\ADelivery status notification/,
12
- }.freeze
13
- Re1 = {
14
- :begin => %r/\A[ \t]+This is an automatically generated Delivery Status Notification/,
15
- :rfc822 => %r|\AContent-Type: message/rfc822|,
16
- :endof => %r/\A__END_OF_EMAIL_MESSAGE__\z/,
17
- }.freeze
18
9
  Indicators = Sisimai::Bite::Email.INDICATORS
10
+ StartingOf = {
11
+ message: [' This is an automatically generated Delivery Status Notification'],
12
+ rfc822: ['Content-Type: message/rfc822'],
13
+ }.freeze
19
14
 
20
15
  def description; return 'Unknown MTA #3'; end
21
16
  def smtpagent; return Sisimai::Bite.smtpagent(self); end
22
17
  def headerlist; return []; end
23
- def pattern; return Re0; end
24
18
 
25
19
  # Parse bounce messages from Unknown MTA #3
26
20
  # @param [Hash] mhead Message headers of a bounce email
@@ -36,8 +30,8 @@ module Sisimai::Bite::Email
36
30
  def scan(mhead, mbody)
37
31
  return nil unless mhead
38
32
  return nil unless mbody
39
- return nil unless mhead['subject'] =~ Re0[:subject]
40
- return nil unless mhead['from'] =~ Re0[:from]
33
+ return nil unless mhead['subject'].start_with?('Delivery status notification')
34
+ return nil unless mhead['from'].start_with?('Mail Delivery System')
41
35
 
42
36
  dscontents = [Sisimai::Bite.DELIVERYSTATUS]
43
37
  hasdivided = mbody.split("\n")
@@ -47,10 +41,10 @@ module Sisimai::Bite::Email
47
41
  recipients = 0 # (Integer) The number of 'Final-Recipient' header
48
42
  v = nil
49
43
 
50
- hasdivided.each do |e|
44
+ while e = hasdivided.shift do
51
45
  if readcursor.zero?
52
46
  # Beginning of the bounce message or delivery status part
53
- if e =~ Re1[:begin]
47
+ if e.include?(StartingOf[:message][0])
54
48
  readcursor |= Indicators[:deliverystatus]
55
49
  next
56
50
  end
@@ -58,7 +52,7 @@ module Sisimai::Bite::Email
58
52
 
59
53
  if (readcursor & Indicators[:'message-rfc822']).zero?
60
54
  # Beginning of the original message part
61
- if e =~ Re1[:rfc822]
55
+ if e.start_with?(StartingOf[:rfc822][0])
62
56
  readcursor |= Indicators[:'message-rfc822']
63
57
  next
64
58
  end
@@ -72,7 +66,6 @@ module Sisimai::Bite::Email
72
66
  next
73
67
  end
74
68
  rfc822list << e
75
-
76
69
  else
77
70
  # Before "message/rfc822"
78
71
  next if (readcursor & Indicators[:deliverystatus]).zero?
@@ -104,7 +97,6 @@ module Sisimai::Bite::Email
104
97
  end
105
98
  v['recipient'] = cv[1]
106
99
  recipients += 1
107
-
108
100
  else
109
101
  # Detect error message
110
102
  if cv = e.match(/\ASMTP:([^ ]+)[ ](.+)\z/)
@@ -119,11 +111,10 @@ module Sisimai::Bite::Email
119
111
  end
120
112
  end
121
113
  end
122
-
123
114
  return nil if recipients.zero?
115
+
124
116
  require 'sisimai/string'
125
117
  require 'sisimai/smtp/status'
126
-
127
118
  dscontents.map do |e|
128
119
  e['agent'] = self.smtpagent
129
120
  e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])