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,10 +8,8 @@ module Sisimai::Lhost
8
8
 
9
9
  # https://aws.amazon.com/workmail/
10
10
  Indicators = Sisimai::Lhost.INDICATORS
11
- StartingOf = {
12
- message: ['Technical report:'],
13
- rfc822: ['content-type: message/rfc822'],
14
- }.freeze
11
+ ReBackbone = %r|^content-type:[ ]message/rfc822|.freeze
12
+ StartingOf = { message: ['Technical report:'] }.freeze
15
13
 
16
14
  def description; return 'Amazon WorkMail: https://aws.amazon.com/workmail/'; end
17
15
  def smtpagent; return Sisimai::Lhost.smtpagent(self); end
@@ -52,84 +50,64 @@ module Sisimai::Lhost
52
50
  permessage = {} # (Hash) Store values of each Per-Message field
53
51
 
54
52
  dscontents = [Sisimai::Lhost.DELIVERYSTATUS]
55
- hasdivided = mbody.split("\n")
56
- rfc822list = [] # (Array) Each line in message/rfc822 part string
57
- blanklines = 0 # (Integer) The number of blank lines
53
+ emailsteak = Sisimai::RFC5322.fillet(mbody, ReBackbone)
54
+ bodyslices = emailsteak[0].split("\n")
58
55
  readcursor = 0 # (Integer) Points the current cursor position
59
56
  recipients = 0 # (Integer) The number of 'Final-Recipient' header
60
57
  v = nil
61
58
 
62
- while e = hasdivided.shift do
59
+ while e = bodyslices.shift do
60
+ # Read error messages and delivery status lines from the head of the email
61
+ # to the previous line of the beginning of the original message.
62
+
63
63
  if readcursor == 0
64
64
  # Beginning of the bounce message or message/delivery-status part
65
- if e == StartingOf[:message][0]
66
- readcursor |= Indicators[:deliverystatus]
67
- next
68
- end
69
- end
70
-
71
- if (readcursor & Indicators[:'message-rfc822']) == 0
72
- # Beginning of the original message part(message/rfc822)
73
- if e == StartingOf[:rfc822][0]
74
- readcursor |= Indicators[:'message-rfc822']
75
- next
76
- end
65
+ readcursor |= Indicators[:deliverystatus] if e == StartingOf[:message][0]
66
+ next
77
67
  end
78
-
79
- if readcursor & Indicators[:'message-rfc822'] > 0
80
- # message/rfc822 OR text/rfc822-headers part
81
- if e.empty?
82
- blanklines += 1
83
- break if blanklines > 1
84
- next
85
- end
86
- rfc822list << e
87
- else
88
- # message/delivery-status part
89
- next if (readcursor & Indicators[:deliverystatus]) == 0
90
- next if e.empty?
91
-
92
- if f = Sisimai::RFC1894.match(e)
93
- # "e" matched with any field defined in RFC3464
94
- o = Sisimai::RFC1894.field(e) || next
95
- v = dscontents[-1]
96
-
97
- if o[-1] == 'addr'
68
+ next if (readcursor & Indicators[:deliverystatus]) == 0
69
+ next if e.empty?
70
+
71
+ if f = Sisimai::RFC1894.match(e)
72
+ # "e" matched with any field defined in RFC3464
73
+ o = Sisimai::RFC1894.field(e) || next
74
+ v = dscontents[-1]
75
+
76
+ if o[-1] == 'addr'
77
+ # Final-Recipient: rfc822; kijitora@example.jp
78
+ # X-Actual-Recipient: rfc822; kijitora@example.co.jp
79
+ if o[0] == 'final-recipient'
98
80
  # Final-Recipient: rfc822; kijitora@example.jp
99
- # X-Actual-Recipient: rfc822; kijitora@example.co.jp
100
- if o[0] == 'final-recipient'
101
- # Final-Recipient: rfc822; kijitora@example.jp
102
- if v['recipient']
103
- # There are multiple recipient addresses in the message body.
104
- dscontents << Sisimai::Lhost.DELIVERYSTATUS
105
- v = dscontents[-1]
106
- end
107
- v['recipient'] = o[2]
108
- recipients += 1
109
- else
110
- # X-Actual-Recipient: rfc822; kijitora@example.co.jp
111
- v['alias'] = o[2]
81
+ if v['recipient']
82
+ # There are multiple recipient addresses in the message body.
83
+ dscontents << Sisimai::Lhost.DELIVERYSTATUS
84
+ v = dscontents[-1]
112
85
  end
