sisimai 4.16.0-java → 4.17.0-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 (110) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/ANALYTICAL-PRECISION +7 -7
  4. data/Changes +15 -0
  5. data/Makefile +1 -1
  6. data/README.md +30 -28
  7. data/lib/sisimai.rb +20 -1
  8. data/lib/sisimai/address.rb +28 -9
  9. data/lib/sisimai/arf.rb +37 -46
  10. data/lib/sisimai/data.rb +67 -43
  11. data/lib/sisimai/datetime.rb +210 -210
  12. data/lib/sisimai/mda.rb +30 -30
  13. data/lib/sisimai/message.rb +3 -5
  14. data/lib/sisimai/msp/de/einsundeins.rb +14 -42
  15. data/lib/sisimai/msp/de/gmx.rb +17 -44
  16. data/lib/sisimai/msp/jp/biglobe.rb +15 -44
  17. data/lib/sisimai/msp/jp/ezweb.rb +20 -50
  18. data/lib/sisimai/msp/jp/kddi.rb +16 -43
  19. data/lib/sisimai/msp/ru/mailru.rb +20 -48
  20. data/lib/sisimai/msp/ru/yandex.rb +16 -50
  21. data/lib/sisimai/msp/uk/messagelabs.rb +17 -51
  22. data/lib/sisimai/msp/us/amazonses.rb +18 -40
  23. data/lib/sisimai/msp/us/amazonworkmail.rb +17 -35
  24. data/lib/sisimai/msp/us/aol.rb +17 -41
  25. data/lib/sisimai/msp/us/bigfoot.rb +15 -48
  26. data/lib/sisimai/msp/us/facebook.rb +63 -90
  27. data/lib/sisimai/msp/us/google.rb +15 -44
  28. data/lib/sisimai/msp/us/office365.rb +21 -46
  29. data/lib/sisimai/msp/us/outlook.rb +17 -50
  30. data/lib/sisimai/msp/us/receivingses.rb +20 -43
  31. data/lib/sisimai/msp/us/sendgrid.rb +13 -37
  32. data/lib/sisimai/msp/us/verizon.rb +30 -74
  33. data/lib/sisimai/msp/us/yahoo.rb +12 -40
  34. data/lib/sisimai/msp/us/zoho.rb +14 -42
  35. data/lib/sisimai/mta/activehunter.rb +11 -40
  36. data/lib/sisimai/mta/apachejames.rb +18 -40
  37. data/lib/sisimai/mta/courier.rb +20 -57
  38. data/lib/sisimai/mta/domino.rb +24 -56
  39. data/lib/sisimai/mta/exchange.rb +26 -54
  40. data/lib/sisimai/mta/exim.rb +20 -39
  41. data/lib/sisimai/mta/imailserver.rb +26 -71
  42. data/lib/sisimai/mta/interscanmss.rb +26 -44
  43. data/lib/sisimai/mta/mailfoundry.rb +12 -42
  44. data/lib/sisimai/mta/mailmarshalsmtp.rb +13 -43
  45. data/lib/sisimai/mta/mcafee.rb +17 -46
  46. data/lib/sisimai/mta/messagingserver.rb +14 -47
  47. data/lib/sisimai/mta/mfilter.rb +12 -35
  48. data/lib/sisimai/mta/mxlogic.rb +18 -42
  49. data/lib/sisimai/mta/notes.rb +22 -45
  50. data/lib/sisimai/mta/opensmtpd.rb +18 -48
  51. data/lib/sisimai/mta/postfix.rb +15 -45
  52. data/lib/sisimai/mta/qmail.rb +32 -60
  53. data/lib/sisimai/mta/sendmail.rb +13 -38
  54. data/lib/sisimai/mta/surfcontrol.rb +15 -44
  55. data/lib/sisimai/mta/userdefined.rb +14 -30
  56. data/lib/sisimai/mta/v5sendmail.rb +18 -40
  57. data/lib/sisimai/mta/x1.rb +12 -41
  58. data/lib/sisimai/mta/x2.rb +12 -41
  59. data/lib/sisimai/mta/x3.rb +12 -39
  60. data/lib/sisimai/mta/x4.rb +33 -66
  61. data/lib/sisimai/mta/x5.rb +15 -42
  62. data/lib/sisimai/reason.rb +8 -71
  63. data/lib/sisimai/reason/blocked.rb +3 -0
  64. data/lib/sisimai/reason/contenterror.rb +3 -0
  65. data/lib/sisimai/reason/delivered.rb +27 -0
  66. data/lib/sisimai/reason/exceedlimit.rb +3 -0
  67. data/lib/sisimai/reason/expired.rb +3 -0
  68. data/lib/sisimai/reason/feedback.rb +18 -0
  69. data/lib/sisimai/reason/filtered.rb +4 -0
  70. data/lib/sisimai/reason/hasmoved.rb +3 -0
  71. data/lib/sisimai/reason/hostunknown.rb +3 -0
  72. data/lib/sisimai/reason/mailboxfull.rb +3 -0
  73. data/lib/sisimai/reason/mailererror.rb +3 -0
  74. data/lib/sisimai/reason/mesgtoobig.rb +3 -0
  75. data/lib/sisimai/reason/networkerror.rb +3 -0
  76. data/lib/sisimai/reason/norelaying.rb +3 -0
  77. data/lib/sisimai/reason/notaccept.rb +3 -0
  78. data/lib/sisimai/reason/onhold.rb +3 -0
  79. data/lib/sisimai/reason/rejected.rb +3 -0
  80. data/lib/sisimai/reason/securityerror.rb +3 -0
  81. data/lib/sisimai/reason/spamdetected.rb +3 -0
  82. data/lib/sisimai/reason/suspend.rb +3 -0
  83. data/lib/sisimai/reason/syntaxerror.rb +41 -0
  84. data/lib/sisimai/reason/systemerror.rb +3 -0
  85. data/lib/sisimai/reason/systemfull.rb +3 -0
  86. data/lib/sisimai/reason/toomanyconn.rb +3 -0
  87. data/lib/sisimai/reason/undefined.rb +18 -0
  88. data/lib/sisimai/reason/userunknown.rb +3 -0
  89. data/lib/sisimai/reason/vacation.rb +18 -0
  90. data/lib/sisimai/rfc3464.rb +15 -40
  91. data/lib/sisimai/rfc3834.rb +1 -10
  92. data/lib/sisimai/rfc5322.rb +57 -19
  93. data/lib/sisimai/rhost/googleapps.rb +82 -82
  94. data/lib/sisimai/smtp/reply.rb +2 -1
  95. data/lib/sisimai/smtp/status.rb +154 -152
  96. data/lib/sisimai/string.rb +2 -3
  97. data/lib/sisimai/version.rb +1 -1
  98. data/set-of-emails/maildir/bsd/rfc3464-29.eml +60 -0
  99. data/set-of-emails/maildir/bsd/us-amazonworkmail-06.eml +156 -0
  100. data/set-of-emails/maildir/bsd/us-amazonworkmail-07.eml +158 -0
  101. data/set-of-emails/maildir/bsd/us-google-15.eml +97 -0
  102. data/set-of-emails/maildir/bsd/us-google-16.eml +99 -0
  103. data/set-of-emails/maildir/bsd/us-google-17.eml +104 -0
  104. data/set-of-emails/maildir/dos/apachejames-01.eml +4 -4
  105. data/set-of-emails/maildir/dos/us-amazonworkmail-01.eml +156 -0
  106. data/set-of-emails/maildir/dos/us-office365-01.eml +102 -0
  107. data/set-of-emails/maildir/mac/apachejames-01.eml +1 -9
  108. data/set-of-emails/maildir/mac/us-amazonworkmail-01.eml +1 -7
  109. data/set-of-emails/maildir/mac/us-office365-01.eml +1 -4
  110. metadata +17 -2
