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
@@ -7,7 +7,7 @@ module Sisimai::Lhost
7
7
  require 'sisimai/lhost'
8
8
 
9
9
  Indicators = Sisimai::Lhost.INDICATORS
10
- StartingOf = { rfc822: ['Content-Type: message/partial'] }.freeze
10
+ ReBackbone = %r|^Content-Type:[ ]message/partial|.freeze
11
11
  MarkingsOf = { message: %r/\A[ \t]+[-]+[ \t]*Transcript of session follows/ }.freeze
12
12
 
13
13
  def description; return 'Bigfoot: http://www.bigfoot.com'; end
@@ -37,105 +37,82 @@ module Sisimai::Lhost
37
37
  permessage = {} # (Hash) Store values of each Per-Message field
38
38
 
39
39
  dscontents = [Sisimai::Lhost.DELIVERYSTATUS]
40
- hasdivided = mbody.split("\n")
41
- havepassed = ['']
42
- rfc822list = [] # (Array) Each line in message/rfc822 part string
43
- blanklines = 0 # (Integer) The number of blank lines
40
+ emailsteak = Sisimai::RFC5322.fillet(mbody, ReBackbone)
41
+ bodyslices = emailsteak[0].split("\n")
42
+ readslices = ['']
44
43
  readcursor = 0 # (Integer) Points the current cursor position
45
44
  recipients = 0 # (Integer) The number of 'Final-Recipient' header
46
45
  commandtxt = '' # (String) SMTP Command name begin with the string '>>>'
47
46
  esmtpreply = '' # (String) Reply from remote server on SMTP session
48
47
  v = nil
49
48
 
50
- while e = hasdivided.shift do
51
- # Save the current line for the next loop
52
- havepassed << e
53
- p = havepassed[-2]
49
+ while e = bodyslices.shift do
50
+ # Read error messages and delivery status lines from the head of the email
51
+ # to the previous line of the beginning of the original message.
52
+ readslices << e # Save the current line for the next loop
54
53
 
55
54
  if readcursor == 0
56
55
  # Beginning of the bounce message or message/delivery-status part
57
- if e =~ MarkingsOf[:message]
58
- readcursor |= Indicators[:deliverystatus]
59
- next
60
- end
56
+ readcursor |= Indicators[:deliverystatus] if e =~ MarkingsOf[:message]
57
+ next
61
58
  end
62
-
63
- if (readcursor & Indicators[:'message-rfc822']) == 0
64
- # Beginning of the original message part(message/rfc822)
65
- if e.start_with?(StartingOf[:rfc822][0])
66
- readcursor |= Indicators[:'message-rfc822']
67
- next
68
- end
69
- end
70
-
71
- if readcursor & Indicators[:'message-rfc822'] > 0
72
- # message/rfc822 OR text/rfc822-headers part
73
- if e.empty?
74
- blanklines += 1
75
- break if blanklines > 1
76
- next
77
- end
78
- rfc822list << e
79
- else
80
- # message/delivery-status part
81
- next if (readcursor & Indicators[:deliverystatus]) == 0
82
- next if e.empty?
83
-
84
- if f = Sisimai::RFC1894.match(e)
85
- # "e" matched with any field defined in RFC3464
86
- next unless o = Sisimai::RFC1894.field(e)
87
- v = dscontents[-1]
88
-
89
- if o[-1] == 'addr'
59
+ next if (readcursor & Indicators[:deliverystatus]) == 0
60
+ next if e.empty?
61
+
62
+ if f = Sisimai::RFC1894.match(e)
63
+ # "e" matched with any field defined in RFC3464
64
+ next unless o = Sisimai::RFC1894.field(e)
65
+ v = dscontents[-1]
66
+
67
+ if o[-1] == 'addr'
68
+ # Final-Recipient: rfc822; kijitora@example.jp
69
+ # X-Actual-Recipient: rfc822; kijitora@example.co.jp
70
+ if o[0] == 'final-recipient'
90
71
  # Final-Recipient: rfc822; kijitora@example.jp