113
- elsif o[-1] == 'code'
114
- # Diagnostic-Code: SMTP; 550 5.1.1 <userunknown@example.jp>... User Unknown
115
- v['spec'] = o[1]
116
- v['diagnosis'] = o[2]
86
+ v['recipient'] = o[2]
87
+ recipients += 1
117
88
  else
118
- # Other DSN fields defined in RFC3464
119
- next unless fieldtable.key?(o[0])
120
- v[fieldtable[o[0]]] = o[2]
121
-
122
- next unless f == 1
123
- permessage[fieldtable[o[0]]] = o[2]
89
+ # X-Actual-Recipient: rfc822; kijitora@example.co.jp
90
+ v['alias'] = o[2]
124
91
  end
92
+ elsif o[-1] == 'code'
93
+ # Diagnostic-Code: SMTP; 550 5.1.1 <userunknown@example.jp>... User Unknown
94
+ v['spec'] = o[1]
95
+ v['diagnosis'] = o[2]
96
+ else
97
+ # Other DSN fields defined in RFC3464
98
+ next unless fieldtable[o[0]]
99
+ v[fieldtable[o[0]]] = o[2]
100
+
101
+ next unless f == 1
102
+ permessage[fieldtable[o[0]]] = o[2]
125
103
  end
104
+ end
126
105
 
127
- # <!DOCTYPE HTML><html>
128
- # <head>
129
- # <meta name="Generator" content="Amazon WorkMail v3.0-2023.77">
130
- # <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
131
- break if e.start_with?('<!DOCTYPE HTML><html>')
132
- end # End of message/delivery-status
106
+ # <!DOCTYPE HTML><html>
107
+ # <head>
108
+ # <meta name="Generator" content="Amazon WorkMail v3.0-2023.77">
109
+ # <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
110
+ break if e.start_with?('<!DOCTYPE HTML><html>')
133
111
  end
134
112
  return nil unless recipients > 0
135
113
 
@@ -160,8 +138,7 @@ module Sisimai::Lhost
160
138
  e['agent'] = self.smtpagent
161
139
  end
162
140
 
163
- rfc822part = Sisimai::RFC5322.weedout(rfc822list)
164
- return { 'ds' => dscontents, 'rfc822' => rfc822part }
141
+ return { 'ds' => dscontents, 'rfc822' => emailsteak[1] }
165
142
  end
166
143
 
167
144
  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: ['Content-Type: message/delivery-status'],