@@ -19,8 +19,6 @@ module Sisimai
19
19
  :endof => %r/\A__END_OF_EMAIL_MESSAGE__\z/,
20
20
  }
21
21
  Indicators = Sisimai::MSP.INDICATORS
22
- LongFields = Sisimai::RFC5322.LONGFIELDS
23
- RFC822Head = Sisimai::RFC5322.HEADERFIELDS
24
22
 
25
23
  def description; return 'Bigfoot: http://www.bigfoot.com'; end
26
24
  def smtpagent; return 'US::Bigfoot'; end
@@ -48,12 +46,11 @@ module Sisimai
48
46
  return nil if match == 0
49
47
 
50
48
  require 'sisimai/address'
51
- dscontents = []; dscontents << Sisimai::MSP.DELIVERYSTATUS
49
+ dscontents = [Sisimai::MSP.DELIVERYSTATUS]
52
50
  hasdivided = mbody.split("\n")
53
- havepassed = [''];
54
- rfc822next = { 'from' => false, 'to' => false, 'subject' => false }
55
- rfc822part = '' # (String) message/rfc822-headers part
56
- previousfn = '' # (String) Previous field name
51
+ havepassed = ['']
52
+ rfc822list = [] # (Array) Each line in message/rfc822 part string
53
+ blanklines = 0 # (Integer) The number of blank lines
57
54
  readcursor = 0 # (Integer) Points the current cursor position