91
- # X-Actual-Recipient: rfc822; kijitora@example.co.jp
92
- if o[0] == 'final-recipient'
93
- # Final-Recipient: rfc822; kijitora@example.jp
94
- if v['recipient']
95
- # There are multiple recipient addresses in the message body.
96
- dscontents << Sisimai::Lhost.DELIVERYSTATUS
97
- v = dscontents[-1]
98
- end
99
- v['recipient'] = o[2]
100
- recipients += 1
101
- else
102
- # X-Actual-Recipient: rfc822; kijitora@example.co.jp
103
- v['alias'] = o[2]
72
+ if v['recipient']
73
+ # There are multiple recipient addresses in the message body.
74
+ dscontents << Sisimai::Lhost.DELIVERYSTATUS
75
+ v = dscontents[-1]
104
76
  end
105
- elsif o[-1] == 'code'
106
- # Diagnostic-Code: SMTP; 550 5.1.1 <userunknown@example.jp>... User Unknown
107
- v['spec'] = o[1]
108
- v['diagnosis'] = o[2]
77
+ v['recipient'] = o[2]
78
+ recipients += 1
109
79
  else
110
- # Other DSN fields defined in RFC3464
111
- next unless fieldtable.key?(o[0])
112
- v[fieldtable[o[0]]] = o[2]
113
-
114
- next unless f == 1
115
- permessage[fieldtable[o[0]]] = o[2]
80
+ # X-Actual-Recipient: rfc822; kijitora@example.co.jp
81
+ v['alias'] = o[2]
116
82
  end
83
+ elsif o[-1] == 'code'
84
+ # Diagnostic-Code: SMTP; 550 5.1.1 <userunknown@example.jp>... User Unknown
85
+ v['spec'] = o[1]
86
+ v['diagnosis'] = o[2]
117
87
  else
118
- # The line does not begin with a DSN field defined in RFC3464
119
- unless e.start_with?(' ')
120
- # ----- Transcript of session follows -----
121
- # >>> RCPT TO:<destinaion@example.net>
122
- # <<< 553 Invalid recipient destinaion@example.net (Mode: normal)
123
- if cv = e.match(/\A[>]{3}[ ]+([A-Z]{4})[ ]?/)
124
- # >>> DATA
125
- commandtxt = cv[1]
126
- elsif cv = e.match(/\A[<]{3}[ ]+(.+)\z/)
127
- # <<< Response
128
- esmtpreply = cv[1]
129
- end
130
- else
131
- # Continued line of the value of Diagnostic-Code field
132
- next unless p.start_with?('Diagnostic-Code:')
133
- next unless cv = e.match(/\A[ \t]+(.+)\z/)
134
- v['diagnosis'] << ' ' << cv[1]
135
- havepassed[-1] = 'Diagnostic-Code: ' << e
88
+ # Other DSN fields defined in RFC3464
89
+ next unless fieldtable[o[0]]
90
+ v[fieldtable[o[0]]] = o[2]
91
+
92
+ next unless f == 1
93
+ permessage[fieldtable[o[0]]] = o[2]
94
+ end
95
+ else
96
+ # The line does not begin with a DSN field defined in RFC3464
97
+ unless e.start_with?(' ')
98
+ # ----- Transcript of session follows -----
99
+ # >>> RCPT TO:<destinaion@example.net>
100
+ # <<< 553 Invalid recipient destinaion@example.net (Mode: normal)
101
+ if cv = e.match(/\A[>]{3}[ ]+([A-Z]{4})[ ]?/)
102
+ # >>> DATA
103
+ commandtxt = cv[1]
104
+ elsif cv = e.match(/\A[<]{3}[ ]+(.+)\z/)
105
+ # <<< Response
106
+ esmtpreply = cv[1]
136
107
  end