12
- rfc822: ['Content-Type: message/rfc822'],
13
- }.freeze
10
+ ReBackbone = %r|^Content-Type:[ ]message/rfc822|.freeze
11
+ StartingOf = { message: ['Content-Type: message/delivery-status'] }.freeze
14
12
  MessagesOf = {
15
13
  'hostunknown' => ['Host or domain name not found'],
16
14
  'notaccept' => ['type=MX: Malformed or unexpected name server reply'],
@@ -52,89 +50,66 @@ module Sisimai::Lhost
52
50
  permessage = {} # (Hash) Store values of each Per-Message field
53
51
 
54
52
  dscontents = [Sisimai::Lhost.DELIVERYSTATUS]
55
- hasdivided = mbody.split("\n")
56
- havepassed = ['']
57
- rfc822list = [] # (Array) Each line in message/rfc822 part string
58
- blanklines = 0 # (Integer) The number of blank lines
53
+ emailsteak = Sisimai::RFC5322.fillet(mbody, ReBackbone)
54
+ bodyslices = emailsteak[0].split("\n")
55
+ readslices = ['']
59
56
  readcursor = 0 # (Integer) Points the current cursor position
60
57
  recipients = 0 # (Integer) The number of 'Final-Recipient' header
61
58
  v = nil
62
59
 
63
- while e = hasdivided.shift do
64
- # Save the current line for the next loop
65
- havepassed << e
66
- p = havepassed[-2]
60
+ while e = bodyslices.shift do
61
+ # Read error messages and delivery status lines from the head of the email
62
+ # to the previous line of the beginning of the original message.
63
+ readslices << e # Save the current line for the next loop
67
64
 
68
65
  if readcursor == 0
69
66
  # Beginning of the bounce message or message/delivery-status part
70
- if e.start_with?(StartingOf[:message][0])
71
- readcursor |= Indicators[:deliverystatus]
72
- next
73
- end
74
- end
75
-
76
- if (readcursor & Indicators[:'message-rfc822']) == 0
77
- # Beginning of the original message part(message/rfc822)
78
- if e.start_with?(StartingOf[:rfc822][0])
79
- readcursor |= Indicators[:'message-rfc822']
80
- next
81
- end
67
+ readcursor |= Indicators[:deliverystatus] if e.start_with?(StartingOf[:message][0])
68
+ next
82
69
  end
83
-
84
- if readcursor & Indicators[:'message-rfc822'] > 0
85
- # message/rfc822 OR text/rfc822-headers part
86
- if e.empty?
87
- blanklines += 1
88
- break if blanklines > 1
89
- next
90
- end
91
- rfc822list << e
92
- else
93
- # message/delivery-status part
94
- next if (readcursor & Indicators[:deliverystatus]) == 0
95
- next if e.empty?
96
-
97
- if f = Sisimai::RFC1894.match(e)
98
- # "e" matched with any field defined in RFC3464
99
- next unless o = Sisimai::RFC1894.field(e)
100
- v = dscontents[-1]
101
-
102
- if o[-1] == 'addr'
70
+ next if (readcursor & Indicators[:deliverystatus]) == 0
71
+ next if e.empty?
72
+
73
+ if f = Sisimai::RFC1894.match(e)
74
+ # "e" matched with any field defined in RFC3464
75
+ next unless o = Sisimai::RFC1894.field(e)
76
+ v = dscontents[-1]
77
+
78
+ if o[-1] == 'addr'
79
+ # Final-Recipient: rfc822; kijitora@example.jp
80
+ # X-Actual-Recipient: rfc822; kijitora@example.co.jp
81
+ if o[0] == 'final-recipient'
103
82
  # Final-Recipient: rfc822; kijitora@example.jp
104
- # X-Actual-Recipient: rfc822; kijitora@example.co.jp
105
- if o[0] == 'final-recipient'
106
- # Final-Recipient: rfc822; kijitora@example.jp
107
- if v['recipient']
108
- # There are multiple recipient addresses in the message body.
109
- dscontents << Sisimai::Lhost.DELIVERYSTATUS
110
- v = dscontents[-1]
111
- end
112
- v['recipient'] = o[2]
113
- recipients += 1
114
- else
115
- # X-Actual-Recipient: rfc822; kijitora@example.co.jp
116
- v['alias'] = o[2]
83
+ if v['recipient']
84
+ # There are multiple recipient addresses in the message body.
85
+ dscontents << Sisimai::Lhost.DELIVERYSTATUS
86
+ v = dscontents[-1]
117
87
  end
118
- elsif o[-1] == 'code'
119
- # Diagnostic-Code: SMTP; 550 5.1.1 <userunknown@example.jp>... User Unknown
120
- v['spec'] = o[1]
121
- v['diagnosis'] = o[2]
88
+ v['recipient'] = o[2]
89
+ recipients += 1
122
90
  else
123
- # Other DSN fields defined in RFC3464
124
- next unless fieldtable.key?(o[0])
125
- v[fieldtable[o[0]]] = o[2]
126
-
127
- next unless f == 1
128
- permessage[fieldtable[o[0]]] = o[2]
91
+ # X-Actual-Recipient: rfc822; kijitora@example.co.jp
92
+ v['alias'] = o[2]
129
93
  end
94
+ elsif o[-1] == 'code'
95
+ # Diagnostic-Code: SMTP; 550 5.1.1 <userunknown@example.jp>... User Unknown
96
+ v['spec'] = o[1]
97
+ v['diagnosis'] = o[2]
130
98
  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
99
+ # Other DSN fields defined in RFC3464
100
+ next unless fieldtable[o[0]]
101
+ v[fieldtable[o[0]]] = o[2]
102
+
103
+ next unless f == 1
104
+ permessage[fieldtable[o[0]]] = o[2]
136
105
  end
137
- end # End of message/delivery-status
106
+ else
107
+ # Continued line of the value of Diagnostic-Code field
108
+ next unless readslices[-2].start_with?('Diagnostic-Code:')
109
+ next unless cv = e.match(/\A[ \t]+(.+)\z/)
110
+ v['diagnosis'] << ' ' << cv[1]
111
+ readslices[-1] = 'Diagnostic-Code: ' << e
112
+ end
138
113
  end
139
114
  return nil unless recipients > 0
140
115
 
@@ -159,8 +134,7 @@ module Sisimai::Lhost
159
134
  end
160
135
  end
161
136
 
162
- rfc822part = Sisimai::RFC5322.weedout(rfc822list)
163
- return { 'ds' => dscontents, 'rfc822' => rfc822part }
137
+ return { 'ds' => dscontents, 'rfc822' => emailsteak[1] }
164
138
  end
165
139
  end
166
140
  end
@@ -7,12 +7,12 @@ 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
  # apache-james-2.3.2/src/java/org/apache/james/transport/mailets/
12
13
  # AbstractNotify.java|124: out.println("Error message below:");
13
14
  # AbstractNotify.java|128: out.println("Message details:");
14
15
  message: [''],
15
- rfc822: ['Content-Type: message/rfc822'],
16
16
  error: ['Error message below:'],
17
17
  }.freeze
