sisimai 4.25.4 → 4.25.5

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 (100) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -2
  3. data/ChangeLog.md +50 -0
  4. data/README-JA.md +10 -37
  5. data/README.md +10 -37
  6. data/lib/sisimai.rb +15 -64
  7. data/lib/sisimai/address.rb +13 -17
  8. data/lib/sisimai/arf.rb +4 -4
  9. data/lib/sisimai/data.rb +3 -5
  10. data/lib/sisimai/lhost.rb +0 -14
  11. data/lib/sisimai/lhost/activehunter.rb +31 -55
  12. data/lib/sisimai/lhost/amavis.rb +41 -66
  13. data/lib/sisimai/lhost/amazonses.rb +189 -235
  14. data/lib/sisimai/lhost/amazonworkmail.rb +48 -71
  15. data/lib/sisimai/lhost/aol.rb +49 -75
  16. data/lib/sisimai/lhost/apachejames.rb +60 -83
  17. data/lib/sisimai/lhost/bigfoot.rb +61 -85
  18. data/lib/sisimai/lhost/biglobe.rb +40 -62
  19. data/lib/sisimai/lhost/courier.rb +60 -82
  20. data/lib/sisimai/lhost/domino.rb +50 -76
  21. data/lib/sisimai/lhost/einsundeins.rb +57 -55
  22. data/lib/sisimai/lhost/exchange2003.rb +79 -101
  23. data/lib/sisimai/lhost/exchange2007.rb +66 -74
  24. data/lib/sisimai/lhost/exim.rb +119 -142
  25. data/lib/sisimai/lhost/ezweb.rb +53 -73
  26. data/lib/sisimai/lhost/facebook.rb +49 -75
  27. data/lib/sisimai/lhost/fml.rb +25 -50
  28. data/lib/sisimai/lhost/gmx.rb +55 -79
  29. data/lib/sisimai/lhost/google.rb +39 -66
  30. data/lib/sisimai/lhost/gsuite.rb +74 -94
  31. data/lib/sisimai/lhost/imailserver.rb +34 -67
  32. data/lib/sisimai/lhost/interscanmss.rb +33 -67
  33. data/lib/sisimai/lhost/kddi.rb +30 -52
  34. data/lib/sisimai/lhost/mailfoundry.rb +35 -57
  35. data/lib/sisimai/lhost/mailmarshalsmtp.rb +66 -89
  36. data/lib/sisimai/lhost/mailru.rb +51 -76
  37. data/lib/sisimai/lhost/mcafee.rb +53 -79
  38. data/lib/sisimai/lhost/messagelabs.rb +49 -75
  39. data/lib/sisimai/lhost/messagingserver.rb +91 -113
  40. data/lib/sisimai/lhost/mfilter.rb +50 -70
  41. data/lib/sisimai/lhost/mxlogic.rb +38 -63
  42. data/lib/sisimai/lhost/notes.rb +53 -82
  43. data/lib/sisimai/lhost/office365.rb +64 -81
  44. data/lib/sisimai/lhost/opensmtpd.rb +30 -52
  45. data/lib/sisimai/lhost/outlook.rb +49 -75
  46. data/lib/sisimai/lhost/postfix.rb +116 -117
  47. data/lib/sisimai/lhost/qmail.rb +33 -55
  48. data/lib/sisimai/lhost/receivingses.rb +49 -75
  49. data/lib/sisimai/lhost/sendgrid.rb +68 -203
  50. data/lib/sisimai/lhost/sendmail.rb +101 -125
  51. data/lib/sisimai/lhost/surfcontrol.rb +53 -79
  52. data/lib/sisimai/lhost/userdefined.rb +15 -35
  53. data/lib/sisimai/lhost/v5sendmail.rb +59 -89
  54. data/lib/sisimai/lhost/verizon.rb +75 -124
  55. data/lib/sisimai/lhost/x1.rb +30 -54
  56. data/lib/sisimai/lhost/x2.rb +28 -52
  57. data/lib/sisimai/lhost/x3.rb +44 -68
  58. data/lib/sisimai/lhost/x4.rb +34 -58
  59. data/lib/sisimai/lhost/x5.rb +42 -70
  60. data/lib/sisimai/lhost/yahoo.rb +44 -68
  61. data/lib/sisimai/lhost/yandex.rb +59 -85
  62. data/lib/sisimai/lhost/zoho.rb +54 -78
  63. data/lib/sisimai/mail.rb +5 -9
  64. data/lib/sisimai/mail/maildir.rb +10 -14
  65. data/lib/sisimai/mail/mbox.rb +8 -12
  66. data/lib/sisimai/mail/memory.rb +5 -9
  67. data/lib/sisimai/mail/stdin.rb +7 -11
  68. data/lib/sisimai/mda.rb +2 -2
  69. data/lib/sisimai/message.rb +51 -154
  70. data/lib/sisimai/mime.rb +2 -2
  71. data/lib/sisimai/order.rb +2 -27
  72. data/lib/sisimai/reason.rb +3 -5
  73. data/lib/sisimai/rfc1894.rb +1 -1
  74. data/lib/sisimai/rfc3464.rb +29 -29
  75. data/lib/sisimai/rfc3834.rb +7 -6
  76. data/lib/sisimai/rfc5322.rb +20 -31
  77. data/lib/sisimai/rhost/franceptt.rb +120 -24
  78. data/lib/sisimai/rhost/iua.rb +1 -1
  79. data/lib/sisimai/smtp/error.rb +7 -7
  80. data/lib/sisimai/version.rb +1 -1
  81. data/set-of-emails/maildir/bsd/email-einsundeins-03.eml +66 -0
  82. data/set-of-emails/maildir/bsd/email-exchange2007-05.eml +1469 -0
  83. data/set-of-emails/maildir/bsd/email-exchange2007-06.eml +764 -0
  84. data/set-of-emails/maildir/bsd/email-postfix-64.eml +96 -0
  85. data/set-of-emails/maildir/bsd/rfc3834-03.eml +26 -0
  86. data/set-of-emails/maildir/bsd/rhost-franceptt-04.eml +66 -0
  87. data/set-of-emails/maildir/bsd/rhost-franceptt-05.eml +96 -0
  88. data/set-of-emails/maildir/bsd/rhost-franceptt-06.eml +100 -0
  89. data/set-of-emails/maildir/bsd/rhost-franceptt-07.eml +97 -0
  90. data/set-of-emails/maildir/bsd/rhost-franceptt-08.eml +78 -0
  91. data/set-of-emails/maildir/bsd/rhost-franceptt-10.eml +79 -0
  92. data/set-of-emails/maildir/bsd/rhost-franceptt-11.eml +96 -0
  93. metadata +14 -9
  94. data/lib/sisimai/bite.rb +0 -42
  95. data/lib/sisimai/bite/email.rb +0 -18
  96. data/lib/sisimai/bite/json.rb +0 -16
  97. data/lib/sisimai/message/email.rb +0 -26
  98. data/lib/sisimai/message/json.rb +0 -24
  99. data/lib/sisimai/order/email.rb +0 -20
  100. data/lib/sisimai/order/json.rb +0 -16
