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.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/ChangeLog.md +50 -0
- data/README-JA.md +10 -37
- data/README.md +10 -37
- data/lib/sisimai.rb +15 -64
- data/lib/sisimai/address.rb +13 -17
- data/lib/sisimai/arf.rb +4 -4
- data/lib/sisimai/data.rb +3 -5
- data/lib/sisimai/lhost.rb +0 -14
- data/lib/sisimai/lhost/activehunter.rb +31 -55
- data/lib/sisimai/lhost/amavis.rb +41 -66
- data/lib/sisimai/lhost/amazonses.rb +189 -235
- data/lib/sisimai/lhost/amazonworkmail.rb +48 -71
- data/lib/sisimai/lhost/aol.rb +49 -75
- data/lib/sisimai/lhost/apachejames.rb +60 -83
- data/lib/sisimai/lhost/bigfoot.rb +61 -85
- data/lib/sisimai/lhost/biglobe.rb +40 -62
- data/lib/sisimai/lhost/courier.rb +60 -82
- data/lib/sisimai/lhost/domino.rb +50 -76
- data/lib/sisimai/lhost/einsundeins.rb +57 -55
- data/lib/sisimai/lhost/exchange2003.rb +79 -101
- data/lib/sisimai/lhost/exchange2007.rb +66 -74
- data/lib/sisimai/lhost/exim.rb +119 -142
- data/lib/sisimai/lhost/ezweb.rb +53 -73
- data/lib/sisimai/lhost/facebook.rb +49 -75
- data/lib/sisimai/lhost/fml.rb +25 -50
- data/lib/sisimai/lhost/gmx.rb +55 -79
- data/lib/sisimai/lhost/google.rb +39 -66
- data/lib/sisimai/lhost/gsuite.rb +74 -94
- data/lib/sisimai/lhost/imailserver.rb +34 -67
- data/lib/sisimai/lhost/interscanmss.rb +33 -67
- data/lib/sisimai/lhost/kddi.rb +30 -52
- data/lib/sisimai/lhost/mailfoundry.rb +35 -57
- data/lib/sisimai/lhost/mailmarshalsmtp.rb +66 -89
- data/lib/sisimai/lhost/mailru.rb +51 -76
- data/lib/sisimai/lhost/mcafee.rb +53 -79
- data/lib/sisimai/lhost/messagelabs.rb +49 -75
- data/lib/sisimai/lhost/messagingserver.rb +91 -113
- data/lib/sisimai/lhost/mfilter.rb +50 -70
- data/lib/sisimai/lhost/mxlogic.rb +38 -63
- data/lib/sisimai/lhost/notes.rb +53 -82
- data/lib/sisimai/lhost/office365.rb +64 -81
- data/lib/sisimai/lhost/opensmtpd.rb +30 -52
- data/lib/sisimai/lhost/outlook.rb +49 -75
- data/lib/sisimai/lhost/postfix.rb +116 -117
- data/lib/sisimai/lhost/qmail.rb +33 -55
- data/lib/sisimai/lhost/receivingses.rb +49 -75
- data/lib/sisimai/lhost/sendgrid.rb +68 -203
- data/lib/sisimai/lhost/sendmail.rb +101 -125
- data/lib/sisimai/lhost/surfcontrol.rb +53 -79
- data/lib/sisimai/lhost/userdefined.rb +15 -35
- data/lib/sisimai/lhost/v5sendmail.rb +59 -89
- data/lib/sisimai/lhost/verizon.rb +75 -124
- data/lib/sisimai/lhost/x1.rb +30 -54
- data/lib/sisimai/lhost/x2.rb +28 -52
- data/lib/sisimai/lhost/x3.rb +44 -68
- data/lib/sisimai/lhost/x4.rb +34 -58
- data/lib/sisimai/lhost/x5.rb +42 -70
- data/lib/sisimai/lhost/yahoo.rb +44 -68
- data/lib/sisimai/lhost/yandex.rb +59 -85
- data/lib/sisimai/lhost/zoho.rb +54 -78
- data/lib/sisimai/mail.rb +5 -9
- data/lib/sisimai/mail/maildir.rb +10 -14
- data/lib/sisimai/mail/mbox.rb +8 -12
- data/lib/sisimai/mail/memory.rb +5 -9
- data/lib/sisimai/mail/stdin.rb +7 -11
- data/lib/sisimai/mda.rb +2 -2
- data/lib/sisimai/message.rb +51 -154
- data/lib/sisimai/mime.rb +2 -2
- data/lib/sisimai/order.rb +2 -27
- data/lib/sisimai/reason.rb +3 -5
- data/lib/sisimai/rfc1894.rb +1 -1
- data/lib/sisimai/rfc3464.rb +29 -29
- data/lib/sisimai/rfc3834.rb +7 -6
- data/lib/sisimai/rfc5322.rb +20 -31
- data/lib/sisimai/rhost/franceptt.rb +120 -24
- data/lib/sisimai/rhost/iua.rb +1 -1
- data/lib/sisimai/smtp/error.rb +7 -7
- data/lib/sisimai/version.rb +1 -1
- data/set-of-emails/maildir/bsd/email-einsundeins-03.eml +66 -0
- data/set-of-emails/maildir/bsd/email-exchange2007-05.eml +1469 -0
- data/set-of-emails/maildir/bsd/email-exchange2007-06.eml +764 -0
- data/set-of-emails/maildir/bsd/email-postfix-64.eml +96 -0
- data/set-of-emails/maildir/bsd/rfc3834-03.eml +26 -0
- data/set-of-emails/maildir/bsd/rhost-franceptt-04.eml +66 -0
- data/set-of-emails/maildir/bsd/rhost-franceptt-05.eml +96 -0
- data/set-of-emails/maildir/bsd/rhost-franceptt-06.eml +100 -0
- data/set-of-emails/maildir/bsd/rhost-franceptt-07.eml +97 -0
- data/set-of-emails/maildir/bsd/rhost-franceptt-08.eml +78 -0
- data/set-of-emails/maildir/bsd/rhost-franceptt-10.eml +79 -0
- data/set-of-emails/maildir/bsd/rhost-franceptt-11.eml +96 -0
- metadata +14 -9
- data/lib/sisimai/bite.rb +0 -42
- data/lib/sisimai/bite/email.rb +0 -18
- data/lib/sisimai/bite/json.rb +0 -16
- data/lib/sisimai/message/email.rb +0 -26
- data/lib/sisimai/message/json.rb +0 -24
- data/lib/sisimai/order/email.rb +0 -20
- data/lib/sisimai/order/json.rb +0 -16
data/lib/sisimai/mail.rb
CHANGED
@@ -3,15 +3,11 @@ module Sisimai
|
|
3
3
|
# wrapper class of Sisimai::Mail::Mbox and Sisimai::Mail::Maildir classes.
|
4
4
|
class Mail
|
5
5
|
# Imported from p5-Sisimail/lib/Sisimai/Mail.pm
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
:mail, # [Sisimai::Mail::[Mbox,Maildir,Memory,STDIN]] Object
|
12
|
-
]
|
13
|
-
@@roaccessors.each { |e| attr_reader e }
|
14
|
-
@@rwaccessors.each { |e| attr_accessor e }
|
6
|
+
# :path [String] path to mbox or Maildir/
|
7
|
+
# :type [String] Data type: mailbox, maildir, or stdin
|
8
|
+
# :mail [Sisimai::Mail::[Mbox,Maildir,Memory,STDIN]] Object
|
9
|
+
attr_reader :path, :type
|
10
|
+
attr_accessor :mail
|
15
11
|
|
16
12
|
# Constructor of Sisimai::Mail
|
17
13
|
# @param [String] argv1 Path to mbox or Maildir/
|
data/lib/sisimai/mail/maildir.rb
CHANGED
@@ -4,19 +4,15 @@ module Sisimai
|
|
4
4
|
# Maildir/ directory.
|
5
5
|
class Maildir
|
6
6
|
# Imported from p5-Sisimail/lib/Sisimai/Mail/Maildir.pm
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
]
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
:handle, # [IO::Dir] Directory handle
|
17
|
-
]
|
18
|
-
@@roaccessors.each { |e| attr_reader e }
|
19
|
-
@@rwaccessors.each { |e| attr_accessor e }
|
7
|
+
# :dir [String] Path to Maildir/
|
8
|
+
# :size [Integer] The number of entires in the directory
|
9
|
+
# :path [String] Path to each file
|
10
|
+
# :file, [String] Each file name of a mail in the Maildir/
|
11
|
+
# :inodes [Array] i-node List of files in the Maildir/
|
12
|
+
# :count [Integer] The number of file has read
|
13
|
+
# :handle [IO::Dir] Directory handle
|
14
|
+
attr_reader :dir, :size
|
15
|
+
attr_accessor :path, :file, :inodes, :count, :handle
|
20
16
|
|
21
17
|
# Constructor of Sisimai::Mail::Maildir
|
22
18
|
# @param [String] argvs Path to Maildir/
|
@@ -54,7 +50,7 @@ module Sisimai
|
|
54
50
|
next unless File.readable?(emailindir)
|
55
51
|
|
56
52
|
emailinode = File.stat(emailindir).ino
|
57
|
-
next if self.inodes
|
53
|
+
next if self.inodes[emailinode]
|
58
54
|
|
59
55
|
File.open(emailindir, 'r:UTF-8') do |f|
|
60
56
|
readbuffer = f.read
|
data/lib/sisimai/mail/mbox.rb
CHANGED
@@ -3,18 +3,14 @@ module Sisimai
|
|
3
3
|
# Sisimai::Mail::Mbox is a mailbox file (UNIX mbox) reader.
|
4
4
|
class Mbox
|
5
5
|
# Imported from p5-Sisimail/lib/Sisimai/Mail/Mbox.pm
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
]
|
12
|
-
|
13
|
-
|
14
|
-
:handle, # [IO::File] File handle
|
15
|
-
]
|
16
|
-
@@roaccessors.each { |e| attr_reader e }
|
17
|
-
@@rwaccessors.each { |e| attr_accessor e }
|
6
|
+
# :dir [String] Directory name of the mbox
|
7
|
+
# :file [String] File name of the mbox
|
8
|
+
# :path [String] Path to mbox
|
9
|
+
# :size [Integer] File size of the mbox
|
10
|
+
# :offset [Integer] Offset position for seeking
|
11
|
+
# :handle [IO::File] File handle
|
12
|
+
attr_reader :dir, :file, :path, :size
|
13
|
+
attr_accessor :offset, :handle
|
18
14
|
|
19
15
|
# Constructor of Sisimai::Mail::Mbox
|
20
16
|
# @param [String] argv1 Path to mbox
|
data/lib/sisimai/mail/memory.rb
CHANGED
@@ -3,15 +3,11 @@ module Sisimai
|
|
3
3
|
# Sisimai::Mail::Memory is a class for reading an email string
|
4
4
|
class Memory
|
5
5
|
# Imported from p5-Sisimail/lib/Sisimai/Mail/Memory.pm
|
6
|
-
|
7
|
-
|
8
|
-
]
|
9
|
-
|
10
|
-
|
11
|
-
:offset, # [Integer] Index of ":data"
|
12
|
-
]
|
13
|
-
@@roaccessors.each { |e| attr_reader e }
|
14
|
-
@@rwaccessors.each { |e| attr_accessor e }
|
6
|
+
# :size [Integer] data size of the email text
|
7
|
+
# :data [Array] Entire bounce mail message
|
8
|
+
# :offset [Integer] Index of ":data"
|
9
|
+
attr_reader :size
|
10
|
+
attr_accessor :data, :offset
|
15
11
|
|
16
12
|
# Constructor of Sisimai::Mail::Memory
|
17
13
|
# @param [String] argv1 Entire email string
|
data/lib/sisimai/mail/stdin.rb
CHANGED
@@ -4,17 +4,13 @@ module Sisimai
|
|
4
4
|
# STDIN
|
5
5
|
class STDIN
|
6
6
|
# Imported from p5-Sisimail/lib/Sisimai/Mail/STDIN.pm
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
]
|
12
|
-
|
13
|
-
|
14
|
-
:handle, # [IO::File] File handle
|
15
|
-
]
|
16
|
-
@@roaccessors.each { |e| attr_reader e }
|
17
|
-
@@rwaccessors.each { |e| attr_accessor e }
|
7
|
+
# :path [String] Path to mbox
|
8
|
+
# :name [String] File name of the mbox
|
9
|
+
# :size [Integer] File size of the mbox
|
10
|
+
# :offset [Integer] Offset position for seeking
|
11
|
+
# :handle [IO::File] File handle
|
12
|
+
attr_reader :path, :name, :size
|
13
|
+
attr_accessor :offset, :handle
|
18
14
|
|
19
15
|
# Constructor of Sisimai::Mail::STDIN
|
20
16
|
# @param [IO::STDIN] stdin Standard-In
|
data/lib/sisimai/mda.rb
CHANGED
@@ -91,10 +91,10 @@ module Sisimai
|
|
91
91
|
agentname0 = '' # [String] MDA name
|
92
92
|
reasonname = '' # [String] Error reason
|
93
93
|
bouncemesg = '' # [String] Error message
|
94
|
-
|
94
|
+
bodyslices = mbody.split("\n")
|
95
95
|
linebuffer = []
|
96
96
|
|
97
|
-
while e =
|
97
|
+
while e = bodyslices.shift do
|
98
98
|
# Check each line with each MDA's symbol regular expression.
|
99
99
|
if agentname0 == ''
|
100
100
|
# Try to match with each regular expression
|
data/lib/sisimai/message.rb
CHANGED
@@ -5,6 +5,13 @@ module Sisimai
|
|
5
5
|
# method is not a bounce email, the method returns nil.
|
6
6
|
class Message
|
7
7
|
# Imported from p5-Sisimail/lib/Sisimai/Message.pm
|
8
|
+
# :from [String] UNIX From line
|
9
|
+
# :header [Hash] Header part of an email
|
10
|
+
# :ds [Array] Parsed data by Sisimai::Lhost::* module
|
11
|
+
# :rfc822 [Hash] Header part of the original message
|
12
|
+
# :catch [Any] The results returned by hook method
|
13
|
+
attr_accessor :from, :header, :ds, :rfc822, :catch
|
14
|
+
|
8
15
|
require 'sisimai/arf'
|
9
16
|
require 'sisimai/mime'
|
10
17
|
require 'sisimai/order'
|
@@ -14,15 +21,6 @@ module Sisimai
|
|
14
21
|
require 'sisimai/rfc3834'
|
15
22
|
require 'sisimai/smtp/error'
|
16
23
|
|
17
|
-
@@rwaccessors = [
|
18
|
-
:from, # [String] UNIX From line
|
19
|
-
:header, # [Hash] Header part of an email
|
20
|
-
:ds, # [Array] Parsed data by Sisimai::Lhost::* module
|
21
|
-
:rfc822, # [Hash] Header part of the original message
|
22
|
-
:catch, # [Any] The results returned by hook method
|
23
|
-
]
|
24
|
-
@@rwaccessors.each { |e| attr_accessor e }
|
25
|
-
|
26
24
|
DefaultSet = Sisimai::Order.another
|
27
25
|
ExtHeaders = Sisimai::Order.headers
|
28
26
|
SubjectTab = Sisimai::Order.by('subject')
|
@@ -47,31 +45,19 @@ module Sisimai
|
|
47
45
|
def initialize(data: '', **argvs)
|
48
46
|
return nil if data.empty?
|
49
47
|
|
50
|
-
email = data
|
51
|
-
input = email.is_a?(Hash) ? 'json' : 'email'
|
48
|
+
email = data.scrub('?').gsub("\r\n", "\n")
|
52
49
|
field = argvs[:field] || []
|
53
50
|
|
54
|
-
if input == 'email'
|
55
|
-
# Email message
|
56
|
-
return nil if email.empty?
|
57
|
-
email = email.scrub('?').gsub("\r\n", "\n")
|
58
|
-
end
|
59
|
-
|
60
51
|
unless field.is_a? Array
|
61
52
|
# Unsupported value in "field"
|
62
53
|
warn ' ***warning: "field" accepts an array reference only'
|
63
54
|
return nil
|
64
55
|
end
|
65
56
|
|
66
|
-
methodargv = {
|
67
|
-
'data' => email,
|
68
|
-
'hook' => argvs[:hook] || nil,
|
69
|
-
'field' => field,
|
70
|
-
'input' => input,
|
71
|
-
}
|
57
|
+
methodargv = { 'data' => email, 'hook' => argvs[:hook] || nil, 'field' => field }
|
72
58
|
[:load, :order].each do |e|
|
73
59
|
# Order of MTA modules
|
74
|
-
next unless argvs
|
60
|
+
next unless argvs[e]
|
75
61
|
next unless argvs[e].is_a? Array
|
76
62
|
next if argvs[e].empty?
|
77
63
|
methodargv[e.to_s] = argvs[e]
|
@@ -79,7 +65,7 @@ module Sisimai
|
|
79
65
|
|
80
66
|
datasource = Sisimai::Message.make(methodargv)
|
81
67
|
return nil unless datasource
|
82
|
-
return nil unless datasource
|
68
|
+
return nil unless datasource['ds']
|
83
69
|
|
84
70
|
@from = datasource['from']
|
85
71
|
@header = datasource['header']
|
@@ -120,52 +106,39 @@ module Sisimai
|
|
120
106
|
}
|
121
107
|
tobeloaded = Sisimai::Message.load(methodargv)
|
122
108
|
|
123
|
-
|
124
|
-
|
125
|
-
# 1. Split email data to headers and a body part.
|
126
|
-
return nil unless aftersplit = Sisimai::Message.divideup(email)
|
127
|
-
|
128
|
-
# 2. Convert email headers from text to hash reference
|
129
|
-
headerargv = {
|
130
|
-
'extheaders' => ExtHeaders,
|
131
|
-
'tryonfirst' => [],
|
132
|
-
'extrafield' => argvs['field'] || [],
|
133
|
-
}
|
134
|
-
processing['from'] = aftersplit['from']
|
135
|
-
processing['header'] = Sisimai::Message.headers(aftersplit['header'], headerargv)
|
136
|
-
|
137
|
-
# 3. Check headers for detecting MTA modules
|
138
|
-
if headerargv['tryonfirst'].empty?
|
139
|
-
headerargv['tryonfirst'] += Sisimai::Message.makeorder(processing['header'])
|
140
|
-
end
|
109
|
+
# 1. Split email data to headers and a body part.
|
110
|
+
return nil unless aftersplit = Sisimai::Message.divideup(email)
|
141
111
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
'hook' => hookmethod,
|
155
|
-
'json' => argvs['data'],
|
156
|
-
'tobeloaded' => tobeloaded.concat(Sisimai::Order.forjson),
|
157
|
-
}
|
158
|
-
return nil unless bouncedata = Sisimai::Message.adapt(methodargv)
|
112
|
+
# 2. Convert email headers from text to hash reference
|
113
|
+
headerargv = {
|
114
|
+
'extheaders' => ExtHeaders,
|
115
|
+
'tryonfirst' => [],
|
116
|
+
'extrafield' => argvs['field'] || [],
|
117
|
+
}
|
118
|
+
processing['from'] = aftersplit['from']
|
119
|
+
processing['header'] = Sisimai::Message.headers(aftersplit['header'], headerargv)
|
120
|
+
|
121
|
+
# 3. Check headers for detecting MTA modules
|
122
|
+
if headerargv['tryonfirst'].empty?
|
123
|
+
headerargv['tryonfirst'] += Sisimai::Message.makeorder(processing['header'])
|
159
124
|
end
|
160
|
-
return nil if bouncedata.empty?
|
161
125
|
|
126
|
+
# 4. Rewrite message body for detecting the bounce reason
|
127
|
+
methodargv = {
|
128
|
+
'hook' => hookmethod,
|
129
|
+
'mail' => processing,
|
130
|
+
'body' => aftersplit['body'],
|
131
|
+
'tryonfirst' => headerargv['tryonfirst'],
|
132
|
+
'tobeloaded' => tobeloaded,
|
133
|
+
}
|
134
|
+
return nil unless bouncedata = Sisimai::Message.parse(methodargv)
|
135
|
+
return nil if bouncedata.empty?
|
162
136
|
%w|ds catch rfc822|.each { |e| processing[e] = bouncedata[e] }
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
end
|
137
|
+
|
138
|
+
# 5. Rewrite headers of the original message in the body part
|
139
|
+
p = bouncedata['rfc822']
|
140
|
+
p = aftersplit['body'] if p.empty?
|
141
|
+
processing['rfc822'] = p.is_a?(::String) ? Sisimai::Message.takeapart(p) : p
|
169
142
|
|
170
143
|
return processing
|
171
144
|
end
|
@@ -182,7 +155,7 @@ module Sisimai
|
|
182
155
|
|
183
156
|
%w[load order].each do |e|
|
184
157
|
# The order of MTA modules specified by user
|
185
|
-
next unless argvs
|
158
|
+
next unless argvs[e]
|
186
159
|
next unless argvs[e].is_a? Array
|
187
160
|
next if argvs[e].empty?
|
188
161
|
|
@@ -198,7 +171,6 @@ module Sisimai
|
|
198
171
|
warn ' ***warning: Failed to load ' << v
|
199
172
|
next
|
200
173
|
end
|
201
|
-
next unless argvs.input == 'email'
|
202
174
|
|
203
175
|
Module.const_get(v).headerlist.each do |w|
|
204
176
|
# Get header name which required user defined MTA module
|
@@ -252,7 +224,7 @@ module Sisimai
|
|
252
224
|
structured = {}
|
253
225
|
extheaders = argvs['extheaders'] || []
|
254
226
|
extrafield = argvs['extrafield'] || []
|
255
|
-
|
227
|
+
headslices = heads.split("\n")
|
256
228
|
|
257
229
|
HeaderList.each { |e| structured[e] = nil }
|
258
230
|
HeaderList.each { |e| allheaders[e] = true }
|
@@ -263,11 +235,11 @@ module Sisimai
|
|
263
235
|
extrafield.each { |e| allheaders[e] = true }
|
264
236
|
end
|
265
237
|
|
266
|
-
while e =
|
238
|
+
while e = headslices.shift do
|
267
239
|
# Convert email headers to hash
|
268
240
|
if cv = e.match(/\A[ \t]+(.+)\z/)
|
269
241
|
# Continued (foled) header value from the previous line
|
270
|
-
next unless allheaders
|
242
|
+
next unless allheaders[currheader]
|
271
243
|
|
272
244
|
# Header line continued from the previous line
|
273
245
|
if structured[currheader].is_a? Array
|
@@ -281,12 +253,11 @@ module Sisimai
|
|
281
253
|
# split the line into a header name and a header content
|
282
254
|
(lhs, rhs) = e.split(/:[ ]*/, 2)
|
283
255
|
currheader = lhs ? lhs.downcase : ''
|
284
|
-
next unless allheaders
|
256
|
+
next unless allheaders[currheader]
|
285
257
|
|
286
|
-
if IsMultiple
|
258
|
+
if IsMultiple[currheader]
|
287
259
|
# Such as 'Received' header, there are multiple headers in a single
|
288
260
|
# email message.
|
289
|
-
#rhs = rhs.tr("\t", ' ').squeeze(' ')
|
290
261
|
rhs = rhs.tr("\t", ' ')
|
291
262
|
structured[currheader] << rhs
|
292
263
|
else
|
@@ -320,7 +291,7 @@ module Sisimai
|
|
320
291
|
return nil unless block['header']
|
321
292
|
return nil unless block['body']
|
322
293
|
|
323
|
-
if block['header']
|
294
|
+
if block['header'].start_with?('From ')
|
324
295
|
# From MAILER-DAEMON Tue Feb 11 00:00:00 2014
|
325
296
|
block['from'] = block['header'].split(/\n/, 2)[0].delete("\r")
|
326
297
|
else
|
@@ -345,9 +316,9 @@ module Sisimai
|
|
345
316
|
previousfn = '' # Previous field name
|
346
317
|
asciiarmor = {} # Header names which has MIME encoded value
|
347
318
|
headerpart = {} # Required headers in the original message part
|
348
|
-
|
319
|
+
headslices = heads.split("\n")
|
349
320
|
|
350
|
-
while e =
|
321
|
+
while e = headslices.shift do
|
351
322
|
# Header name as a key, The value of header as a value
|
352
323
|
if e.start_with?(' ', "\t")
|
353
324
|
# Continued (foled) header value from the previous line
|
@@ -376,7 +347,7 @@ module Sisimai
|
|
376
347
|
lhs.downcase!
|
377
348
|
previousfn = ''
|
378
349
|
|
379
|
-
next unless RFC822Head
|
350
|
+
next unless RFC822Head[lhs]
|
380
351
|
previousfn = lhs
|
381
352
|
headerpart[previousfn] = rhs unless headerpart[previousfn]
|
382
353
|
end
|
@@ -520,7 +491,7 @@ module Sisimai
|
|
520
491
|
argvs['tryonfirst'].concat(DefaultSet)
|
521
492
|
while r = argvs['tryonfirst'].shift do
|
522
493
|
# Try MTA module candidates
|
523
|
-
next if haveloaded
|
494
|
+
next if haveloaded[r]
|
524
495
|
require r.gsub('::', '/').downcase
|
525
496
|
parseddata = Module.const_get(r).make(mailheader, bodystring)
|
526
497
|
haveloaded[r] = true
|
@@ -547,80 +518,6 @@ module Sisimai
|
|
547
518
|
return parseddata
|
548
519
|
end
|
549
520
|
|
550
|
-
# Parse bounce object with each MTA(JSON) module
|
551
|
-
# @param [Hash] argvs Processing message entity.
|
552
|
-
# @param options argvs [Hash] json Decoded bounce object
|
553
|
-
# @param options argvs [Proc] hook Hook method to be called
|
554
|
-
# @return [Hash] Parsed and structured bounce mails
|
555
|
-
def self.adapt(argvs)
|
556
|
-
Sisimai::Message.warn(self.name, 'gone')
|
557
|
-
bouncedata = argvs['json'] || {}
|
558
|
-
hookmethod = argvs['hook'] || nil
|
559
|
-
havecaught = nil
|
560
|
-
haveloaded = {}
|
561
|
-
parseddata = nil
|
562
|
-
|
563
|
-
# Call the hook method
|
564
|
-
if hookmethod.is_a? Proc
|
565
|
-
# Execute hook method
|
566
|
-
begin
|
567
|
-
p = {
|
568
|
-
'datasrc' => 'json',
|
569
|
-
'headers' => nil,
|
570
|
-
'message' => nil,
|
571
|
-
'bounces' => argvs['json']
|
572
|
-
}
|
573
|
-
havecaught = hookmethod.call(p)
|
574
|
-
rescue StandardError => ce
|
575
|
-
warn ' ***warning: Something is wrong in hook method :' << ce.to_s
|
576
|
-
end
|
577
|
-
end
|
578
|
-
|
579
|
-
catch :ADAPTOR do
|
580
|
-
while true
|
581
|
-
# 1. User-Defined Module
|
582
|
-
# 2. MTA(JSON) Module Candidates to be tried on first
|
583
|
-
# 3. Sisimai::Lhost::*
|
584
|
-
#
|
585
|
-
argvs['tobeloaded'].each do |r|
|
586
|
-
# Call user defined MTA(JSON) modules
|
587
|
-
next if haveloaded[r]
|
588
|
-
begin
|
589
|
-
require r.gsub('::', '/').downcase
|
590
|
-
rescue LoadError => ce
|
591
|
-
warn ' ***warning: Failed to load ' << ce.to_s
|
592
|
-
next
|
593
|
-
end
|
594
|
-
parseddata = Module.const_get(r).json(bouncedata)
|
595
|
-
haveloaded[r] = true
|
596
|
-
throw :ADAPTOR if parseddata
|
597
|
-
end
|
598
|
-
|
599
|
-
break # as of now, we have no sample JSON data for coding this block
|
600
|
-
end
|
601
|
-
end
|
602
|
-
return nil unless parseddata
|
603
|
-
return nil unless parseddata['ds']
|
604
|
-
|
605
|
-
parseddata['catch'] = havecaught
|
606
|
-
parseddata['ds'].each { |e| e['agent'].sub!(/\AEmail::/, 'JSON::') }
|
607
|
-
return parseddata
|
608
|
-
end
|
609
|
-
|
610
|
-
# @abstract Print warnings about an obsoleted method. This method will be
|
611
|
-
# removed at the future release of Sisimai
|
612
|
-
# @until v4.25.5
|
613
|
-
def self.warn(whois = '', useit = nil)
|
614
|
-
label = ' ***warning:'
|
615
|
-
methodname = caller[0][/`.*'/][1..-2]
|
616
|
-
messageset = sprintf("%s %s.%s is marked as obsoleted", label, whois, methodname)
|
617
|
-
|
618
|
-
useit ||= methodname
|
619
|
-
messageset << sprintf(" and will be removed at %s.", Sisimai::Lhost.removedat)
|
620
|
-
messageset << sprintf(" Use %s.%s instead.\n", self.name, useit) if useit != 'gone'
|
621
|
-
Kernel.warn messageset
|
622
|
-
end
|
623
|
-
|
624
521
|
end
|
625
522
|
end
|
626
523
|
|