18
18
 
@@ -39,9 +39,8 @@ module Sisimai::Lhost
39
39
  return nil unless match > 0
40
40
 
41
41
  dscontents = [Sisimai::Lhost.DELIVERYSTATUS]
42
- hasdivided = mbody.split("\n")
43
- rfc822list = [] # (Array) Each line in message/rfc822 part string
44
- blanklines = 0 # (Integer) The number of blank lines
42
+ emailsteak = Sisimai::RFC5322.fillet(mbody, ReBackbone)
43
+ bodyslices = emailsteak[0].split("\n")
45
44
  readcursor = 0 # (Integer) Points the current cursor position
46
45
  recipients = 0 # (Integer) The number of 'Final-Recipient' header
47
46
  diagnostic = '' # (String) Alternative diagnostic message
@@ -49,98 +48,77 @@ module Sisimai::Lhost
49
48
  gotmessage = nil # (Boolean) Flag for error message
50
49
  v = nil
51
50
 
52
- while e = hasdivided.shift do
51
+ while e = bodyslices.shift do
52
+ # Read error messages and delivery status lines from the head of the email
53
+ # to the previous line of the beginning of the original message.
54
+
53
55
  if readcursor == 0
54
56
  # Beginning of the bounce message or delivery status part
55
- if e.start_with?(StartingOf[:message][0])
56
- readcursor |= Indicators[:deliverystatus]
57
- next
58
- end
59
- end
60
-
61
- if (readcursor & Indicators[:'message-rfc822']) == 0
62
- # Beginning of the original message part
63
- if e.start_with?(StartingOf[:rfc822][0])
64
- readcursor |= Indicators[:'message-rfc822']
65
- next
66
- end
57
+ readcursor |= Indicators[:deliverystatus] if e.start_with?(StartingOf[:message][0])
58
+ next
67
59
  end
68
-
69
- if readcursor & Indicators[:'message-rfc822'] > 0
70
- # Inside of the original message part
71
- if e.empty?
72
- blanklines += 1
73
- break if blanklines > 1
74
- next
60
+ next if (readcursor & Indicators[:deliverystatus]) == 0
61
+ next if e.empty?
62
+
63
+ # Message details:
64
+ # Subject: Nyaaan
65
+ # Sent date: Thu Apr 29 01:20:50 JST 2015
66
+ # MAIL FROM: shironeko@example.jp
67
+ # RCPT TO: kijitora@example.org
68
+ # From: Neko <shironeko@example.jp>
69
+ # To: kijitora@example.org
70
+ # Size (in bytes): 1024
71
+ # Number of lines: 64
72
+ v = dscontents[-1]
73
+
74
+ if cv = e.match(/\A[ ][ ]RCPT[ ]TO:[ ]([^ ]+[@][^ ]+)\z/)
75
+ # RCPT TO: kijitora@example.org
76
+ if v['recipient']
77
+ # There are multiple recipient addresses in the message body.
78
+ dscontents << Sisimai::Lhost.DELIVERYSTATUS
79
+ v = dscontents[-1]
75
80
  end
76
- rfc822list << e
77
- else
78
- # Error message part
79
- next if (readcursor & Indicators[:deliverystatus]) == 0
80
- next if e.empty?
81
+ v['recipient'] = cv[1]
82
+ recipients += 1
81
83
 