58
55
  recipients = 0 # (Integer) The number of 'Final-Recipient' header
59
56
  commandtxt = '' # (String) SMTP Command name begin with the string '>>>'
@@ -67,12 +64,13 @@ module Sisimai
67
64
 
68
65
  hasdivided.each do |e|
69
66
  # Save the current line for the next loop
70
- havepassed << e; p = havepassed[-2]
67
+ havepassed << e
68
+ p = havepassed[-2]
71
69
 
72
70
  if readcursor == 0
73
71
  # Beginning of the bounce message or delivery status part
74
72
  if e =~ Re1[:begin]
75
- readcursor |= Indicators[:'deliverystatus']
73
+ readcursor |= Indicators[:deliverystatus]
76
74
  next
77
75
  end
78
76
  end
@@ -87,30 +85,16 @@ module Sisimai
87
85
 
88
86
  if readcursor & Indicators[:'message-rfc822'] > 0
89
87
  # After "message/rfc822"
90
- if cv = e.match(/\A([-0-9A-Za-z]+?)[:][ ]*.+\z/)
91
- # Get required headers only
92
- lhs = cv[1].downcase
93
- previousfn = ''
94
- next unless RFC822Head.key?(lhs)
95
-
96
- previousfn = lhs
97
- rfc822part += e + "\n"
98
-
99
- elsif e =~ /\A[ \t]+/
100
- # Continued line from the previous line
101
- next if rfc822next[previousfn]
102
- rfc822part += e + "\n" if LongFields.key?(previousfn)
103
-
104
- else
105
- # Check the end of headers in rfc822 part
106
- next unless LongFields.key?(previousfn)
107
- next unless e.empty?
108
- rfc822next[previousfn] = true
88
+ if e.empty?
89
+ blanklines += 1
90
+ break if blanklines > 1
91
+ next
109
92
  end
93
+ rfc822list << e
110
94
 
111
95
  else
112
96
  # Before "message/rfc822"
113
- next if readcursor & Indicators[:'deliverystatus'] == 0
97
+ next if readcursor & Indicators[:deliverystatus] == 0
114
98
  next if e.empty?
115
99
 
116
100
  if connvalues == connheader.keys.size
@@ -200,39 +184,22 @@ module Sisimai
200
184
  end
201
185
  end
202
186
  end
203
-
204
187
  return nil if recipients == 0
205
188
  require 'sisimai/string'
206
- require 'sisimai/smtp/status'
207
189
 
208
190
  dscontents.map do |e|
209
191
  # Set default values if each value is empty.
210
192
  connheader.each_key { |a| e[a] ||= connheader[a] || '' }
211
193
 
212
- if mhead['received'].size > 0
213
- # Get localhost and remote host name from Received header.
214
- r0 = mhead['received']
215
- %w|lhost rhost|.each { |a| e[a] ||= '' }
216
- e['lhost'] = Sisimai::RFC5322.received(r0[0]).shift if e['lhost'].empty?
217
- e['rhost'] = Sisimai::RFC5322.received(r0[-1]).pop if e['rhost'].empty?
218
- end
194
+ e['agent'] = Sisimai::MSP::US::Bigfoot.smtpagent
219
195
  e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