108
+ else
109
+ # Continued line of the value of Diagnostic-Code field
110
+ next unless readslices[-2].start_with?('Diagnostic-Code:')
111
+ next unless cv = e.match(/\A[ \t]+(.+)\z/)
112
+ v['diagnosis'] << ' ' << cv[1]
113
+ readslices[-1] = 'Diagnostic-Code: ' << e
137
114
  end
138
- end # End of message/delivery-status
115
+ end
139
116
  end
140
117
  return nil unless recipients > 0
141
118
 
@@ -152,8 +129,7 @@ module Sisimai::Lhost
152
129
  end
153
130
  end
154
131
 
155
- rfc822part = Sisimai::RFC5322.weedout(rfc822list)
156
- return { 'ds' => dscontents, 'rfc822' => rfc822part }
132
+ return { 'ds' => dscontents, 'rfc822' => emailsteak[1] }
157
133
  end
158
134
 
159
135
  end
@@ -7,10 +7,10 @@ module Sisimai::Lhost
7
7
  require 'sisimai/lhost'
8
8
 
9
9
  Indicators = Sisimai::Lhost.INDICATORS
10
+ ReBackbone = %r|^Content-Type:[ ]message/rfc822|.freeze
10
11
  StartingOf = {
11
12
  message: [' ----- The following addresses had delivery problems -----'],
12
13
  error: [' ----- Non-delivered information -----'],
13
- rfc822: ['Content-Type: message/rfc822'],
14
14
  }.freeze