@@ -8,11 +8,8 @@ module Sisimai::Lhost
8
8
  require 'sisimai/lhost'
9
9
 
10
10
  Indicators = Sisimai::Lhost.INDICATORS
11
- StartingOf = {
12
- message: ['This message was created automatically by mail delivery software.'],
13
- rfc822: ['------ This is a copy of the message, including all the headers. ------'],
14
- }.freeze
15
-
11
+ ReBackbone = %r|^------ This is a copy of the message, including all the headers[.] ------|.freeze
12
+ StartingOf = { message: ['This message was created automatically by mail delivery software.'] }.freeze
16
13
  ReCommands = [
17
14
  %r/SMTP error from remote (?:mail server|mailer) after ([A-Za-z]{4})/,
18
15
  %r/SMTP error from remote (?:mail server|mailer) after end of ([A-Za-z]{4})/,
@@ -77,86 +74,65 @@ module Sisimai::Lhost
77
74
  }x
78
75
 
79
76
  dscontents = [Sisimai::Lhost.DELIVERYSTATUS]
80
- hasdivided = mbody.split("\n")
81
- rfc822list = [] # (Array) Each line in message/rfc822 part string
82
- blanklines = 0 # (Integer) The number of blank lines
77
+ emailsteak = Sisimai::RFC5322.fillet(mbody, ReBackbone)
78
+ bodyslices = emailsteak[0].split("\n")
83
79
  readcursor = 0 # (Integer) Points the current cursor position