220
-
221
196
  e['command'] = commandtxt
222
197
  if e['command'].empty?
223
198
  e['command'] = 'EHLO' if esmtpreply.size > 0
224
199
  end
225
-
226
- if e['status'].empty? || e['status'] =~ /\A\d[.]0[.]0\z/
227
- # There is no value of Status header or the value is 5.0.0, 4.0.0
228
- pseudostatus = Sisimai::SMTP::Status.find(e['diagnosis'])
229
- e['status'] = pseudostatus if pseudostatus.size > 0
230
- end
231
-
232
- e['spec'] ||= 'SMTP'
233
- e['agent'] = Sisimai::MSP::US::Bigfoot.smtpagent
234
200
  end
235
201
 
202
+ rfc822part = Sisimai::RFC5322.weedout(rfc822list)
236
203
  return { 'ds' => dscontents, 'rfc822' => rfc822part }
237
204
  end
238
205
 
@@ -21,63 +21,63 @@ module Sisimai
21
21
  # http://postmaster.facebook.com/response_codes
22
22
  # NOT TESTD EXCEPT RCP-P2
23
23
  ReFailure = {
24
- 'userunknown' => [
25
- 'RCP-P1', # The attempted recipient address does not exist.
26
- 'INT-P1', # The attempted recipient address does not exist.
27
- 'INT-P3', # The attempted recpient group address does not exist.
28
- 'INT-P4', # The attempted recipient address does not exist.
24
+ userunknown: [
25
+ 'RCP-P1', # The attempted recipient address does not exist.
26
+ 'INT-P1', # The attempted recipient address does not exist.
27
+ 'INT-P3', # The attempted recpient group address does not exist.
28
+ 'INT-P4', # The attempted recipient address does not exist.
29
29
  ],
30
- 'filtered' => [
31
- 'RCP-P2', # The attempted recipient's preferences prevent messages from being delivered.
32
- 'RCP-P3', # The attempted recipient's privacy settings blocked the delivery.
30
+ filtered: [
31
+ 'RCP-P2', # The attempted recipient's preferences prevent messages from being delivered.
32
+ 'RCP-P3', # The attempted recipient's privacy settings blocked the delivery.
33
33
  ],
34
- 'mesgtoobig' => [
35
- 'MSG-P1', # The message exceeds Facebook's maximum allowed size.
36
- 'INT-P2', # The message exceeds Facebook's maximum allowed size.
34
+ mesgtoobig: [
35
+ 'MSG-P1', # The message exceeds Facebook's maximum allowed size.
36
+ 'INT-P2', # The message exceeds Facebook's maximum allowed size.
37
37
  ],
38
- 'contenterror' => [
39
- 'MSG-P2', # The message contains an attachment type that Facebook does not accept.
40
- 'MSG-P3', # The message contains multiple instances of a header field that can only be present once. Please see RFC 5322, section 3.6 for more information
41
- 'POL-P6', # The message contains a url that has been blocked by Facebook.
42
- 'POL-P7', # The message does not comply with Facebook's abuse policies and will not be accepted.
38
+ contenterror: [
39
+ 'MSG-P2', # The message contains an attachment type that Facebook does not accept.
40
+ 'MSG-P3', # The message contains multiple instances of a header field that can only be present once. Please see RFC 5322, section 3.6 for more information
41
+ 'POL-P6', # The message contains a url that has been blocked by Facebook.
42
+ 'POL-P7', # The message does not comply with Facebook's abuse policies and will not be accepted.
43
43
  ],
44
- 'securityerror' => [
45
- 'POL-P1', # Your mail server's IP Address is listed on the Spamhaus PBL.
46
- 'POL-P2', # Facebook will no longer accept mail from your mail server's IP Address.
47
- 'POL-P5', # The message contains a virus.
48
- 'POL-P7', # The message does not comply with Facebook's Domain Authentication requirements.
44
+ securityerror: [
45
+ 'POL-P1', # Your mail server's IP Address is listed on the Spamhaus PBL.
46
+ 'POL-P2', # Facebook will no longer accept mail from your mail server's IP Address.
47
+ 'POL-P5', # The message contains a virus.
48
+ 'POL-P7', # The message does not comply with Facebook's Domain Authentication requirements.
49
49
  ],
50
- 'notaccept' => [
51
- 'POL-P3', # Facebook is not accepting messages from your mail server. This will persist for 4 to 8 hours.
52
- 'POL-P4', # Facebook is not accepting messages from your mail server. This will persist for 24 to 48 hours.
53
- 'POL-T1', # Facebook is not accepting messages from your mail server, but they may be retried later. This will persist for 1 to 2 hours.
54
- 'POL-T2', # Facebook is not accepting messages from your mail server, but they may be retried later. This will persist for 4 to 8 hours.
55
- 'POL-T3', # Facebook is not accepting messages from your mail server, but they may be retried later. This will persist for 24 to 48 hours.
50
+ notaccept: [
51
+ 'POL-P3', # Facebook is not accepting messages from your mail server. This will persist for 4 to 8 hours.
52
+ 'POL-P4', # Facebook is not accepting messages from your mail server. This will persist for 24 to 48 hours.
53
+ 'POL-T1', # Facebook is not accepting messages from your mail server, but they may be retried later. This will persist for 1 to 2 hours.
54
+ 'POL-T2', # Facebook is not accepting messages from your mail server, but they may be retried later. This will persist for 4 to 8 hours.
55
+ 'POL-T3', # Facebook is not accepting messages from your mail server, but they may be retried later. This will persist for 24 to 48 hours.
56
56
  ],
57
- 'rejected' => [
58
- 'DNS-P1', # Your SMTP MAIL FROM domain does not exist.
59
- 'DNS-P2', # Your SMTP MAIL FROM domain does not have an MX record.
60
- 'DNS-T1', # Your SMTP MAIL FROM domain exists but does not currently resolve.
61
- 'DNS-P3', # Your mail server does not have a reverse DNS record.
62
- 'DNS-T2', # You mail server's reverse DNS record does not currently resolve.
57
+ rejected: [
58
+ 'DNS-P1', # Your SMTP MAIL FROM domain does not exist.
59
+ 'DNS-P2', # Your SMTP MAIL FROM domain does not have an MX record.
60
+ 'DNS-T1', # Your SMTP MAIL FROM domain exists but does not currently resolve.
61
+ 'DNS-P3', # Your mail server does not have a reverse DNS record.
62
+ 'DNS-T2', # You mail server's reverse DNS record does not currently resolve.
63
63
  ],
64
- 'systemerror' => [
65
- 'CON-T1', # Facebook's mail server currently has too many connections open to allow another one.
64
+ systemerror: [
65
+ 'CON-T1', # Facebook's mail server currently has too many connections open to allow another one.
66
66
  ],
67
- 'undefined' => [
68
- 'RCP-T1', # The attempted recipient address is not currently available due to an internal system issue. This is a temporary condition.
69
- 'MSG-T1', # The number of recipients on the message exceeds Facebook's allowed maximum.
70
- 'CON-T2', # Your mail server currently has too many connections open to Facebook's mail servers.
71
- 'CON-T3', # Your mail server has opened too many new connections to Facebook's mail servers in a short period of time.
72
- 'CON-T4', # Your mail server has exceeded the maximum number of recipients for its current connection.
67
+ toomanyconn: [
68
+ 'CON-T3', # Your mail server has opened too many new connections to Facebook's mail servers in a short period of time.
73
69
  ],
74
- 'suspend' => [
75
- 'RCP-T4', # The attempted recipient address is currently deactivated. The user may or may not reactivate it.
70
+ suspend: [
71
+ 'RCP-T4', # The attempted recipient address is currently deactivated. The user may or may not reactivate it.
72
+ ],
73
+ undefined: [
74
+ 'RCP-T1', # The attempted recipient address is not currently available due to an internal system issue. This is a temporary condition.
75
+ 'MSG-T1', # The number of recipients on the message exceeds Facebook's allowed maximum.
76
+ 'CON-T2', # Your mail server currently has too many connections open to Facebook's mail servers.
77
+ 'CON-T4', # Your mail server has exceeded the maximum number of recipients for its current connection.
76
78
  ],
77
79
  }
78
80
  Indicators = Sisimai::MSP.INDICATORS
79
- LongFields = Sisimai::RFC5322.LONGFIELDS
80
- RFC822Head = Sisimai::RFC5322.HEADERFIELDS
81
81
 
82
82
  def description; return 'Facebook: https://www.facebook.com'; end
83
83
  def smtpagent; return 'US::Facebook'; end
@@ -101,12 +101,11 @@ module Sisimai
101
101
  return nil unless mhead['from'] =~ Re0[:from]
102
102
  return nil unless mhead['subject'] =~ Re0[:subject]
103
103
 
104
- dscontents = []; dscontents << Sisimai::MSP.DELIVERYSTATUS
104
+ dscontents = [Sisimai::MSP.DELIVERYSTATUS]
105
105
  hasdivided = mbody.split("\n")
106
- havepassed = [''];
107
- rfc822next = { 'from' => false, 'to' => false, 'subject' => false }
108
- rfc822part = '' # (String) message/rfc822-headers part
109
- previousfn = '' # (String) Previous field name
106
+ havepassed = ['']
107
+ rfc822list = [] # (Array) Each line in message/rfc822 part string
108
+ blanklines = 0 # (Integer) The number of blank lines
110
109
  readcursor = 0 # (Integer) Points the current cursor position
111
110
  recipients = 0 # (Integer) The number of 'Final-Recipient' header
112
111
  fbresponse = '' # (String) Response code from Facebook
@@ -119,12 +118,13 @@ module Sisimai
119
118
 
120
119
  hasdivided.each do |e|
121
120
  # Save the current line for the next loop
122
- havepassed << e; p = havepassed[-2]
121
+ havepassed << e
122
+ p = havepassed[-2]
123
123
 
124
124
  if readcursor == 0
125
125
  # Beginning of the bounce message or delivery status part
126
126
  if e =~ Re1[:begin]
127
- readcursor |= Indicators[:'deliverystatus']
127
+ readcursor |= Indicators[:deliverystatus]
128
128
  next
129
129
  end
130
130
  end
@@ -139,30 +139,16 @@ module Sisimai
139
139
 
140
140
  if readcursor & Indicators[:'message-rfc822'] > 0
141
141
  # After "message/rfc822"
142
- if cv = e.match(/\A([-0-9A-Za-z]+?)[:][ ]*.+\z/)
143
- # Get required headers only
144
- lhs = cv[1].downcase
145
- previousfn = ''
146
- next unless RFC822Head.key?(lhs)
147
-
148
- previousfn = lhs
149
- rfc822part += e + "\n"
150
-
151
- elsif e =~ /\A[ \t]+/
152
- # Continued line from the previous line
153
- next if rfc822next[previousfn]
154
- rfc822part += e + "\n" if LongFields.key?(previousfn)
155
-
156
- else
157
- # Check the end of headers in rfc822 part
158
- next unless LongFields.key?(previousfn)
159
- next unless e.empty?
160
- rfc822next[previousfn] = true
142
+ if e.empty?
143
+ blanklines += 1
144
+ break if blanklines > 1
145
+ next
161
146
  end
147
+ rfc822list << e
162
148
 
163
149
  else
164
150
  # Before "message/rfc822"
165
- next if readcursor & Indicators[:'deliverystatus'] == 0
151
+ next if readcursor & Indicators[:deliverystatus] == 0
166
152
  next if e.empty?
167
153
 
168
154
  if connvalues == connheader.keys.size
@@ -234,21 +220,12 @@ module Sisimai
234
220
  end
235
221
  end
236
222
  end
237
-
238
223
  return nil if recipients == 0
239
224
  require 'sisimai/string'
240
- require 'sisimai/smtp/status'
241
225
 
242
226
  dscontents.map do |e|
243
- e['lhost'] ||= connheader['lhost']
244
-
245
- if mhead['received'].size > 0
246
- # Get localhost and remote host name from Received header.
247
- r0 = mhead['received']
248
- %w|lhost rhost|.each { |a| e[a] ||= '' }
249
- e['lhost'] = Sisimai::RFC5322.received(r0[0]).shift if e['lhost'].empty?
250
- e['rhost'] = Sisimai::RFC5322.received(r0[-1]).pop if e['rhost'].empty?
251
- end
227
+ e['lhost'] ||= connheader['lhost']
228
+ e['agent'] = Sisimai::MSP::US::Facebook.smtpagent
252
229
  e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
253
230
 
254
231
  if cv = e['diagnosis'].match(/\b([A-Z]{3})[-]([A-Z])(\d)\b/)
@@ -257,7 +234,7 @@ module Sisimai
257
234
  rhs = cv[2]
258
235
  num = cv[3]
259
236
 
260
- fbresponse = sprintf("%s-%s%d", lhs, rhs, num)
237
+ fbresponse = sprintf('%s-%s%d', lhs, rhs, num)
261
238
  e['softbounce'] = rhs == 'P' ? 0 : 1
262
239
  end
263
240
 
@@ -267,7 +244,7 @@ module Sisimai
267
244
  ReFailure[r].each do |rr|
268
245
  # Check each regular expression
269
246
  next unless fbresponse == rr
270
- e['reason'] = r
247
+ e['reason'] = r.to_s
271
248
  throw :SESSION
272
249
  end
273
250
  end
@@ -289,13 +266,9 @@ module Sisimai
289
266
  e['softbounce'] = 1
290
267
  end
291
268
  end
292
-
293
- e['status'] = Sisimai::SMTP::Status.find(e['diagnosis'])
294
- e['spec'] = e['reason'] == 'mailererror' ? 'X-UNIX' : 'SMTP'
295
- e['action'] = 'failed' if e['status'] =~ /\A[45]/
296
- e['agent'] = Sisimai::MSP::US::Facebook.smtpagent
297
269
  end
298
270
 
271
+ rfc822part = Sisimai::RFC5322.weedout(rfc822list)
299
272
  return { 'ds' => dscontents, 'rfc822' => rfc822part }
300
273
  end
301
274
 
@@ -24,13 +24,13 @@ module Sisimai
24
24
  :endof => %r/\A__END_OF_EMAIL_MESSAGE__\z/,
25
25
  }
26
26
  ReFailure = {
27
- 'expired' => %r{(?:
27
+ expired: %r{(?:
28
28
  DNS[ ]Error:[ ]Could[ ]not[ ]contact[ ]DNS[ ]servers
29
29
  |Delivery[ ]to[ ]the[ ]following[ ]recipient[ ]has[ ]been[ ]delayed
30
30
  |The[ ]recipient[ ]server[ ]did[ ]not[ ]accept[ ]our[ ]requests[ ]to[ ]connect
31
31
  )
32
32
  }x,
33
- 'hostunknown' => %r{DNS[ ]Error:[ ](?:
33
+ hostunknown: %r{DNS[ ]Error:[ ](?:
34
34
  Domain[ ]name[ ]not[ ]found
35
35
  |DNS[ ]server[ ]returned[ ]answer[ ]with[ ]no[ ]data
36
36
  )
@@ -110,8 +110,6 @@ module Sisimai
110
110
  '18' => { 'command' => 'DATA', 'reason' => 'filtered' },
111
111
  }
112
112
  Indicators = Sisimai::MSP.INDICATORS
113
- LongFields = Sisimai::RFC5322.LONGFIELDS
114
- RFC822Head = Sisimai::RFC5322.HEADERFIELDS
115
113
 
116
114
  def description; return 'Google Gmail: https://mail.google.com'; end
117
115
  def smtpagent; return 'US::Google'; end
@@ -184,11 +182,10 @@ module Sisimai
184
182
  return nil unless mhead['subject'] =~ Re0[:subject]
185
183
 
186
184
  require 'sisimai/address'
187
- dscontents = []; dscontents << Sisimai::MSP.DELIVERYSTATUS
185
+ dscontents = [Sisimai::MSP.DELIVERYSTATUS]
188
186
  hasdivided = mbody.split("\n")
189
- rfc822next = { 'from' => false, 'to' => false, 'subject' => false }
190
- rfc822part = '' # (String) message/rfc822-headers part
191
- previousfn = '' # (String) Previous field name
187
+ rfc822list = [] # (Array) Each line in message/rfc822 part string
188
+ blanklines = 0 # (Integer) The number of blank lines
192
189
  readcursor = 0 # (Integer) Points the current cursor position
193
190
  recipients = 0 # (Integer) The number of 'Final-Recipient' header
194
191
  statecode0 = 0 # (Integer) The value of (state *) in the error message
@@ -198,7 +195,7 @@ module Sisimai
198
195
  if readcursor == 0
199
196
  # Beginning of the bounce message or delivery status part
200
197
  if e =~ Re1[:begin]
201
- readcursor |= Indicators[:'deliverystatus']
198
+ readcursor |= Indicators[:deliverystatus]
202
199
  end
203
200
  end
204
201
 
@@ -212,33 +209,16 @@ module Sisimai
212
209
 
213
210
  if readcursor & Indicators[:'message-rfc822'] > 0
214
211
  # After "message/rfc822"
215
- if cv = e.match(/\A([-0-9A-Za-z]+?)[:][ ]*.+\z/)
216
- # Skip if DKIM-Signature header
217
- next if e =~ /\ADKIM-Signature[:]/
218
-
219
- # Get required headers only
220
- lhs = cv[1].downcase
221
- previousfn = ''
222
- next unless RFC822Head.key?(lhs)
223
-
224
- previousfn = lhs
225
- rfc822part += e + "\n"
226
-
227
- elsif e =~ /\A[ \t]+/
228
- # Continued line from the previous line
229
- next if rfc822next[previousfn]
230
- rfc822part += e + "\n" if LongFields.key?(previousfn)
231
-
232
- else
233
- # Check the end of headers in rfc822 part
234
- next unless LongFields.key?(previousfn)
235
- next unless e.empty?
236
- rfc822next[previousfn] = true
212
+ if e.empty?
213
+ blanklines += 1
214
+ break if blanklines > 1
215
+ next
237
216
  end
217
+ rfc822list << e
238
218
 
239
219
  else
240
220
  # Before "message/rfc822"
241
- next if readcursor & Indicators[:'deliverystatus'] == 0
221
+ next if readcursor & Indicators[:deliverystatus] == 0
242
222
  next if e.empty?
243
223
 
244
224
  # Technical details of permanent failure:=20
@@ -289,6 +269,7 @@ module Sisimai
289
269
  require 'sisimai/smtp/status'
290
270
 
291
271
  dscontents.map do |e|
272
+ e['agent'] = Sisimai::MSP::US::Google.smtpagent
292
273
  e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
293
274
 
294
275
  unless e['rhost']
@@ -308,14 +289,6 @@ module Sisimai
308
289
  end
309
290
  end
310
291
 
311
- if mhead['received'].size > 0
312
- # Get localhost and remote host name from Received header.
313
- r0 = mhead['received']
314
- %w|lhost rhost|.each { |a| e[a] ||= '' }
315
- e['lhost'] = Sisimai::RFC5322.received(r0[0]).shift if e['lhost'].empty?
316
- e['rhost'] = Sisimai::RFC5322.received(r0[-1]).pop if e['rhost'].empty?
317
- end
318
-
319
292
  if cv = e['diagnosis'].match(/[(]state[ ](\d+)[)][.]/)
320
293
  statecode0 = cv[1]
321
294
  end
@@ -329,7 +302,7 @@ module Sisimai
329
302
  ReFailure.each_key do |r|
330
303
  # Verify each regular expression of session errors
331
304
  next unless e['diagnosis'] =~ ReFailure[r]
332
- e['reason'] = r
305
+ e['reason'] = r.to_s
333
306
  break
334
307
  end
335
308
  end
@@ -342,11 +315,9 @@ module Sisimai
342
315
  e['reason'] = Sisimai::SMTP::Status.name(e['status'])
343
316
  end
344
317
  end
345
- e['spec'] = e['reason'] == 'mailererror' ? 'X-UNIX' : 'SMTP'
346
- e['action'] = 'failed' if e['status'] =~ /\A[45]/
347
- e['agent'] = Sisimai::MSP::US::Google.smtpagent
348
318
  end
349
319
 
320
+ rfc822part = Sisimai::RFC5322.weedout(rfc822list)
350
321
  return { 'ds' => dscontents, 'rfc822' => rfc822part }
351
322
  end
352
323