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,10 +7,8 @@ module Sisimai::Lhost
7
7
  require 'sisimai/lhost'
8
8
 
9
9
  Indicators = Sisimai::Lhost.INDICATORS
10
- StartingOf = {
11
- message: ['Your message'],
12
- rfc822: ['Content-Type: message/delivery-status'],
13
- }.freeze
10
+ ReBackbone = %r|^Content-Type:[ ]message/delivery-status|.freeze
11
+ StartingOf = { message: ['Your message'] }.freeze
14
12
  MessagesOf = {
15
13
  'userunknown' => [
16
14
  'not listed in Domino Directory',
@@ -40,86 +38,65 @@ module Sisimai::Lhost
40
38
  return nil unless mhead['subject'].start_with?('DELIVERY FAILURE:')
41
39
 
42
40
  dscontents = [Sisimai::Lhost.DELIVERYSTATUS]
43
- hasdivided = mbody.split("\n")
44
- rfc822list = [] # (Array) Each line in message/rfc822 part string
45
- blanklines = 0 # (Integer) The number of blank lines
41
+ emailsteak = Sisimai::RFC5322.fillet(mbody, ReBackbone)
42
+ bodyslices = emailsteak[0].split("\n")
46
43
  readcursor = 0 # (Integer) Points the current cursor position
47
44
  recipients = 0 # (Integer) The number of 'Final-Recipient' header
48
45
  subjecttxt = '' # (String) The value of Subject:
49
46
  v = nil
50
47
 
51
- while e = hasdivided.shift do
48
+ while e = bodyslices.shift do
49
+ # Read error messages and delivery status lines from the head of the email
50
+ # to the previous line of the beginning of the original message.
52
51
  next if e.empty?
53
52
 
54
53
  if readcursor == 0
55
54
  # Beginning of the bounce message or delivery status part
56
- if e.start_with?(StartingOf[:message][0])
57
- readcursor |= Indicators[:deliverystatus]
58
- next
59
- end
55
+ readcursor |= Indicators[:deliverystatus] if e.start_with?(StartingOf[:message][0])
56
+ next
60
57
  end
61
-
62
- if (readcursor & Indicators[:'message-rfc822']) == 0
63
- # Beginning of the original message part
64
- if e == StartingOf[:rfc822][0]
65
- readcursor |= Indicators[:'message-rfc822']
66
- next
58
+ next if (readcursor & Indicators[:deliverystatus]) == 0
59
+
60
+ # Your message
61
+ #
62
+ # Subject: Test Bounce
63
+ #
64
+ # was not delivered to:
65
+ #
66
+ # kijitora@example.net
67
+ #
68
+ # because:
69
+ #
70
+ # User some.name (kijitora@example.net) not listed in Domino Directory
71
+ #
72
+ v = dscontents[-1]
73
+
74
+ if e.start_with?('was not delivered to:')
75
+ # was not delivered to:
76
+ if v['recipient']
77
+ # There are multiple recipient addresses in the message body.
78
+ dscontents << Sisimai::Lhost.DELIVERYSTATUS
79
+ v = dscontents[-1]
67
80
  end
68
- end
81
+ v['recipient'] ||= e
82
+ recipients += 1
69
83
 
70
- if readcursor & Indicators[:'message-rfc822'] > 0
71
- # Inside of the original message part
72
- if e.empty?
73
- blanklines += 1
74
- break if blanklines > 1
75
- next
76
- end
77
- rfc822list << e
78
- else
79
- # Error message part
80
- next if (readcursor & Indicators[:deliverystatus]) == 0
81
-
82
- # Your message
83
- #
84
- # Subject: Test Bounce
85
- #
86
- # was not delivered to:
87
- #
84
+ elsif cv = e.match(/\A[ ][ ]([^ ]+[@][^ ]+)\z/)
85
+ # Continued from the line "was not delivered to:"
88
86
  # kijitora@example.net
89
- #
87
+ v['recipient'] = Sisimai::Address.s3s4(cv[1])
88
+
89
+ elsif e.start_with?('because:')
90
90
  # because:
91
- #
92
- # User some.name (kijitora@example.net) not listed in Domino Directory
93
- #
94
- v = dscontents[-1]
95
-
96
- if e.start_with?('was not delivered to:')
97
- # was not delivered to:
98
- if v['recipient']
99
- # There are multiple recipient addresses in the message body.
100
- dscontents << Sisimai::Lhost.DELIVERYSTATUS
101
- v = dscontents[-1]
102
- end
103
- v['recipient'] ||= e
104
- recipients += 1
105
-
106
- elsif cv = e.match(/\A[ ][ ]([^ ]+[@][^ ]+)\z/)
107
- # Continued from the line "was not delivered to:"
108
- # kijitora@example.net
109
- v['recipient'] = Sisimai::Address.s3s4(cv[1])
110
-
111
- elsif e.start_with?('because:')
112
- # because:
91
+ v['diagnosis'] = e
92
+ else
93
+ if v['diagnosis'].to_s == 'because:'
94
+ # Error message, continued from the line "because:"
113
95
  v['diagnosis'] = e
114
- else
115
- if v['diagnosis'].to_s == 'because:'
116
- # Error message, continued from the line "because:"
117
- v['diagnosis'] = e
118
-
119
- elsif cv = e.match(/\A[ ][ ]Subject: (.+)\z/)
120
- # Subject: Nyaa
121
- subjecttxt = cv[1]
122
- end
96
+
97
+ elsif cv = e.match(/\A[ ][ ]Subject: (.+)\z/)
98
+ # Subject: Nyaa
99
+ subjecttxt = cv[1]
123
100
  end
124
101
  end
125
102
  end
@@ -140,14 +117,11 @@ module Sisimai::Lhost
140
117
  e.each_key { |a| e[a] ||= '' }
141
118
  end
142
119
 
143
- unless rfc822list.any? { |a| a.start_with?('Subject:') }
144
- # Set the value of subjecttxt as a Subject if there is no original
145
- # message in the bounce mail.
146
- rfc822list << ('Subject: ' << subjecttxt)
147
- end
120
+ # Set the value of subjecttxt as a Subject if there is no original
121
+ # message in the bounce mail.
122
+ emailsteak[1] << ('Subject: ' << subjecttxt << "\n") unless emailsteak[1] =~ /^Subject: /
148
123
 
149
- rfc822part = Sisimai::RFC5322.weedout(rfc822list)
150
- return { 'ds' => dscontents, 'rfc822' => rfc822part }
124
+ return { 'ds' => dscontents, 'rfc822' => emailsteak[1] }
151
125
  end
152
126
 
153
127
  end
@@ -7,10 +7,10 @@ module Sisimai::Lhost
7
7
  require 'sisimai/lhost'
8
8
 
9
9
  Indicators = Sisimai::Lhost.INDICATORS
10
+ ReBackbone = %r|^---[ ]The[ ]header[ ]of[ ]the[ ]original[ ]message[ ]is[ ]following[.][ ]---|.freeze
10
11
  StartingOf = {
11
12
  message: ['This message was created automatically by mail delivery software'],
12
13
  error: ['For the following reason:'],
13
- rfc822: ['--- The header of the original message is following'],
14
14
  }.freeze
15
15
  MessagesOf = { 'mesgtoobig' => ['Mail size limit exceeded'] }.freeze
16
16
 
@@ -34,77 +34,80 @@ module Sisimai::Lhost
34
34
  return nil unless mhead['subject'] == 'Mail delivery failed: returning message to sender'
35
35
 
36
36
  dscontents = [Sisimai::Lhost.DELIVERYSTATUS]
37
- hasdivided = mbody.split("\n")
38
- rfc822list = [] # (Array) Each line in message/rfc822 part string
39
- blanklines = 0 # (Integer) The number of blank lines
37
+ emailsteak = Sisimai::RFC5322.fillet(mbody, ReBackbone)
38
+ bodyslices = emailsteak[0].split("\n")
40
39
  readcursor = 0 # (Integer) Points the current cursor position
41
40
  recipients = 0 # (Integer) The number of 'Final-Recipient' header
42
41
  v = nil
43
42
 
44
- while e = hasdivided.shift do
43
+ while e = bodyslices.shift do
44
+ # Read error messages and delivery status lines from the head of the email
45
+ # to the previous line of the beginning of the original message.
46
+
45
47
  if readcursor == 0
46
48
  # Beginning of the bounce message or delivery status part
47
- if e.start_with?(StartingOf[:message][0])
48
- readcursor |= Indicators[:deliverystatus]
49
- next
50
- end
49
+ readcursor |= Indicators[:deliverystatus] if e.start_with?(StartingOf[:message][0])
50
+ next
51
51
  end
52
+ next if (readcursor & Indicators[:deliverystatus]) == 0
53
+ next if e.empty?
52
54
 
53
- if (readcursor & Indicators[:'message-rfc822']) == 0
54
- # Beginning of the original message part
55
- if e.start_with?(StartingOf[:rfc822][0])
56
- readcursor |= Indicators[:'message-rfc822']
57
- next
58
- end
59
- end
55
+ # The following address failed:
56
+ #
57
+ # general@example.eu
58
+ #
59
+ # For the following reason:
60
+ #
61
+ # Mail size limit exceeded. For explanation visit
62
+ # http://postmaster.1and1.com/en/error-messages?ip=%1s
63
+ v = dscontents[-1]
60
64
 
61
- if readcursor & Indicators[:'message-rfc822'] > 0
62
- # Inside of the original message part
63
- if e.empty?
64
- blanklines += 1
65
- break if blanklines > 1
66
- next
65
+ if cv = e.match(/\A([^ ]+[@][^ ]+)\z/)
66
+ # general@example.eu
67
+ if v['recipient']
68
+ # There are multiple recipient addresses in the message body.
69
+ dscontents << Sisimai::Lhost.DELIVERYSTATUS
70
+ v = dscontents[-1]
67
71
  end
68
- rfc822list << e
69
- else
70
- # Error message part
71
- next if (readcursor & Indicators[:deliverystatus]) == 0
72
- next if e.empty?
72
+ v['recipient'] = cv[1]
73
+ recipients += 1
73
74
 
74
- # The following address failed:
75
- #
76
- # general@example.eu
77
- #
75
+ elsif e.start_with?(StartingOf[:error][0])
78
76
  # For the following reason:
79
- #
80
- # Mail size limit exceeded. For explanation visit
81
- # http://postmaster.1and1.com/en/error-messages?ip=%1s
82
- v = dscontents[-1]
83
-
84
- if cv = e.match(/\A([^ ]+[@][^ ]+)\z/)
85
- # general@example.eu
86
- if v['recipient']
87
- # There are multiple recipient addresses in the message body.
88
- dscontents << Sisimai::Lhost.DELIVERYSTATUS
89
- v = dscontents[-1]
90
- end
91
- v['recipient'] = cv[1]
92
- recipients += 1
93
-
94
- elsif e.start_with?(StartingOf[:error][0])
95
- # For the following reason:
96
- v['diagnosis'] = e
97
- else
77
+ v['diagnosis'] = e
78
+ else
79
+ if v['diagnosis']
98
80
  # Get error message and append error message strings
99
- v['diagnosis'] << ' ' << e if v['diagnosis']
81
+ v['diagnosis'] << ' ' << e
82
+ else
83
+ # OR the following format:
84
+ # neko@example.fr:
85
+ # SMTP error from remote server for TEXT command, host: ...
86
+ v['alterrors'] ||= ''
87
+ v['alterrors'] << ' ' << e
100
88
  end
101
89
  end
102
90
  end
103
91
  return nil unless recipients > 0
104
92
 
105
93
  dscontents.each do |e|
106
- e['agent'] = self.smtpagent
107
- e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'].to_s.gsub(/\A#{StartingOf[:error][0]}/, ''))
94
+ e['agent'] = self.smtpagent
95
+ e['diagnosis'] ||= ''
96
+ e['diagnosis'] = e['alterrors'] if e['diagnosis'].empty?
97
+
98
+ if cv = e['diagnosis'].match(/host:[ ]+(.+?)[ ]+.+[ ]+reason:.+/)
99
+ # SMTP error from remote server for TEXT command,
100
+ # host: smtp-in.orange.fr (193.252.22.65)
101
+ # reason: 550 5.2.0 Mail rejete. Mail rejected. ofr_506 [506]
102
+ e['rhost'] = cv[1]
103
+ e['command'] = 'DATA' if e['diagnosis'] =~ /for TEXT command/
104
+ e['spec'] = 'SMTP' if e['diagnosis'] =~ /SMTP error/
105
+ e['status'] = Sisimai::SMTP::Status.find(e['diagnosis'])
106
+ else
107
+ # For the following reason:
108
+ e['diagnosis'].gsub(/\A#{StartingOf[:error][0]}/, '')
109
+ end
110
+ e['diagnosis'] = Sisimai::String.sweep(e['diagnosis'])
108
111
 
109
112
  MessagesOf.each_key do |r|
110
113
  # Verify each regular expression of session errors
@@ -114,8 +117,7 @@ module Sisimai::Lhost
114
117
  end
115
118
  end
116
119
 
117
- rfc822part = Sisimai::RFC5322.weedout(rfc822list)
118
- return { 'ds' => dscontents, 'rfc822' => rfc822part }
120
+ return { 'ds' => dscontents, 'rfc822' => emailsteak[1] }
119
121
  end
120
122
 
121
123
  end
@@ -8,10 +8,10 @@ module Sisimai::Lhost
8
8
  require 'sisimai/lhost'
9
9
 
10
10
  Indicators = Sisimai::Lhost.INDICATORS
11
+ ReBackbone = %r|^Content-Type:[ ]message/rfc822|.freeze
11
12
  StartingOf = {
12
13
  message: ['Your message'],
13
14
  error: ['did not reach the following recipient(s):'],
14
- rfc822: ['Content-Type: message/rfc822'],
15
15
  }.freeze
16
16
  ErrorCodes = {
17
17
  'onhold' => [
@@ -92,9 +92,8 @@ module Sisimai::Lhost
92
92
  return nil unless match > 0
93
93
 
94
94
  dscontents = [Sisimai::Lhost.DELIVERYSTATUS]
95
- hasdivided = mbody.split("\n")
96
- rfc822list = [] # (Array) Each line in message/rfc822 part string
97
- blanklines = 0 # (Integer) The number of blank lines
95
+ emailsteak = Sisimai::RFC5322.fillet(mbody, ReBackbone)
96
+ bodyslices = emailsteak[0].split("\n")
98
97
  readcursor = 0 # (Integer) Points the current cursor position
99
98
  recipients = 0 # (Integer) The number of 'Final-Recipient' header
100
99
  statuspart = false # (Boolean) Flag, true = have got delivery status part.
@@ -106,108 +105,88 @@ module Sisimai::Lhost
106
105
  }
107
106
  v = nil
108
107
 
109
- while e = hasdivided.shift do
108
+ while e = bodyslices.shift do
109
+ # Read error messages and delivery status lines from the head of the email
110
+ # to the previous line of the beginning of the original message.
110
111
  if readcursor == 0
111
112
  # Beginning of the bounce message or delivery status part
112
- if e.start_with?(StartingOf[:message][0])
113
- readcursor |= Indicators[:deliverystatus]
114
- next
115
- end
116
- end
117
-
118
- if (readcursor & Indicators[:'message-rfc822']) == 0
119
- # Beginning of the original message part
120
- if e.start_with?(StartingOf[:rfc822][0])
121
- readcursor |= Indicators[:'message-rfc822']
122
- next
123
- end
113
+ readcursor |= Indicators[:deliverystatus] if e.start_with?(StartingOf[:message][0])
114
+ next
124
115
  end
116
+ next if (readcursor & Indicators[:deliverystatus]) == 0
117
+ next if statuspart
118
+
119
+ if connvalues == connheader.keys.size
120
+ # did not reach the following recipient(s):
121
+ #
122
+ # kijitora@example.co.jp on Thu, 29 Apr 2007 16:51:51 -0500
123
+ # The recipient name is not recognized
124
+ # The MTS-ID of the original message is: c=jp;a= ;p=neko
125
+ # ;l=EXCHANGE000000000000000000
126
+ # MSEXCH:IMS:KIJITORA CAT:EXAMPLE:EXCHANGE 0 (000C05A6) Unknown Recipient
127
+ # mikeneko@example.co.jp on Thu, 29 Apr 2007 16:51:51 -0500
128
+ # The recipient name is not recognized
129
+ # The MTS-ID of the original message is: c=jp;a= ;p=neko
130
+ # ;l=EXCHANGE000000000000000000
131
+ # MSEXCH:IMS:KIJITORA CAT:EXAMPLE:EXCHANGE 0 (000C05A6) Unknown Recipient
132
+ v = dscontents[-1]
125
133
 
126
- if readcursor & Indicators[:'message-rfc822'] > 0
127
- # Inside of the original message part
128
- if e.empty?
129
- blanklines += 1
130
- break if blanklines > 1
131
- next
132
- end
133
- rfc822list << e
134
- else
135
- # Error message part
136
- next if (readcursor & Indicators[:deliverystatus]) == 0
137
- next if statuspart
138
-
139
- if connvalues == connheader.keys.size
140
- # did not reach the following recipient(s):
141
- #
134
+ if cv = e.match(/\A[ \t]*([^ ]+[@][^ ]+) on[ \t]*.*\z/) ||
135
+ e.match(/\A[ \t]*.+(?:SMTP|smtp)=([^ ]+[@][^ ]+) on[ \t]*.*\z/)
142
136
  # kijitora@example.co.jp on Thu, 29 Apr 2007 16:51:51 -0500
143
- # The recipient name is not recognized
144
- # The MTS-ID of the original message is: c=jp;a= ;p=neko
145
- # ;l=EXCHANGE000000000000000000
146
- # MSEXCH:IMS:KIJITORA CAT:EXAMPLE:EXCHANGE 0 (000C05A6) Unknown Recipient
147
- # mikeneko@example.co.jp on Thu, 29 Apr 2007 16:51:51 -0500
148
- # The recipient name is not recognized
149
- # The MTS-ID of the original message is: c=jp;a= ;p=neko
150
- # ;l=EXCHANGE000000000000000000
151
- # MSEXCH:IMS:KIJITORA CAT:EXAMPLE:EXCHANGE 0 (000C05A6) Unknown Recipient
152
- v = dscontents[-1]
153
-
154
- if cv = e.match(/\A[ \t]*([^ ]+[@][^ ]+) on[ \t]*.*\z/) ||
155
- e.match(/\A[ \t]*.+(?:SMTP|smtp)=([^ ]+[@][^ ]+) on[ \t]*.*\z/)
156
- # kijitora@example.co.jp on Thu, 29 Apr 2007 16:51:51 -0500
157
- # kijitora@example.com on 4/29/99 9:19:59 AM
158
- if v['recipient']
159
- # There are multiple recipient addresses in the message body.
160
- dscontents << Sisimai::Lhost.DELIVERYSTATUS
161
- v = dscontents[-1]
162
- end
163
- v['recipient'] = cv[1]
164
- v['msexch'] = false
165
- recipients += 1
137
+ # kijitora@example.com on 4/29/99 9:19:59 AM
138
+ if v['recipient']
139
+ # There are multiple recipient addresses in the message body.
140
+ dscontents << Sisimai::Lhost.DELIVERYSTATUS
141
+ v = dscontents[-1]
142
+ end
143
+ v['recipient'] = cv[1]
144
+ v['msexch'] = false
145
+ recipients += 1
166
146
 
167
- elsif cv = e.match(/\A[ \t]+(MSEXCH:.+)\z/)
168
- # MSEXCH:IMS:KIJITORA CAT:EXAMPLE:EXCHANGE 0 (000C05A6) Unknown Recipient
169
- v['diagnosis'] ||= ''
170
- v['diagnosis'] << cv[1]
147
+ elsif cv = e.match(/\A[ \t]+(MSEXCH:.+)\z/)
148
+ # MSEXCH:IMS:KIJITORA CAT:EXAMPLE:EXCHANGE 0 (000C05A6) Unknown Recipient
149
+ v['diagnosis'] ||= ''
150
+ v['diagnosis'] << cv[1]
151
+ else
152
+ next if v['msexch']
153
+ if v['diagnosis'].to_s.start_with?('MSEXCH:')
154
+ # Continued from MEEXCH in the previous line
155
+ v['msexch'] = true
156
+ v['diagnosis'] << ' ' << e
157
+ statuspart = true
171
158
  else
172
- next if v['msexch']
173
- if v['diagnosis'].to_s.start_with?('MSEXCH:')
174
- # Continued from MEEXCH in the previous line
175
- v['msexch'] = true
176
- v['diagnosis'] << ' ' << e
177
- statuspart = true
178
- else
179
- # Error message in the body part
180
- v['alterrors'] ||= ''
181
- v['alterrors'] << ' ' << e
182
- end
159
+ # Error message in the body part
160
+ v['alterrors'] ||= ''
161
+ v['alterrors'] << ' ' << e
183
162
  end
184
- else
185
- # Your message
186
- #
163
+ end
164
+ else
165
+ # Your message
166
+ #
167
+ # To: shironeko@example.jp
168
+ # Subject: ...
169
+ # Sent: Thu, 29 Apr 2010 18:14:35 +0000
170
+ #
171
+ if cv = e.match(/\A[ \t]+To:[ \t]+(.+)\z/)
187
172
  # To: shironeko@example.jp
188
- # Subject: ...
189
- # Sent: Thu, 29 Apr 2010 18:14:35 +0000
190
- #
191
- if cv = e.match(/\A[ \t]+To:[ \t]+(.+)\z/)
192
- # To: shironeko@example.jp
193
- next unless connheader['to'].empty?
194
- connheader['to'] = cv[1]
195
- connvalues += 1
173
+ next unless connheader['to'].empty?
174
+ connheader['to'] = cv[1]
175
+ connvalues += 1
196
176
 
197
- elsif cv = e.match(/\A[ \t]+Subject:[ \t]+(.+)\z/)
198
- # Subject: ...
199
- next unless connheader['subject'].empty?
200
- connheader['subject'] = cv[1]
201
- connvalues += 1
177
+ elsif cv = e.match(/\A[ \t]+Subject:[ \t]+(.+)\z/)
178
+ # Subject: ...
179
+ next unless connheader['subject'].empty?
180
+ connheader['subject'] = cv[1]
181
+ connvalues += 1
202
182
 
203
- elsif cv = e.match(%r|\A[ \t]+Sent:[ \t]+([A-Z][a-z]{2},.+[-+]\d{4})\z|) ||
204
- e.match(%r|\A[ \t]+Sent:[ \t]+(\d+[/]\d+[/]\d+[ \t]+\d+:\d+:\d+[ \t].+)|)
205
- # Sent: Thu, 29 Apr 2010 18:14:35 +0000
206
- # Sent: 4/29/99 9:19:59 AM
207
- next unless connheader['date'].empty?
208
- connheader['date'] = cv[1]
209
- connvalues += 1
210
- end
183
+ elsif cv = e.match(%r|\A[ \t]+Sent:[ \t]+([A-Z][a-z]{2},.+[-+]\d{4})\z|) ||
184
+ e.match(%r|\A[ \t]+Sent:[ \t]+(\d+[/]\d+[/]\d+[ \t]+\d+:\d+:\d+[ \t].+)|)
185
+ # Sent: Thu, 29 Apr 2010 18:14:35 +0000
186
+ # Sent: 4/29/99 9:19:59 AM
187
+ next unless connheader['date'].empty?
188
+ connheader['date'] = cv[1]
189
+ connvalues += 1
211
190
  end
212
191
  end
213
192
  end
@@ -244,15 +223,14 @@ module Sisimai::Lhost
244
223
  e.each_key { |a| e[a] ||= '' }
245
224
  end
246
225
 
247
- if rfc822list.empty?
226
+ if emailsteak[1].empty?
248
227
  # When original message does not included in the bounce message
249
- rfc822list << ('From: ' << connheader['to'])
250
- rfc822list << ('Date: ' << connheader['date'])
251
- rfc822list << ('Subject: ' << connheader['subject'])
228
+ emailsteak[1] << ('From: ' << connheader['to'] << "\n")
229
+ emailsteak[1] << ('Date: ' << connheader['date'] << "\n")
230
+ emailsteak[1] << ('Subject: ' << connheader['subject'] << "\n")
252
231
  end
253
232
 
254
- rfc822part = Sisimai::RFC5322.weedout(rfc822list)
255
- return { 'ds' => dscontents, 'rfc822' => rfc822part }
233
+ return { 'ds' => dscontents, 'rfc822' => emailsteak[1] }
256
234
  end
257
235
 
258
236
  end