84
80
  recipients = 0 # (Integer) The number of 'Final-Recipient' header
85
81
  localhost0 = '' # (String) Local MTA
86
82
  v = nil
87
83
 
88
- while e = hasdivided.shift do
84
+ while e = bodyslices.shift do
85
+ # Read error messages and delivery status lines from the head of the email
86
+ # to the previous line of the beginning of the original message.
89
87
  if readcursor == 0
90
88
  # Beginning of the bounce message or delivery status part
91
- if e.start_with?(StartingOf[:message][0])
92
- readcursor |= Indicators[:deliverystatus]
93
- next
94
- end
89
+ readcursor |= Indicators[:deliverystatus] if e.start_with?(StartingOf[:message][0])
90
+ next
95
91
  end
96
-
97
- if (readcursor & Indicators[:'message-rfc822']) == 0
98
- # Beginning of the original message part
99
- if e == StartingOf[:rfc822][0]
100
- readcursor |= Indicators[:'message-rfc822']
101
- next
92
+ next if (readcursor & Indicators[:deliverystatus]) == 0
93
+ next if e.empty?
94
+
95
+ # Это письмо создано автоматически
96
+ # сервером Mail.Ru, # отвечать на него не
97
+ # нужно.
98
+ #
99
+ # К сожалению, Ваше письмо не может
100
+ # быть# доставлено одному или нескольким
101
+ # получателям:
102
+ #
103
+ # **********************
104
+ #
105
+ # This message was created automatically by mail delivery software.
106
+ #
107
+ # A message that you sent could not be delivered to one or more of its
108
+ # recipients. This is a permanent error. The following address(es) failed:
109
+ #
110
+ # kijitora@example.jp
111
+ # SMTP error from remote mail server after RCPT TO:<kijitora@example.jp>:
112
+ # host neko.example.jp [192.0.2.222]: 550 5.1.1 <kijitora@example.jp>... User Unknown
113
+ v = dscontents[-1]
114
+
115
+ if cv = e.match(/\A[ \t]+([^ \t]+[@][^ \t]+[.][a-zA-Z]+)\z/)
116
+ # kijitora@example.jp
117
+ if v['recipient']
118
+ # There are multiple recipient addresses in the message body.
119
+ dscontents << Sisimai::Lhost.DELIVERYSTATUS
120
+ v = dscontents[-1]
102
121
  end
103
- end
122
+ v['recipient'] = cv[1]
123
+ recipients += 1
104
124
 
105
- if readcursor & Indicators[:'message-rfc822'] > 0
106
- # Inside of the original message part
107
- if e.empty?
108
- blanklines += 1
109
- break if blanklines > 1
110
- next
111
- end
112
- rfc822list << e
113
- else
114
- # Error message part
115
- next if (readcursor & Indicators[:deliverystatus]) == 0
125
+ elsif dscontents.size == recipients
126
+ # Error message
116
127
  next if e.empty?