15
15
  MessagesOf = {
16
16
  'filtered' => ['Mail Delivery Failed... User unknown'],
@@ -37,77 +37,56 @@ module Sisimai::Lhost
37
37
  return nil unless mhead['subject'].start_with?('Returned mail:')
38
38
 
39
39
  dscontents = [Sisimai::Lhost.DELIVERYSTATUS]
40
- hasdivided = mbody.split("\n")
41
- rfc822list = [] # (Array) Each line in message/rfc822 part string
42
- blanklines = 0 # (Integer) The number of blank lines
40
+ emailsteak = Sisimai::RFC5322.fillet(mbody, ReBackbone)
41
+ bodyslices = emailsteak[0].split("\n")
43
42
  readcursor = 0 # (Integer) Points the current cursor position
44
43
  recipients = 0 # (Integer) The number of 'Final-Recipient' header
45
44
  v = nil
46
45
 
47
- while e = hasdivided.shift do
46
+ while e = bodyslices.shift do
47
+ # Read error messages and delivery status lines from the head of the email
48
+ # to the previous line of the beginning of the original message.
48
49
  if readcursor == 0
49
50
  # Beginning of the bounce message or delivery status part
50
- if e == StartingOf[:message][0]
51
- readcursor |= Indicators[:deliverystatus]
52
- next
53
- end
51
+ readcursor |= Indicators[:deliverystatus] if e == StartingOf[:message][0]
52
+ next
54
53
  end
54
+ next if (readcursor & Indicators[:deliverystatus]) == 0
55
+ next if e.empty?
55
56
 
56
- if (readcursor & Indicators[:'message-rfc822']) == 0
57
- # Beginning of the original message part
58
- if e == StartingOf[:rfc822][0]
59
- readcursor |= Indicators[:'message-rfc822']
60
- next
61
- end
62
- end
63
-
64
- if readcursor & Indicators[:'message-rfc822'] > 0
65
- # Inside of the original message part
66
- if e.empty?
67
- blanklines += 1
68
- break if blanklines > 1
69
- next
70
- end
71
- rfc822list << e
72
- else
73
- # Error message part
74
- next if (readcursor & Indicators[:deliverystatus]) == 0
75
- next if e.empty?
57
+ # This is a MIME-encapsulated message.
58
+ #
59
+ # ----_Biglobe000000/00000.biglobe.ne.jp
60
+ # Content-Type: text/plain; charset="iso-2022-jp"
61
+ #
62
+ # ----- The following addresses had delivery problems -----
63
+ # ********@***.biglobe.ne.jp
64
+ #
65
+ # ----- Non-delivered information -----
66
+ # The number of messages in recipient's mailbox exceeded the local limit.
67
+ #
68
+ # ----_Biglobe000000/00000.biglobe.ne.jp
69
+ # Content-Type: message/rfc822
70
+ #
71
+ v = dscontents[-1]
76
72
 
77
- # This is a MIME-encapsulated message.
78
- #
79
- # ----_Biglobe000000/00000.biglobe.ne.jp
80
- # Content-Type: text/plain; charset="iso-2022-jp"
81
- #
73
+ if cv = e.match(/\A([^ ]+[@][^ ]+)\z/)
82
74
  # ----- The following addresses had delivery problems -----
83
75
  # ********@***.biglobe.ne.jp
84
- #
85
- # ----- Non-delivered information -----
86
- # The number of messages in recipient's mailbox exceeded the local limit.
87
- #
88
- # ----_Biglobe000000/00000.biglobe.ne.jp
89
- # Content-Type: message/rfc822
90
- #
91
- v = dscontents[-1]
92
-
93
- if cv = e.match(/\A([^ ]+[@][^ ]+)\z/)
94
- # ----- The following addresses had delivery problems -----
95
- # ********@***.biglobe.ne.jp
96
- if v['recipient']
97
- # There are multiple recipient addresses in the message body.
98
- dscontents << Sisimai::Lhost.DELIVERYSTATUS
99
- v = dscontents[-1]
100
- end
101
-
102
- r = Sisimai::Address.s3s4(cv[1])
103
- next unless Sisimai::RFC5322.is_emailaddress(r)
104
- v['recipient'] = r
105
- recipients += 1
106
- else
107
- next if e =~ /\A[^\w]/
108
- v['diagnosis'] ||= ''
109
- v['diagnosis'] << e + ' '
76
+ if v['recipient']
77
+ # There are multiple recipient addresses in the message body.
78
+ dscontents << Sisimai::Lhost.DELIVERYSTATUS
79
+ v = dscontents[-1]
110
80
  end
81
+
82
+ r = Sisimai::Address.s3s4(cv[1])
83
+ next unless Sisimai::RFC5322.is_emailaddress(r)
84
+ v['recipient'] = r
85
+ recipients += 1
86
+ else
87
+ next if e =~ /\A[^\w]/
88
+ v['diagnosis'] ||= ''
89
+ v['diagnosis'] << e + ' '
111
90
  end
112
91
  end
113
92
  return nil unless recipients > 0
@@ -124,8 +103,7 @@ module Sisimai::Lhost
124
103
  end
125
104
  end
126
105
 
127
- rfc822part = Sisimai::RFC5322.weedout(rfc822list)
128
- return { 'ds' => dscontents, 'rfc822' => rfc822part }
106
+ return { 'ds' => dscontents, 'rfc822' => emailsteak[1] }
129
107
  end
130
108
 
131
109
  end
@@ -8,10 +8,10 @@ module Sisimai::Lhost
8
8
 
9
9
  # https://www.courier-mta.org/courierdsn.html
10
10
  Indicators = Sisimai::Lhost.INDICATORS
11
+ ReBackbone = %r<^Content-Type:[ ](?:message/rfc822|text/rfc822-headers)>.freeze
11
12
  StartingOf = {
12
13
  # courier/module.dsn/dsn*.txt
13
14
  message: ['DELAYS IN DELIVERING YOUR MESSAGE', 'UNDELIVERABLE MAIL'],
14
- rfc822: ['Content-Type: message/rfc822', 'Content-Type: text/rfc822-headers'],
15
15
  }.freeze
16
16
 
17
17
  MessagesOf = {
@@ -54,19 +54,18 @@ module Sisimai::Lhost
54
54
  permessage = {} # (Hash) Store values of each Per-Message field
55
55
 
56
56
  dscontents = [Sisimai::Lhost.DELIVERYSTATUS]
57
- hasdivided = mbody.split("\n")
58
- havepassed = ['']
59
- rfc822list = [] # (Array) Each line in message/rfc822 part string
60
- blanklines = 0 # (Integer) The number of blank lines
57
+ emailsteak = Sisimai::RFC5322.fillet(mbody, ReBackbone)
58
+ bodyslices = emailsteak[0].split("\n")
59
+ readslices = ['']
61
60
  readcursor = 0 # (Integer) Points the current cursor position
62
61
  recipients = 0 # (Integer) The number of 'Final-Recipient' header
63
62
  commandtxt = '' # (String) SMTP Command name begin with the string '>>>'
64
63
  v = nil
65
64
 
66
- while e = hasdivided.shift do
67
- # Save the current line for the next loop
68
- havepassed << e
69
- p = havepassed[-2]
65
+ while e = bodyslices.shift do
66
+ # Read error messages and delivery status lines from the head of the email
67
+ # to the previous line of the beginning of the original message.
68
+ readslices << e # Save the current line for the next loop
70
69
 
71
70
  if readcursor == 0
72
71
  # Beginning of the bounce message or message/delivery-status part
@@ -75,89 +74,69 @@ module Sisimai::Lhost
75
74
  next
76
75
  end
77
76
  end
78
-
79
- if (readcursor & Indicators[:'message-rfc822']) == 0
80
- # Beginning of the original message part(message/rfc822)
81
- if e.start_with?(StartingOf[:rfc822][0], StartingOf[:rfc822][1])
82
- readcursor |= Indicators[:'message-rfc822']
83
- next
84
- end
85
- end
86
-
87
- if readcursor & Indicators[:'message-rfc822'] > 0
88
- # message/rfc822 OR text/rfc822-headers part
89
- if e.empty?
90
- blanklines += 1
91
- break if blanklines > 1
92
- next
93
- end
94
- rfc822list << e
95
- else
96
- # message/delivery-status part
97
- next if (readcursor & Indicators[:deliverystatus]) == 0
98
- next if e.empty?
99
-
100
- if f = Sisimai::RFC1894.match(e)
101
- # "e" matched with any field defined in RFC3464
102
- next unless o = Sisimai::RFC1894.field(e)
103
- v = dscontents[-1]
104
-
105
- if o[-1] == 'addr'
77
+ next if (readcursor & Indicators[:deliverystatus]) == 0
78
+ next if e.empty?
79
+
80
+ if f = Sisimai::RFC1894.match(e)
81
+ # "e" matched with any field defined in RFC3464
82
+ next unless o = Sisimai::RFC1894.field(e)
83
+ v = dscontents[-1]
84
+
85
+ if o[-1] == 'addr'
86
+ # Final-Recipient: rfc822; kijitora@example.jp
87
+ # X-Actual-Recipient: rfc822; kijitora@example.co.jp
88
+ if o[0] == 'final-recipient'
106
89
  # Final-Recipient: rfc822; kijitora@example.jp
107
- # X-Actual-Recipient: rfc822; kijitora@example.co.jp
108
- if o[0] == 'final-recipient'
109
- # Final-Recipient: rfc822; kijitora@example.jp
110
- if v['recipient']
111
- # There are multiple recipient addresses in the message body.
112
- dscontents << Sisimai::Lhost.DELIVERYSTATUS
113
- v = dscontents[-1]
114
- end
115
- v['recipient'] = o[2]
116
- recipients += 1
117
- else
118
- # X-Actual-Recipient: rfc822; kijitora@example.co.jp
119
- v['alias'] = o[2]
90
+ if v['recipient']
91
+ # There are multiple recipient addresses in the message body.
92
+ dscontents << Sisimai::Lhost.DELIVERYSTATUS
93
+ v = dscontents[-1]
120
94
  end
121
- elsif o[-1] == 'code'
122
- # Diagnostic-Code: SMTP; 550 5.1.1 <userunknown@example.jp>... User Unknown
123
- v['spec'] = o[1]
124
- v['diagnosis'] = o[2]
95
+ v['recipient'] = o[2]
96
+ recipients += 1
125
97
  else
126
- # Other DSN fields defined in RFC3464
127
- next unless fieldtable.key?(o[0])
128
- v[fieldtable[o[0]]] = o[2]
129
-
130
- next unless f == 1
131
- permessage[fieldtable[o[0]]] = o[2]
98
+ # X-Actual-Recipient: rfc822; kijitora@example.co.jp
99
+ v['alias'] = o[2]
132
100
  end
101
+ elsif o[-1] == 'code'
102
+ # Diagnostic-Code: SMTP; 550 5.1.1 <userunknown@example.jp>... User Unknown
103
+ v['spec'] = o[1]
104
+ v['diagnosis'] = o[2]
133
105
  else
134
- # The line does not begin with a DSN field defined in RFC3464
135
- if cv = e.match(/\A[>]{3}[ ]+([A-Z]{4})[ ]?/)
136
- # Your message to the following recipients cannot be delivered:
137
- #
138
- # <kijitora@example.co.jp>:
139
- # mx.example.co.jp [74.207.247.95]:
140
- # >>> RCPT TO:<kijitora@example.co.jp>
141
- # <<< 550 5.1.1 <kijitora@example.co.jp>... User Unknown
142
- #
143
- next unless commandtxt.empty?
144
- commandtxt = cv[1]
145
- else
146
- # Continued line of the value of Diagnostic-Code field
147
- next unless p.start_with?('Diagnostic-Code:')
148
- next unless cv = e.match(/\A[ \t]+(.+)\z/)
149
- v['diagnosis'] << ' ' << cv[1]
150
- havepassed[-1] = 'Diagnostic-Code: ' << e
151
- end
106
+ # Other DSN fields defined in RFC3464
107
+ next unless fieldtable[o[0]]
108
+ v[fieldtable[o[0]]] = o[2]
109
+
110
+ next unless f == 1
111
+ permessage[fieldtable[o[0]]] = o[2]
152
112
  end
153
- end # End of message/delivery-status
113
+ else
114
+ # The line does not begin with a DSN field defined in RFC3464
115
+ if cv = e.match(/\A[>]{3}[ ]+([A-Z]{4})[ ]?/)
116
+ # Your message to the following recipients cannot be delivered:
117
+ #
118
+ # <kijitora@example.co.jp>:
119
+ # mx.example.co.jp [74.207.247.95]:
120
+ # >>> RCPT TO:<kijitora@example.co.jp>
121
+ # <<< 550 5.1.1 <kijitora@example.co.jp>... User Unknown
122
+ #
123
+ next unless commandtxt.empty?
124
+ commandtxt = cv[1]
125
+ else
126
+ # Continued line of the value of Diagnostic-Code field
127
+ next unless readslices[-2].start_with?('Diagnostic-Code:')
128
+ next unless cv = e.match(/\A[ \t]+(.+)\z/)
129
+ v['diagnosis'] << ' ' << cv[1]
130
+ readslices[-1] = 'Diagnostic-Code: ' << e
131
+ end
132
+ end
154
133
  end
155
134
  return nil unless recipients > 0
156
135
 
157
136
  dscontents.each do |e|
158
137
  # Set default values if each value is empty.
159
138
  permessage.each_key { |a| e[a] ||= permessage[a] || '' }
160
- e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
139
+ e['diagnosis'] = Sisimai::String.sweep(e['diagnosis']) || ''
161
140
 
162
141
  MessagesOf.each_key do |r|
163
142
  # Verify each regular expression of session errors
@@ -171,8 +150,7 @@ module Sisimai::Lhost
171
150
  e.each_key { |a| e[a] ||= '' }
172
151
  end
173
152
 
174
- rfc822part = Sisimai::RFC5322.weedout(rfc822list)
175
- return { 'ds' => dscontents, 'rfc822' => rfc822part }
153
+ return { 'ds' => dscontents, 'rfc822' => emailsteak[1] }
176
154
  end
177
155
 
178
156
  end