82
- # Message details:
83
- # Subject: Nyaaan
84
+ elsif cv = e.match(/\A[ ][ ]Sent[ ]date:[ ](.+)\z/)
84
85
  # Sent date: Thu Apr 29 01:20:50 JST 2015
85
- # MAIL FROM: shironeko@example.jp
86
- # RCPT TO: kijitora@example.org
87
- # From: Neko <shironeko@example.jp>
88
- # To: kijitora@example.org
89
- # Size (in bytes): 1024
90
- # Number of lines: 64
91
- v = dscontents[-1]
86
+ v['date'] = cv[1]
92
87
 
93
- if cv = e.match(/\A[ ][ ]RCPT[ ]TO:[ ]([^ ]+[@][^ ]+)\z/)
94
- # RCPT TO: kijitora@example.org
95
- if v['recipient']
96
- # There are multiple recipient addresses in the message body.
97
- dscontents << Sisimai::Lhost.DELIVERYSTATUS
98
- v = dscontents[-1]
88
+ elsif cv = e.match(/\A[ ][ ]Subject:[ ](.+)\z/)
89
+ # Subject: Nyaaan
90
+ subjecttxt = cv[1]
91
+ else
92
+ next if gotmessage
93
+ if v['diagnosis']
94
+ # Get an error message text
95
+ if e.start_with?('Message details:')
96
+ # Message details:
97
+ # Subject: nyaan
98
+ # ...
99
+ gotmessage = true
100
+ else
101
+ # Append error message text like the followng:
102
+ # Error message below:
103
+ # 550 - Requested action not taken: no such user here
104
+ v['diagnosis'] << ' ' << e
99
105
  end
100
- v['recipient'] = cv[1]
101
- recipients += 1
102
-
103
- elsif cv = e.match(/\A[ ][ ]Sent[ ]date:[ ](.+)\z/)
104
- # Sent date: Thu Apr 29 01:20:50 JST 2015
105
- v['date'] = cv[1]
106
-
107
- elsif cv = e.match(/\A[ ][ ]Subject:[ ](.+)\z/)
108
- # Subject: Nyaaan
109
- subjecttxt = cv[1]
110
106
  else
111
- next if gotmessage
112
- if v['diagnosis']
113
- # Get an error message text
114
- if e.start_with?('Message details:')
115
- # Message details:
116
- # Subject: nyaan
117
- # ...
118
- gotmessage = true
119
- else
120
- # Append error message text like the followng:
121
- # Error message below:
122
- # 550 - Requested action not taken: no such user here
123
- v['diagnosis'] << ' ' << e
124
- end
125
- else
126
- # Error message below:
127
- # 550 - Requested action not taken: no such user here
128
- v['diagnosis'] = e if e == StartingOf[:error][0]
129
- unless gotmessage
130
- v['diagnosis'] ||= ''
131
- v['diagnosis'] << ' ' + e
132
- end
107
+ # Error message below:
108
+ # 550 - Requested action not taken: no such user here
109
+ v['diagnosis'] = e if e == StartingOf[:error][0]
110
+ unless gotmessage
111
+ v['diagnosis'] ||= ''
112
+ v['diagnosis'] << ' ' + e
133
113
  end
134
114
  end
135
115
  end
136
116
  end
137
117
  return nil unless recipients > 0
138
118
 
139
- unless rfc822list.any? { |a| a.start_with?('Subject:') }
140
- # Set the value of subjecttxt as a Subject if there is no original
141
- # message in the bounce mail.
142
- rfc822list << ('Subject: ' << subjecttxt)
143
- end
119
+ # Set the value of subjecttxt as a Subject if there is no original
120
+ # message in the bounce mail.
121
+ emailsteak[1] << ('Subject: ' << subjecttxt << "\n") unless emailsteak[1] =~ /^Subject: /
144
122
 
145
123
  dscontents.each do |e|
146
124
  e['agent'] = self.smtpagent
@@ -148,8 +126,7 @@ module Sisimai::Lhost
148
126
  e.each_key { |a| e[a] ||= '' }
149
127
  end
150
128
 
151
- rfc822part = Sisimai::RFC5322.weedout(rfc822list)
152
- return { 'ds' => dscontents, 'rfc822' => rfc822part }
129
+ return { 'ds' => dscontents, 'rfc822' => emailsteak[1] }
153
130
  end
154
131
 
155
132
  end