117
-
118
- # Это письмо создано автоматически
119
- # сервером Mail.Ru, # отвечать на него не
120
- # нужно.
121
- #
122
- # К сожалению, Ваше письмо не может
123
- # быть# доставлено одному или нескольким
124
- # получателям:
125
- #
126
- # **********************
127
- #
128
- # This message was created automatically by mail delivery software.
129
- #
130
- # A message that you sent could not be delivered to one or more of its
131
- # recipients. This is a permanent error. The following address(es) failed:
132
- #
133
- # kijitora@example.jp
134
- # SMTP error from remote mail server after RCPT TO:<kijitora@example.jp>:
135
- # host neko.example.jp [192.0.2.222]: 550 5.1.1 <kijitora@example.jp>... User Unknown
136
- v = dscontents[-1]
137
-
138
- if cv = e.match(/\A[ \t]+([^ \t]+[@][^ \t]+[.][a-zA-Z]+)\z/)
139
- # kijitora@example.jp
140
- if v['recipient']
141
- # There are multiple recipient addresses in the message body.
142
- dscontents << Sisimai::Lhost.DELIVERYSTATUS
143
- v = dscontents[-1]
144
- end
145
- v['recipient'] = cv[1]
146
- recipients += 1
147
-
148
- elsif dscontents.size == recipients
149
- # Error message
150
- next if e.empty?
151
- v['diagnosis'] ||= ''
152
- v['diagnosis'] << e + ' '
153
- else
154
- # Error message when email address above does not include '@'
155
- # and domain part.
156
- next unless e.start_with?(' ', "\t")
157
- v['alterrors'] ||= ''
158
- v['alterrors'] << e + ' '
159
- end
128
+ v['diagnosis'] ||= ''
129
+ v['diagnosis'] << e + ' '
130
+ else
131
+ # Error message when email address above does not include '@'
132
+ # and domain part.
133
+ next unless e.start_with?(' ', "\t")
134
+ v['alterrors'] ||= ''
135
+ v['alterrors'] << e + ' '
160
136
  end
161
137
  end
162
138
 
@@ -243,8 +219,7 @@ module Sisimai::Lhost
243
219
  e['agent'] = self.smtpagent
244
220
  end
245
221
 
246
- rfc822part = Sisimai::RFC5322.weedout(rfc822list)
247
- return { 'ds' => dscontents, 'rfc822' => rfc822part }
222
+ return { 'ds' => dscontents, 'rfc822' => emailsteak[1] }
248
223
  end
249
224
 
250
225
  end
@@ -7,10 +7,8 @@ module Sisimai::Lhost
7
7
  require 'sisimai/lhost'
8
8
 
9
9
  Indicators = Sisimai::Lhost.INDICATORS
10
- StartingOf = {
11
- message: ['--- The following addresses had delivery problems ---'],
12
- rfc822: ['Content-Type: message/rfc822'],
13
- }.freeze
10
+ ReBackbone = %r|^Content-Type:[ ]message/rfc822|.freeze
11
+ StartingOf = { message: ['--- The following addresses had delivery problems ---'] }.freeze
14
12
  ReFailures = {
15
13
  'userunknown' => %r{(?:
16
14
  [ ]User[ ][(].+[@].+[)][ ]unknown[.][ ]
@@ -44,92 +42,69 @@ module Sisimai::Lhost
44
42
  require 'sisimai/rfc1894'
45
43
  fieldtable = Sisimai::RFC1894.FIELDTABLE
46
44
  dscontents = [Sisimai::Lhost.DELIVERYSTATUS]
47
- hasdivided = mbody.split("\n")
48
- havepassed = ['']
49
- rfc822list = [] # (Array) Each line in message/rfc822 part string
50
- blanklines = 0 # (Integer) The number of blank lines
45
+ emailsteak = Sisimai::RFC5322.fillet(mbody, ReBackbone)
46
+ bodyslices = emailsteak[0].split("\n")
47
+ readslices = ['']
51
48
  readcursor = 0 # (Integer) Points the current cursor position
52
49
  recipients = 0 # (Integer) The number of 'Final-Recipient' header
53
50
  diagnostic = '' # (String) Alternative diagnostic message
54
51
  v = nil
55
52
 
56
- while e = hasdivided.shift do
57
- # Save the current line for the next loop
58
- havepassed << e
59
- p = havepassed[-2]
53
+ while e = bodyslices.shift do
54
+ # Read error messages and delivery status lines from the head of the email
55
+ # to the previous line of the beginning of the original message.
56
+ readslices << e # Save the current line for the next loop
60
57
 
61
58
  if readcursor == 0
62
59
  # Beginning of the bounce message or delivery status part
63
- if e.include?(StartingOf[:message][0])
64
- readcursor |= Indicators[:deliverystatus]
65
- next
66
- end
60
+ readcursor |= Indicators[:deliverystatus] if e.include?(StartingOf[:message][0])
61
+ next
67
62
  end
68
-
69
- if (readcursor & Indicators[:'message-rfc822']) == 0
70
- # Beginning of the original message part
71
- if e == StartingOf[:rfc822][0]
72
- readcursor |= Indicators[:'message-rfc822']
73
- next
63
+ next if (readcursor & Indicators[:deliverystatus]) == 0
64
+ next if e.empty?
65
+
66
+ # Content-Type: text/plain; name="deliveryproblems.txt"
67
+ #
68
+ # --- The following addresses had delivery problems ---
69
+ #
70
+ # <user@example.com> (User unknown user@example.com)
71
+ #
72
+ # --------------Boundary-00=_00000000000000000000
73
+ # Content-Type: message/delivery-status; name="deliverystatus.txt"
74
+ #
75
+ v = dscontents[-1]
76
+
77
+ if cv = e.match(/\A[<]([^ ]+[@][^ ]+)[>][ \t]+[(](.+)[)]\z/)
78
+ # <kijitora@example.co.jp> (Unknown user kijitora@example.co.jp)
79
+ if v['recipient']
80
+ # There are multiple recipient addresses in the message body.
81
+ dscontents << Sisimai::Lhost.DELIVERYSTATUS
82
+ v = dscontents[-1]
74
83
  end
75
- end
76
-
77
- if readcursor & Indicators[:'message-rfc822'] > 0
78
- # Inside of the original message part
79
- if e.empty?
80
- blanklines += 1
81
- break if blanklines > 1
84
+ v['recipient'] = cv[1]
85
+ diagnostic = cv[2]
86
+ recipients += 1
87
+
88
+ elsif f = Sisimai::RFC1894.match(e)
89
+ # "e" matched with any field defined in RFC3464
90
+ o = Sisimai::RFC1894.field(e)
91
+ unless o
92
+ # Fallback code for empty value or invalid formatted value
93
+ # - Original-Recipient: <kijitora@example.co.jp>
94
+ if cv = e.match(/\AOriginal-Recipient:[ ]*([^ ]+)\z/)
95
+ v['alias'] = Sisimai::Address.s3s4(cv[1])
96
+ end
82
97
  next
83
98
  end
84
- rfc822list << e
85
- else
86
- # Error message part
87
- next if (readcursor & Indicators[:deliverystatus]) == 0
88
- next if e.empty?
89
-
90
- # Content-Type: text/plain; name="deliveryproblems.txt"
91
- #
92
- # --- The following addresses had delivery problems ---
93
- #
94
- # <user@example.com> (User unknown user@example.com)
95
- #
96
- # --------------Boundary-00=_00000000000000000000
97
- # Content-Type: message/delivery-status; name="deliverystatus.txt"
98
- #
99
- v = dscontents[-1]
100
-
101
- if cv = e.match(/\A[<]([^ ]+[@][^ ]+)[>][ \t]+[(](.+)[)]\z/)
102
- # <kijitora@example.co.jp> (Unknown user kijitora@example.co.jp)
103
- if v['recipient']
104
- # There are multiple recipient addresses in the message body.
105
- dscontents << Sisimai::Lhost.DELIVERYSTATUS
106
- v = dscontents[-1]
107
- end
108
- v['recipient'] = cv[1]
109
- diagnostic = cv[2]
110
- recipients += 1
99
+ next unless fieldtable[o[0]]
100
+ v[fieldtable[o[0]]] = o[2]
111
101
 
112
- elsif f = Sisimai::RFC1894.match(e)
113
- # "e" matched with any field defined in RFC3464
114
- o = Sisimai::RFC1894.field(e)
115
- unless o
116
- # Fallback code for empty value or invalid formatted value
117
- # - Original-Recipient: <kijitora@example.co.jp>
118
- if cv = e.match(/\AOriginal-Recipient:[ ]*([^ ]+)\z/)
119
- v['alias'] = Sisimai::Address.s3s4(cv[1])
120
- end
121
- next
122
- end
123
- next unless fieldtable.key?(o[0])
124
- v[fieldtable[o[0]]] = o[2]
125
-
126
- else
127
- # Continued line of the value of Diagnostic-Code field
128
- next unless p.start_with?('Diagnostic-Code:')
129
- next unless cv = e.match(/\A[ \t]+(.+)\z/)
130
- v['diagnosis'] << ' ' << cv[1]
131
- havepassed[-1] = 'Diagnostic-Code: ' << e
132
- end
102
+ else
103
+ # Continued line of the value of Diagnostic-Code field
104
+ next unless readslices[-2].start_with?('Diagnostic-Code:')
105
+ next unless cv = e.match(/\A[ \t]+(.+)\z/)
106
+ v['diagnosis'] << ' ' << cv[1]
107
+ readslices[-1] = 'Diagnostic-Code: ' << e
133
108
  end
134
109
  end
135
110
  return nil unless recipients > 0
@@ -147,8 +122,7 @@ module Sisimai::Lhost
147
122
  e.each_key { |a| e[a] ||= '' }
148
123
  end
149
124
 
150
- rfc822part = Sisimai::RFC5322.weedout(rfc822list)
151
- return { 'ds' => dscontents, 'rfc822' => rfc822part }
125
+ return { 'ds' => dscontents, 'rfc822' => emailsteak[1] }
152
126
  end
153
127
 
154
128
  end
@@ -8,10 +8,8 @@ module Sisimai::Lhost
8
8
  require 'sisimai/lhost'
9
9
 
10
10
  Indicators = Sisimai::Lhost.INDICATORS
11
- StartingOf = {
12
- message: ['Content-Type: message/delivery-status'],
13
- rfc822: ['Content-Type: text/rfc822-headers'],
14
- }.freeze
11
+ ReBackbone = %r|^Content-Type:[ ]text/rfc822-headers|.freeze
12
+ StartingOf = { message: ['Content-Type: message/delivery-status'] }.freeze
15
13
  ReFailures = {
16
14
  'userunknown' => %r/(?:542 .+ Rejected|No such user)/,
17
15
  'securityerror' => %r/Please turn on SMTP Authentication in your mail client/,
@@ -48,90 +46,67 @@ module Sisimai::Lhost
48
46
  permessage = {} # (Hash) Store values of each Per-Message field
49
47
 
50
48
  dscontents = [Sisimai::Lhost.DELIVERYSTATUS]
51
- hasdivided = mbody.split("\n")
52
- havepassed = ['']
53
- rfc822list = [] # (Array) Each line in message/rfc822 part string
54
- blanklines = 0 # (Integer) The number of blank lines
49
+ emailsteak = Sisimai::RFC5322.fillet(mbody, ReBackbone)
50
+ bodyslices = emailsteak[0].split("\n")
51
+ readslices = ['']
55
52
  readcursor = 0 # (Integer) Points the current cursor position
56
53
  recipients = 0 # (Integer) The number of 'Final-Recipient' header
57
54
  commandset = [] # (Array) ``in reply to * command'' list
58
55
  v = nil
59
56
 
60
- while e = hasdivided.shift do
61
- # Save the current line for the next loop
62
- havepassed << e
63
- p = havepassed[-2]
57
+ while e = bodyslices.shift do
58
+ # Read error messages and delivery status lines from the head of the email
59
+ # to the previous line of the beginning of the original message.
60
+ readslices << e # Save the current line for the next loop
64
61
 
65
62
  if readcursor == 0
66
63
  # Beginning of the bounce message or message/delivery-status part
67
- if e.start_with?(StartingOf[:message][0])
68
- readcursor |= Indicators[:deliverystatus]
69
- next
70
- end
71
- end
72
-
73
- if (readcursor & Indicators[:'message-rfc822']) == 0
74
- # Beginning of the original message part(message/rfc822)
75
- if e == StartingOf[:rfc822][0]
76
- readcursor |= Indicators[:'message-rfc822']
77
- next
78
- end
64
+ readcursor |= Indicators[:deliverystatus] if e.start_with?(StartingOf[:message][0])
65
+ next
79
66
  end
80
-
81
- if readcursor & Indicators[:'message-rfc822'] > 0
82
- # message/rfc822 OR text/rfc822-headers part
83
- if e.empty?
84
- blanklines += 1
85
- break if blanklines > 1
86
- next
87
- end
88
- rfc822list << e
89
- else
90
- # message/delivery-status part
91
- next if (readcursor & Indicators[:deliverystatus]) == 0
92
- next if e.empty?
93
-
94
- if f = Sisimai::RFC1894.match(e)
95
- # "e" matched with any field defined in RFC3464
96
- next unless o = Sisimai::RFC1894.field(e)
97
- v = dscontents[-1]
98
-
99
- if o[-1] == 'addr'
67
+ next if (readcursor & Indicators[:deliverystatus]) == 0
68
+ next if e.empty?
69
+
70
+ if f = Sisimai::RFC1894.match(e)
71
+ # "e" matched with any field defined in RFC3464
72
+ next unless o = Sisimai::RFC1894.field(e)
73
+ v = dscontents[-1]
74
+
75
+ if o[-1] == 'addr'
76
+ # Final-Recipient: rfc822; kijitora@example.jp
77
+ # X-Actual-Recipient: rfc822; kijitora@example.co.jp
78
+ if o[0] == 'final-recipient'
100
79
  # Final-Recipient: rfc822; kijitora@example.jp
101
- # X-Actual-Recipient: rfc822; kijitora@example.co.jp
102
- if o[0] == 'final-recipient'
103
- # Final-Recipient: rfc822; kijitora@example.jp
104
- if v['recipient']
105
- # There are multiple recipient addresses in the message body.
106
- dscontents << Sisimai::Lhost.DELIVERYSTATUS
107
- v = dscontents[-1]
108
- end
109
- v['recipient'] = o[2]
110
- recipients += 1
111
- else
112
- # X-Actual-Recipient: rfc822; kijitora@example.co.jp
113
- v['alias'] = o[2]
80
+ if v['recipient']
81
+ # There are multiple recipient addresses in the message body.
82
+ dscontents << Sisimai::Lhost.DELIVERYSTATUS
83
+ v = dscontents[-1]
114
84
  end
115
- elsif o[-1] == 'code'
116
- # Diagnostic-Code: SMTP; 550 5.1.1 <userunknown@example.jp>... User Unknown
117
- v['spec'] = o[1]
118
- v['diagnosis'] = o[2]
85
+ v['recipient'] = o[2]
86
+ recipients += 1
119
87
  else
120
- # Other DSN fields defined in RFC3464
121
- next unless fieldtable.key?(o[0])
122
- v[fieldtable[o[0]]] = o[2]
123
-
124
- next unless f == 1
125
- permessage[fieldtable[o[0]]] = o[2]
88
+ # X-Actual-Recipient: rfc822; kijitora@example.co.jp
89
+ v['alias'] = o[2]
126
90
  end
91
+ elsif o[-1] == 'code'
92
+ # Diagnostic-Code: SMTP; 550 5.1.1 <userunknown@example.jp>... User Unknown
93
+ v['spec'] = o[1]
94
+ v['diagnosis'] = o[2]
127
95
  else
128
- # Continued line of the value of Diagnostic-Code field
129
- next unless p.start_with?('Diagnostic-Code:')
130
- next unless cv = e.match(/\A[ \t]+(.+)\z/)
131
- v['diagnosis'] << ' ' << cv[1]
132
- havepassed[-1] = 'Diagnostic-Code: ' << e
96
+ # Other DSN fields defined in RFC3464
97
+ next unless fieldtable[o[0]]
98
+ v[fieldtable[o[0]]] = o[2]
99
+
100
+ next unless f == 1
101
+ permessage[fieldtable[o[0]]] = o[2]
133
102
  end
134
- end # End of message/delivery-status
103
+ else
104
+ # Continued line of the value of Diagnostic-Code field
105
+ next unless readslices[-2].start_with?('Diagnostic-Code:')
106
+ next unless cv = e.match(/\A[ \t]+(.+)\z/)
107
+ v['diagnosis'] << ' ' << cv[1]
108
+ readslices[-1] = 'Diagnostic-Code: ' << e
109
+ end
135
110
  end
136
111
  return nil unless recipients > 0
137
112
 
@@ -151,8 +126,7 @@ module Sisimai::Lhost
151
126
  end
152
127
  end
153
128
 
154
- rfc822part = Sisimai::RFC5322.weedout(rfc822list)
155
- return { 'ds' => dscontents, 'rfc822' => rfc822part }
129
+ return { 'ds' => dscontents, 'rfc822' => emailsteak[1] }
156
130
  end
157
131
 
158
132
  end