sisimai 4.18.0-java → 4.18.1-java
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 +1 -0
- data/ANALYTICAL-PRECISION +8 -8
- data/Changes +9 -0
- data/Gemfile +0 -4
- data/README-JA.md +3 -3
- data/README.md +3 -3
- data/lib/sisimai/mail.rb +0 -2
- data/lib/sisimai/mail/stdin.rb +4 -0
- data/lib/sisimai/message.rb +23 -1
- data/lib/sisimai/mime.rb +123 -7
- data/lib/sisimai/msp/us/amazonworkmail.rb +0 -11
- data/lib/sisimai/msp/us/office365.rb +1 -12
- data/lib/sisimai/mta/exchange2007.rb +13 -3
- data/lib/sisimai/order.rb +1 -0
- data/lib/sisimai/reason/norelaying.rb +1 -0
- data/lib/sisimai/reason/rejected.rb +1 -0
- data/lib/sisimai/reason/securityerror.rb +2 -0
- data/lib/sisimai/string.rb +66 -0
- data/lib/sisimai/version.rb +1 -1
- data/set-of-emails/maildir/bsd/sendmail-40.eml +71 -0
- data/sisimai-java.gemspec +6 -1
- data/sisimai.gemspec +6 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: faeb3a937063e9c2ac6f3eb598e3685af17a4df8
|
4
|
+
data.tar.gz: 8b71ea9646c6e9bbd38d95542bb45ed543966935
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 000895ef83533fa8002d30944b14f8e7c57126a206594c2ea7b48902155474e35ea63000973b27ca1a3fa8f7ae0fb6b128c5fc229b5e3c00befe9d41df21f428
|
7
|
+
data.tar.gz: d52bff92353248023dd1c21d47860309643c96ba2ca96d7a423f7839913858f0fa9fb3859c0b33496e8218dc5be03c6157aedcb853658393adb482a38f7ee278
|
data/.travis.yml
CHANGED
data/ANALYTICAL-PRECISION
CHANGED
@@ -4,10 +4,10 @@
|
|
4
4
|
MTA::Activehunter ....... 0/0014 0.0000 TransWARE Active!hunter
|
5
5
|
MTA::ApacheJames ........ 0/0006 0.0000 Java Apache Mail Enterprise Server
|
6
6
|
MTA::Courier ............ 14/0016 0.8750 Courier MTA
|
7
|
-
MTA::Domino .............
|
7
|
+
MTA::Domino ............. 6/0015 0.4000 IBM Domino Server
|
8
8
|
MTA::Exchange2003 ....... 1/0051 0.0196 Microsoft Exchange Server 2003
|
9
|
-
MTA::Exchange2007 .......
|
10
|
-
MTA::Exim ...............
|
9
|
+
MTA::Exchange2007 ....... 4/0006 0.6667 Microsoft Exchange Server 2007
|
10
|
+
MTA::Exim ............... 144/0174 0.8276 Exim
|
11
11
|
MTA::IMailServer ........ 0/0045 0.0000 IPSWITCH IMail Server
|
12
12
|
MTA::InterScanMSS ....... 0/0009 0.0000 Trend Micro InterScan Messaging Security Suite
|
13
13
|
MTA::MXLogic ............ 0/0014 0.0000 McAfee SaaS
|
@@ -18,7 +18,7 @@ MTA::MessagingServer .... 19/0022 0.8636 Oracle Communications Messaging Ser
|
|
18
18
|
MTA::Notes .............. 0/0012 0.0000 Lotus Notes
|
19
19
|
MTA::OpenSMTPD .......... 5/0023 0.2174 OpenSMTPD
|
20
20
|
MTA::Postfix ............ 165/0183 0.9016 Postfix
|
21
|
-
MTA::Sendmail ...........
|
21
|
+
MTA::Sendmail ........... 330/0252 1.0000 V8Sendmail: /usr/sbin/sendmail
|
22
22
|
MTA::SurfControl ........ 6/0008 0.7500 WebSense SurfControl
|
23
23
|
MTA::V5sendmail ......... 0/0386 0.0000 Sendmail version 5
|
24
24
|
MTA::X1 ................. 0/0007 0.0000 Unknown MTA #1
|
@@ -42,7 +42,7 @@ MSP::US::Aol ............ 18/0021 0.8571 Aol Mail: http://www.aol.com
|
|
42
42
|
MSP::US::Bigfoot ........ 2/0002 1.0000 Bigfoot: http://www.bigfoot.com
|
43
43
|
MSP::US::Facebook ....... 3/0003 1.0000 Facebook: https://www.facebook.com
|
44
44
|
MSP::US::Google ......... 58/0062 0.9355 Google Gmail: https://mail.google.com
|
45
|
-
MSP::US::Office365 ......
|
45
|
+
MSP::US::Office365 ...... 8/0011 0.7273 Microsoft Office 365: http://office.microsoft.com/
|
46
46
|
MSP::US::Outlook ........ 19/0021 0.9048 Microsoft Outlook.com: https://www.outlook.com/
|
47
47
|
MSP::US::ReceivingSES ... 0/0007 0.0000 Amazon SES(Receiving): http://aws.amazon.com/ses/
|
48
48
|
MSP::US::SendGrid ....... 7/0012 0.5833 SendGrid: http://sendgrid.com/
|
@@ -50,8 +50,8 @@ MSP::US::Verizon ........ 3/0003 1.0000 Verizon Wireless: http://www.verizo
|
|
50
50
|
MSP::US::Yahoo .......... 0/0009 0.0000 Yahoo! MAIL: https://www.yahoo.com
|
51
51
|
MSP::US::Zoho ........... 0/0011 0.0000 Zoho Mail: https://www.zoho.com
|
52
52
|
ARF ..................... 9/0050 0.1800 Abuse Feedback Reporting Format
|
53
|
-
RFC3464 .................
|
53
|
+
RFC3464 ................. 135/0276 0.4891 Fallback Module for MTAs
|
54
54
|
RFC3834 ................. 0/0004 0.0000 Detector for auto replied message
|
55
55
|
-------------------------------------------------------------------------------
|
56
|
-
bounceHammer 2.7.13p3
|
57
|
-
Sisimai 4.18.
|
56
|
+
bounceHammer 2.7.13p3 1188/2159 0.5503
|
57
|
+
Sisimai 4.18.1 2159/2159 1.0000
|
data/Changes
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
Revision history for Ruby version of Sisimai
|
2
2
|
|
3
|
+
4.18.1 Sun, 11 Sep 2016 20:05:20 +0900 (JST)
|
4
|
+
- Fix bug in Sisimai::Mail::STDIN.read() method reported at issue #61.
|
5
|
+
Thanks to @yaegassy.
|
6
|
+
- Fix bug in Sisimai::MIME.qprintd() reported at #60.
|
7
|
+
- Improved code related to MIME decoding.
|
8
|
+
- Implement Sisimai::String.to_plain() for converting from HTML message to
|
9
|
+
plain text before parsing. The method and related codes are imported from
|
10
|
+
pull-request #197 at p5-Sisimai.
|
11
|
+
|
3
12
|
4.18.0 Mon, 22 Aug 2016 20:40:55 +0900 (JST)
|
4
13
|
- Import pull-request https://github.com/sisimai/rb-Sisimai/pull/59 (soft
|
5
14
|
bounce improvement) from Perl version of Sisimai.
|
data/Gemfile
CHANGED
@@ -3,10 +3,6 @@ source 'https://rubygems.org'
|
|
3
3
|
# Specify your gem's dependencies in sisimai.gemspec
|
4
4
|
gemspec name: 'sisimai'
|
5
5
|
|
6
|
-
# To execute `rake spec` on Travis-CI
|
7
|
-
gem 'oj', '>= 2.14.4', :platform => :ruby
|
8
|
-
gem 'jrjackson', '>= 0.3.8', :platform => :jruby
|
9
|
-
|
10
6
|
group :development, :test do
|
11
7
|
gem 'rake', :require => false
|
12
8
|
gem 'rspec', :require => false
|
data/README-JA.md
CHANGED
@@ -38,7 +38,7 @@ Sisimaiの動作環境についての詳細は
|
|
38
38
|
|
39
39
|
* [Ruby 2.1.0 or later](http://www.ruby-lang.org/)
|
40
40
|
* [__Oj | The fastest JSON parser and object serializer__](https://rubygems.org/gems/oj)
|
41
|
-
* Also works on [JRuby 9.0.
|
41
|
+
* Also works on [JRuby 9.0.4.0 or later](http://jruby.org)
|
42
42
|
* [__JrJackson | A mostly native JRuby wrapper for the java jackson json processor jar__](https://rubygems.org/gems/jrjackson)
|
43
43
|
|
44
44
|
インストール
|
@@ -148,8 +148,8 @@ Perl版Sisimaiとの違い
|
|
148
148
|
| メール解析速度(1000通のメール) | 3.30秒 | 2.33秒 |
|
149
149
|
| インストール方法 | gem install | cpanm |
|
150
150
|
| 依存モジュール数(コアモジュールを除く) | 1モジュール | 2モジュール |
|
151
|
-
| LOC:ソースコードの行数 |
|
152
|
-
| テスト件数(t/,xt/ディレクトリ)
|
151
|
+
| LOC:ソースコードの行数 | 11600行 | 8500行 |
|
152
|
+
| テスト件数(spec/,t/,xt/ディレクトリ) | 97000件 | 177000件 |
|
153
153
|
| ライセンス | 二条項BSD | 二条項BSD |
|
154
154
|
| 開発会社によるサポート契約 | 準備中 | 提供中 |
|
155
155
|
|
data/README.md
CHANGED
@@ -37,7 +37,7 @@ More details about system requirements are available at
|
|
37
37
|
|
38
38
|
* [Ruby 2.1.0 or later](http://www.ruby-lang.org/)
|
39
39
|
* [__Oj | The fastest JSON parser and object serializer__](https://rubygems.org/gems/oj)
|
40
|
-
* Also works on [JRuby 9.0.
|
40
|
+
* Also works on [JRuby 9.0.4.0 or later](http://jruby.org)
|
41
41
|
* [__JrJackson | A mostly native JRuby wrapper for the java jackson json processor jar__](https://rubygems.org/gems/jrjackson)
|
42
42
|
|
43
43
|
Install
|
@@ -148,8 +148,8 @@ and bounceHammer are available at
|
|
148
148
|
| The speed of parsing email(1000 emails) | 3.30s | 2.33s |
|
149
149
|
| How to install | gem install | cpanm |
|
150
150
|
| Dependencies (Except core modules) | 1 modules | 2 modules |
|
151
|
-
| LOC:Source lines of code |
|
152
|
-
| The number of tests
|
151
|
+
| LOC:Source lines of code | 11600 lines | 8500 lines |
|
152
|
+
| The number of tests(spec/,t/,xt/) directory | 97000 tests | 177000 tests |
|
153
153
|
| License | BSD 2-Clause | BSD 2-Clause |
|
154
154
|
| Support Contract provided by Developer | Coming soon | Available |
|
155
155
|
|
data/lib/sisimai/mail.rb
CHANGED
@@ -27,7 +27,6 @@ module Sisimai
|
|
27
27
|
classname = sprintf('%s::STDIN', self.class)
|
28
28
|
parameter['type'] = 'stdin'
|
29
29
|
parameter['path'] = $stdin
|
30
|
-
|
31
30
|
else
|
32
31
|
# The argumenet is a mailbox or a Maildir/.
|
33
32
|
mediatype = File.ftype(argv1)
|
@@ -49,7 +48,6 @@ module Sisimai
|
|
49
48
|
# The argument neither a mailbox nor a Maildir/.
|
50
49
|
classname = sprintf('%s::STDIN', self.class)
|
51
50
|
parameter['type'] = 'stdin'
|
52
|
-
|
53
51
|
end
|
54
52
|
|
55
53
|
return nil unless classname
|
data/lib/sisimai/mail/stdin.rb
CHANGED
data/lib/sisimai/message.rb
CHANGED
@@ -36,6 +36,7 @@ module Sisimai
|
|
36
36
|
DefaultSet = Sisimai::Order.another
|
37
37
|
PatternSet = Sisimai::Order.by('subject')
|
38
38
|
ExtHeaders = Sisimai::Order.headers
|
39
|
+
ReEncoding = Sisimai::MIME.patterns
|
39
40
|
|
40
41
|
# Constructor of Sisimai::Message
|
41
42
|
# @param [String] data Email text data
|
@@ -412,7 +413,7 @@ module Sisimai
|
|
412
413
|
mesgformat = (mailheader['content-type'] || '').downcase
|
413
414
|
ctencoding = (mailheader['content-transfer-encoding'] || '').downcase
|
414
415
|
|
415
|
-
if mesgformat =~ %r
|
416
|
+
if mesgformat =~ %r{text/(?:plain|html);?}
|
416
417
|
# Content-Type: text/plain; charset=UTF-8
|
417
418
|
if ctencoding == 'base64' || ctencoding == 'quoted-printable'
|
418
419
|
# Content-Transfer-Encoding: base64
|
@@ -426,6 +427,27 @@ module Sisimai
|
|
426
427
|
bodystring = Sisimai::MIME.qprintd(bodystring)
|
427
428
|
end
|
428
429
|
end
|
430
|
+
|
431
|
+
if mesgformat =~ %r|text/html;?|
|
432
|
+
# Content-Type: text/html;...
|
433
|
+
bodystring = Sisimai::String.to_plain(bodystring, true)
|
434
|
+
end
|
435
|
+
|
436
|
+
else
|
437
|
+
# NOT text/plain
|
438
|
+
if bodystring =~ ReEncoding[:'quoted-print']
|
439
|
+
# Content-Transfer-Encoding: quoted-printable
|
440
|
+
bodystring = Sisimai::MIME.qprintd(bodystring, mailheader)
|
441
|
+
end
|
442
|
+
|
443
|
+
if bodystring =~ ReEncoding[:'7bit-encoded'] &&
|
444
|
+
cv = bodystring.match(ReEncoding[:'some-iso2022'])
|
445
|
+
# Content-Transfer-Encoding: 7bit
|
446
|
+
# Content-Type: text/plain; charset=ISO-2022-JP
|
447
|
+
unless cv[1].downcase =~ /(?:us-ascii|utf[-]?8)/
|
448
|
+
bodystring = Sisimai::String.to_utf8(bodystring, cv[1])
|
449
|
+
end
|
450
|
+
end
|
429
451
|
end
|
430
452
|
|
431
453
|
# EXPAND_FORWARDED_MESSAGE:
|
data/lib/sisimai/mime.rb
CHANGED
@@ -4,6 +4,22 @@ module Sisimai
|
|
4
4
|
# Imported from p5-Sisimail/lib/Sisimai/MIME.pm
|
5
5
|
class << self
|
6
6
|
require 'base64'
|
7
|
+
require 'sisimai/string'
|
8
|
+
|
9
|
+
ReE = {
|
10
|
+
:'7bit-encoded' => %r/^Content-Transfer-Encoding:[ ]*7bit$/im,
|
11
|
+
:'quoted-print' => %r/^Content-Transfer-Encoding:[ ]*quoted-printable$/im,
|
12
|
+
:'some-iso2022' => %r/^Content-Type:[ ]*.+;[ ]*charset=["']?(iso-2022-[-a-z0-9]+?)['"]?$/im,
|
13
|
+
:'with-charset' => %r/^Content[-]Type:[ ]*.+[;][ ]*charset=['"]?(.+?)['"]?$/i,
|
14
|
+
:'only-charset' => %r/^[\s\t]+charset=['"]?(.+?)['"]?$/i,
|
15
|
+
:'html-message' => %r|^Content-Type:[ ]*text/html;|mi,
|
16
|
+
}
|
17
|
+
|
18
|
+
# Make MIME-Encoding and Content-Type related headers regurlar expression
|
19
|
+
# @return [Array] Regular expressions related to MIME encoding
|
20
|
+
def patterns
|
21
|
+
return ReE
|
22
|
+
end
|
7
23
|
|
8
24
|
# Check that the argument is MIME-Encoded string or not
|
9
25
|
# @param [String] argvs String to be checked
|
@@ -13,7 +29,22 @@ module Sisimai
|
|
13
29
|
return false unless argv1
|
14
30
|
|
15
31
|
argv1 = argv1.delete('"')
|
16
|
-
|
32
|
+
parts = []
|
33
|
+
isnot = false
|
34
|
+
|
35
|
+
if argv1 =~ /[ ]/
|
36
|
+
# Multiple MIME-Encoded strings in a line
|
37
|
+
parts = argv1.split(' ')
|
38
|
+
else
|
39
|
+
parts << argv1
|
40
|
+
end
|
41
|
+
|
42
|
+
parts.each do |e|
|
43
|
+
# Check all the string in the array
|
44
|
+
next if e =~ /[ \t]*=[?][-_0-9A-Za-z]+[?][BbQq][?].+[?]=?[ \t]*\z/
|
45
|
+
isnot = true
|
46
|
+
end
|
47
|
+
return true unless isnot
|
17
48
|
return false
|
18
49
|
end
|
19
50
|
|
@@ -36,7 +67,7 @@ module Sisimai
|
|
36
67
|
|
37
68
|
if self.is_mimeencoded(e)
|
38
69
|
# MIME Encoded string
|
39
|
-
if cv = e.match(/\A=[?]([-_0-9A-Za-z]+)[?]([BbQq])[?](.+)[?]
|
70
|
+
if cv = e.match(/\A=[?]([-_0-9A-Za-z]+)[?]([BbQq])[?](.+)[?]=?\z/)
|
40
71
|
# =?utf-8?B?55m954yr44Gr44KD44KT44GT?=
|
41
72
|
characterset ||= cv[1]
|
42
73
|
encodingname ||= cv[2]
|
@@ -78,10 +109,95 @@ module Sisimai
|
|
78
109
|
|
79
110
|
# Decode MIME Quoted-Printable Encoded string
|
80
111
|
# @param [String] argv1 MIME Encoded text
|
112
|
+
# @param [Hash] heads Email header
|
81
113
|
# @return [String] MIME Decoded text
|
82
|
-
def qprintd(argv1)
|
114
|
+
def qprintd(argv1 = nil, heads = {})
|
83
115
|
return nil unless argv1
|
84
|
-
return argv1.unpack('M').first
|
116
|
+
return argv1.unpack('M').first unless heads['content-type']
|
117
|
+
return argv1.unpack('M').first unless heads['content-type'].size > 0
|
118
|
+
|
119
|
+
# Quoted-printable encoded part is the part of the text
|
120
|
+
boundary00 = Sisimai::MIME.boundary(heads['content-type'], 0)
|
121
|
+
|
122
|
+
# Decoded using unpack('M') entire body string when the boundary string
|
123
|
+
# or "Content-Transfer-Encoding: quoted-printable" are not included in
|
124
|
+
# the message body.
|
125
|
+
return argv1.unpack('M').first if boundary00.size == 0
|
126
|
+
return argv1.unpack('M').first unless argv1 =~ ReE[:'quoted-print']
|
127
|
+
|
128
|
+
boundary01 = Sisimai::MIME.boundary(heads['content-type'], 1)
|
129
|
+
reboundary = {
|
130
|
+
:begin => Regexp.new('\A' + Regexp.escape(boundary00)),
|
131
|
+
:until => Regexp.new(Regexp.escape(boundary01) + '\z')
|
132
|
+
}
|
133
|
+
bodystring = ''
|
134
|
+
notdecoded = ''
|
135
|
+
getencoded = ''
|
136
|
+
|
137
|
+
encodename = nil
|
138
|
+
ctencoding = nil
|
139
|
+
mimeinside = false
|
140
|
+
|
141
|
+
argv1.split("\n").each do |e|
|
142
|
+
# This is a multi-part message in MIME format. Your mail reader does not
|
143
|
+
# understand MIME message format.
|
144
|
+
# --=_gy7C4Gpes0RP4V5Bs9cK4o2Us2ZT57b-3OLnRN+4klS8dTmQ
|
145
|
+
# Content-Type: text/plain; charset=iso-8859-15
|
146
|
+
# Content-Transfer-Encoding: quoted-printable
|
147
|
+
if mimeinside
|
148
|
+
# Quoted-Printable encoded text block
|
149
|
+
if e =~ reboundary[:begin]
|
150
|
+
# The next boundary string has appeared
|
151
|
+
# --=_gy7C4Gpes0RP4V5Bs9cK4o2Us2ZT57b-3OLnRN+4klS8dTmQ
|
152
|
+
getencoded = Sisimai::String.to_utf8(notdecoded.unpack('M').first, encodename)
|
153
|
+
|
154
|
+
bodystring += getencoded
|
155
|
+
bodystring += e + "\n"
|
156
|
+
|
157
|
+
notdecoded = ''
|
158
|
+
mimeinside = false
|
159
|
+
ctencoding = false
|
160
|
+
encodename = nil
|
161
|
+
else
|
162
|
+
# Inside of Queoted printable encoded text
|
163
|
+
notdecoded += e + "\n"
|
164
|
+
end
|
165
|
+
else
|
166
|
+
# NOT Quoted-Printable encoded text block
|
167
|
+
if e =~ /\A[-]{2}[^\s]+[^-]\z/
|
168
|
+
# Start of the boundary block
|
169
|
+
# --=_gy7C4Gpes0RP4V5Bs9cK4o2Us2ZT57b-3OLnRN+4klS8dTmQ
|
170
|
+
unless e == boundary00
|
171
|
+
# New boundary string has appeared
|
172
|
+
boundary00 = e
|
173
|
+
boundary01 = e + '--'
|
174
|
+
reboundary = {
|
175
|
+
:begin => Regexp.new('\A' + Regexp.escape(boundary00)),
|
176
|
+
:until => Regexp.new(Regexp.escape(boundary01) + '\z')
|
177
|
+
}
|
178
|
+
end
|
179
|
+
elsif cv = e.match(ReE[:'with-charset']) ||
|
180
|
+
cv = e.match(ReE[:'only-charset'])
|
181
|
+
# Content-Type: text/plain; charset=ISO-2022-JP
|
182
|
+
encodename = cv[1]
|
183
|
+
mimeinside = true if ctencoding
|
184
|
+
|
185
|
+
elsif e =~ ReE[:'quoted-print']
|
186
|
+
# Content-Transfer-Encoding: quoted-printable
|
187
|
+
ctencoding = true
|
188
|
+
mimeinside = true if encodename
|
189
|
+
|
190
|
+
elsif e =~ reboundary[:until]
|
191
|
+
# The end of boundary block
|
192
|
+
# --=_gy7C4Gpes0RP4V5Bs9cK4o2Us2ZT57b-3OLnRN+4klS8dTmQ--
|
193
|
+
mimeinside = false
|
194
|
+
end
|
195
|
+
|
196
|
+
bodystring += e + "\n"
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
return bodystring
|
85
201
|
end
|
86
202
|
|
87
203
|
# Decode MIME BASE64 Encoded string
|
@@ -106,7 +222,7 @@ module Sisimai
|
|
106
222
|
# @return [String] Boundary string
|
107
223
|
def boundary(argv1 = nil, start = -1)
|
108
224
|
return nil unless argv1
|
109
|
-
value =
|
225
|
+
value = ''
|
110
226
|
|
111
227
|
if cv = argv1.match(/\bboundary=([^ ]+)/)
|
112
228
|
# Content-Type: multipart/mixed; boundary=Apple-Mail-5--931376066
|
@@ -114,10 +230,10 @@ module Sisimai
|
|
114
230
|
# boundary="n6H9lKZh014511.1247824040/mx.example.jp"
|
115
231
|
value = cv[1]
|
116
232
|
value = value.delete(%q|'"|)
|
233
|
+
value = sprintf('--%s', value) if start > -1
|
234
|
+
value = sprintf('%s--', value) if start > 0
|
117
235
|
end
|
118
236
|
|
119
|
-
value = sprintf('--%s', value) if start > -1
|
120
|
-
value = sprintf('%s--', value) if start > 0
|
121
237
|
return value
|
122
238
|
end
|
123
239
|
end
|
@@ -56,17 +56,6 @@ module Sisimai
|
|
56
56
|
end
|
57
57
|
return nil if match < 2
|
58
58
|
|
59
|
-
if mbody =~ /^Content-Transfer-Encoding: quoted-printable$/
|
60
|
-
# This is a multi-part message in MIME format. Your mail reader does not
|
61
|
-
# understand MIME message format.
|
62
|
-
# --=_gy7C4Gpes0RP4V5Bs9cK4o2Us2ZT57b-3OLnRN+4klS8dTmQ
|
63
|
-
# Content-Type: text/plain; charset=iso-8859-15
|
64
|
-
# Content-Transfer-Encoding: quoted-printable
|
65
|
-
require 'sisimai/mime'
|
66
|
-
mbody = mbody.sub(/\A.+?quoted-printable/ms, '')
|
67
|
-
mbody = Sisimai::MIME.qprintd(mbody)
|
68
|
-
end
|
69
|
-
|
70
59
|
dscontents = [Sisimai::MSP.DELIVERYSTATUS]
|
71
60
|
hasdivided = mbody.split("\n")
|
72
61
|
rfc822list = [] # (Array) Each line in message/rfc822 part string
|
@@ -31,7 +31,7 @@ module Sisimai
|
|
31
31
|
%r/\A4[.]7[.]26\z/ => 'securityerror',
|
32
32
|
%r/\A4[.]7[.][56]\d\d\z/ => 'blocked',
|
33
33
|
%r/\A4[.]7[.]8[5-9]\d\z/ => 'blocked',
|
34
|
-
%r/\A5[.]1[.]0\z/ => '
|
34
|
+
%r/\A5[.]1[.]0\z/ => 'userunknown',
|
35
35
|
%r/\A5[.]4[.]1\z/ => 'norelaying',
|
36
36
|
%r/\A5[.]4[.]6\z/ => 'networkerror',
|
37
37
|
%r/\A5[.]6[.]11\z/ => 'contenterror',
|
@@ -108,17 +108,6 @@ module Sisimai
|
|
108
108
|
end
|
109
109
|
return nil if match < 2
|
110
110
|
|
111
|
-
if mbody =~ /^Content-Transfer-Encoding: quoted-printable$/
|
112
|
-
# This is a multi-part message in MIME format. Your mail reader does not
|
113
|
-
# understand MIME message format.
|
114
|
-
# --=_gy7C4Gpes0RP4V5Bs9cK4o2Us2ZT57b-3OLnRN+4klS8dTmQ
|
115
|
-
# Content-Type: text/plain; charset=iso-8859-15
|
116
|
-
# Content-Transfer-Encoding: quoted-printable
|
117
|
-
require 'sisimai/mime'
|
118
|
-
mbody = mbody.sub(/\A.+?quoted-printable/ms, '')
|
119
|
-
mbody = Sisimai::MIME.qprintd(mbody)
|
120
|
-
end
|
121
|
-
|
122
111
|
dscontents = [Sisimai::MSP.DELIVERYSTATUS]
|
123
112
|
hasdivided = mbody.split("\n")
|
124
113
|
rfc822list = [] # (Array) Each line in message/rfc822 part string
|
@@ -21,9 +21,18 @@ module Sisimai
|
|
21
21
|
:endof => %r/\A__END_OF_EMAIL_MESSAGE__\z/,
|
22
22
|
}
|
23
23
|
NDRSubject = {
|
24
|
-
:'
|
25
|
-
:'
|
26
|
-
:'
|
24
|
+
:'SMTPSEND.DNS.NonExistentDomain'=> 'hostunknown', # 554 5.4.4 SMTPSEND.DNS.NonExistentDomain
|
25
|
+
:'SMTPSEND.DNS.MxLoopback' => 'networkerror', # 554 5.4.4 SMTPSEND.DNS.MxLoopback
|
26
|
+
:'RESOLVER.ADR.BadPrimary' => 'systemerror', # 550 5.2.0 RESOLVER.ADR.BadPrimary
|
27
|
+
:'RESOLVER.ADR.RecipNotFound' => 'userunknown', # 550 5.1.1 RESOLVER.ADR.RecipNotFound
|
28
|
+
:'RESOLVER.ADR.ExRecipNotFound' => 'userunknown', # 550 5.1.1 RESOLVER.ADR.ExRecipNotFound
|
29
|
+
:'RESOLVER.ADR.RecipLimit' => 'toomanyconn', # 550 5.5.3 RESOLVER.ADR.RecipLimit
|
30
|
+
:'RESOLVER.ADR.InvalidInSmtp' => 'systemerror', # 550 5.1.0 RESOLVER.ADR.InvalidInSmtp
|
31
|
+
:'RESOLVER.ADR.Ambiguous' => 'systemerror', # 550 5.1.4 RESOLVER.ADR.Ambiguous, 420 4.2.0 RESOLVER.ADR.Ambiguous
|
32
|
+
:'RESOLVER.RST.AuthRequired' => 'filtered', # 550 5.7.1 RESOLVER.RST.AuthRequired
|
33
|
+
:'RESOLVER.RST.NotAuthorized' => 'rejected', # 550 5.7.1 RESOLVER.RST.NotAuthorized
|
34
|
+
:'RESOLVER.RST.RecipSizeLimit' => 'mesgtoobig', # 550 5.2.3 RESOLVER.RST.RecipSizeLimit
|
35
|
+
:'QUEUE.Expired' => 'expired', # 550 4.4.7 QUEUE.Expired
|
27
36
|
}
|
28
37
|
Indicators = Sisimai::MTA.INDICATORS
|
29
38
|
|
@@ -112,6 +121,7 @@ module Sisimai
|
|
112
121
|
v = dscontents[-1]
|
113
122
|
end
|
114
123
|
v['recipient'] = cv[1]
|
124
|
+
v['diagnosis'] = ''
|
115
125
|
recipients += 1
|
116
126
|
|
117
127
|
elsif cv = e.match(/\A[#]([45]\d{2})[ ]([45][.]\d[.]\d+)[ ].+\z/)
|
data/lib/sisimai/order.rb
CHANGED
@@ -29,6 +29,7 @@ module Sisimai
|
|
29
29
|
|mail[ ]server[ ]requires[ ]authentication[ ]when[ ]attempting[ ]to[ ]
|
30
30
|
send[ ]to[ ]a[ ]non-local[ ]e-mail[ ]address # MailEnable
|
31
31
|
|not[ ]allowed[ ]to[ ]relay[ ]through[ ]this[ ]machine
|
32
|
+
|Not[ ]an[ ]open[ ]relay,[ ]so[ ]get[ ]lost
|
32
33
|
|relay[ ](?:
|
33
34
|
access[ ]denied
|
34
35
|
|denied
|
@@ -44,6 +44,7 @@ module Sisimai
|
|
44
44
|
|invalid[ ]domain,[ ]see[ ][<]url:.+[>]
|
45
45
|
|mx[ ]records[ ]for[ ].+[ ]violate[ ]section[ ].+
|
46
46
|
|name[ ]service[ ]error[ ]for[ ] # Malformed MX RR or host not found
|
47
|
+
|Null[ ]Sender[ ]is[ ]not[ ]allowed
|
47
48
|
|recipient[ ]not[ ]accepted[.][ ][(]batv:[ ]no[ ]tag
|
48
49
|
|returned[ ]mail[ ]not[ ]accepted[ ]here
|
49
50
|
|rfc[ ]1035[ ]violation:[ ]recursive[ ]cname[ ]records[ ]for
|
@@ -44,10 +44,12 @@ module Sisimai
|
|
44
44
|
# http://kb.mimecast.com/Mimecast_Knowledge_Base/Administration_Console/Monitoring/Mimecast_SMTP_Error_Codes#554
|
45
45
|
|rejected[ ]due[ ]to[ ]security[ ]policies
|
46
46
|
)
|
47
|
+
|Executable[ ]files[ ]are[ ]not[ ]allowed[ ]in[ ]compressed[ ]files
|
47
48
|
|insecure[ ]mail[ ]relay
|
48
49
|
|sorry,[ ]you[ ]don'?t[ ]authenticate[ ]or[ ]the[ ]domain[ ]isn'?t[ ]in[ ]my[ ]list[ ]of[ ]allowed[ ]rcpthosts
|
49
50
|
|the[ ]message[ ]was[ ]rejected[ ]because[ ]it[ ]contains[ ]prohibited[ ]virus[ ]or[ ]spam[ ]content
|
50
51
|
|TLS[ ]required[ ]but[ ]not[ ]supported # SendGrid
|
52
|
+
|you[ ]are[ ]not[ ]authorized[ ]to[ ]send[ ]mail,[ ]authentication[ ]is[ ]required
|
51
53
|
|You[ ]have[ ]exceeded[ ]the[ ]the[ ]allowable[ ]number[ ]of[ ]posts[ ]without[ ]solving[ ]a[ ]captcha
|
52
54
|
|verification[ ]failure
|
53
55
|
)
|
data/lib/sisimai/string.rb
CHANGED
@@ -59,6 +59,72 @@ module Sisimai
|
|
59
59
|
return argv1
|
60
60
|
end
|
61
61
|
|
62
|
+
# Convert given HTML text to plain text
|
63
|
+
# @param [String] argv1 HTML text
|
64
|
+
# @param [Boolean] loose Loose check flag
|
65
|
+
# @return [String] Plain text
|
66
|
+
def to_plain(argv1 = '', loose = false)
|
67
|
+
return '' if argv1.empty?
|
68
|
+
|
69
|
+
plain = argv1
|
70
|
+
match = {
|
71
|
+
:html => %r|<html[ >].+?</html>|sim,
|
72
|
+
:body => %r|<head>.+</head>.*<body[ >].+</body>|sim,
|
73
|
+
}
|
74
|
+
|
75
|
+
if loose || plain =~ match[:html] || plain =~ match[:body]
|
76
|
+
# <html> ... </html>
|
77
|
+
# Rewrite <a> elements
|
78
|
+
# 1. <a href = 'http://...'>...</a> to " http://... "
|
79
|
+
# 2. <a href = 'mailto:...'>...</a> to " Value <mailto:...> "
|
80
|
+
plain = plain.gsub(%r|<a\s+href\s*=\s*['"](https?://.+?)['"].*?>(.*?)</a>|i, '[\2](\1)')
|
81
|
+
plain = plain.gsub(%r|<a\s+href\s*=\s*["']mailto:([^\s]+?)["']>(.*?)</a>|i, '[\2](mailto:\1)')
|
82
|
+
|
83
|
+
plain = plain.gsub(/<[^<@>]+?>\s*/,' ') # Delete HTML tags except <neko@example.jp>
|
84
|
+
plain = plain.gsub(/</, '<') # Convert to left angle brackets
|
85
|
+
plain = plain.gsub(/>/, '>') # Convert to right angle brackets
|
86
|
+
plain = plain.gsub(/&/, '&') # Convert to "&"
|
87
|
+
plain = plain.gsub(/"/, '"') # Convert to '"'
|
88
|
+
plain = plain.gsub(/'/, "'") # Convert to "'"
|
89
|
+
plain = plain.gsub(/ /, ' ') # Convert to ' '
|
90
|
+
|
91
|
+
if argv1.size > plain.size
|
92
|
+
plain = plain.squeeze(' ')
|
93
|
+
plain += "\n"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
return plain
|
98
|
+
end
|
99
|
+
|
100
|
+
# Convert given string to UTF-8
|
101
|
+
# @param [String] argv1 String to be converted
|
102
|
+
# @param [String] argv2 Encoding name before converting
|
103
|
+
# @return [String] UTF-8 Encoded string
|
104
|
+
def to_utf8(argv1 = '', argv2 = nil)
|
105
|
+
return '' unless argv1.size > 0
|
106
|
+
|
107
|
+
encodefrom = argv2 || false
|
108
|
+
getencoded = ''
|
109
|
+
|
110
|
+
begin
|
111
|
+
# Try to convert the string to UTF-8
|
112
|
+
if encodefrom
|
113
|
+
# String#encode('UTF-8', <FROM>)
|
114
|
+
getencoded = argv1.encode('UTF-8', encodefrom)
|
115
|
+
else
|
116
|
+
# Force encoding to UTF-8
|
117
|
+
getencoded = argv1.force_encoding('UTF-8')
|
118
|
+
end
|
119
|
+
rescue
|
120
|
+
# Unknown encoding name or failed to encode
|
121
|
+
getencoded = argv1.force_encoding('UTF-8')
|
122
|
+
end
|
123
|
+
getencoded = getencoded.scrub('?')
|
124
|
+
|
125
|
+
return getencoded
|
126
|
+
end
|
127
|
+
|
62
128
|
end
|
63
129
|
end
|
64
130
|
end
|
data/lib/sisimai/version.rb
CHANGED
@@ -0,0 +1,71 @@
|
|
1
|
+
Return-Path: <>
|
2
|
+
Received: from mx1.example.jp (mx1.example.jp [192.0.2.111])
|
3
|
+
by 9jo.example.org (V8/cf) with ESMTP id 00000000000000
|
4
|
+
for <shironeko@example.org>; Thu, 29 Apr 2014 23:34:45 +0900
|
5
|
+
X-SenderID: Sendmail Sender-ID Filter v1.0.0 9jo.example.org sAH7CLnA005966
|
6
|
+
Authentication-Results: 9jo.example.org; sender-id=none header.from=MAILER-DAEMON@mx1.example.jp
|
7
|
+
Received: from localhost (localhost)
|
8
|
+
by mx1.example.jp (V8/cf) id 00000000000000; Thu, 29 Apr 2014 23:34:45 +0900
|
9
|
+
Date: Thu, 29 Apr 2014 23:34:45 +0900
|
10
|
+
From: Mail Delivery Subsystem <MAILER-DAEMON@mx1.example.jp>
|
11
|
+
Message-Id: <20140429233445.00000000000000@mx1.example.jp>
|
12
|
+
To: postmaster@mx1.example.jp
|
13
|
+
MIME-Version: 1.0
|
14
|
+
Content-Type: multipart/report; report-type=delivery-status;
|
15
|
+
boundary="f00000000000.000000000/mx1.example.jp"
|
16
|
+
Subject: Postmaster notify: see transcript for details
|
17
|
+
Auto-Submitted: auto-generated (postmaster-notification)
|
18
|
+
|
19
|
+
This is a MIME-encapsulated message
|
20
|
+
|
21
|
+
--f00000000000.000000000/mx1.example.jp
|
22
|
+
|
23
|
+
The original message was received at Thu, 29 Apr 2014 23:34:45 +0900
|
24
|
+
from localhost [127.0.0.1]
|
25
|
+
with id 0000000000000
|
26
|
+
|
27
|
+
----- The following addresses had permanent fatal errors -----
|
28
|
+
<kijitora@ntt.example.ne.jp>
|
29
|
+
(reason: 550 Unknown user kijitora@ntt.example.ne.jp)
|
30
|
+
|
31
|
+
----- Transcript of session follows -----
|
32
|
+
... while talking to mfsmax.ntt.example.ne.jp.:
|
33
|
+
>>> DATA
|
34
|
+
<<< 550 Unknown user kijitora@ntt.example.ne.jp
|
35
|
+
554 5.0.0 Service unavailable
|
36
|
+
|
37
|
+
--f00000000000.000000000/mx1.example.jp
|
38
|
+
Content-Type: message/delivery-status
|
39
|
+
|
40
|
+
Reporting-MTA: dns; mx1.example.jp
|
41
|
+
Received-From-MTA: DNS; localhost
|
42
|
+
Arrival-Date: Thu, 29 Apr 2014 23:34:45 +0900
|
43
|
+
|
44
|
+
Final-Recipient: RFC822; kijitora@ntt.example.ne.jp
|
45
|
+
Action: failed
|
46
|
+
Status: 5.2.0
|
47
|
+
Remote-MTA: DNS; mfsmax.ntt.example.ne.jp
|
48
|
+
Diagnostic-Code: SMTP; 550 Unknown user kijitora@ntt.example.ne.jp
|
49
|
+
Last-Attempt-Date: Thu, 29 Apr 2014 23:34:45 +0900
|
50
|
+
|
51
|
+
--f00000000000.000000000/mx1.example.jp
|
52
|
+
Content-Type: text/rfc822-headers
|
53
|
+
|
54
|
+
Return-Path: <httpd@mx1.example.jp>
|
55
|
+
Received: from mx1.example.jp (localhost [127.0.0.1])
|
56
|
+
by mx1.example.jp (V8/cf) with ESMTP id 0000000000000;
|
57
|
+
Thu, 29 Apr 2014 23:34:45 +0900
|
58
|
+
Received: (from httpd@example.com)
|
59
|
+
by mx1.example.jp (8.14.9/8.14.9/Submit) id 00000000000000;
|
60
|
+
Thu, 29 Apr 2014 23:34:45 +0900
|
61
|
+
Message-Id: <20140429122334.00000000000000@mx1.example.jp>
|
62
|
+
To: Nyanko <kijitora@ntt.example.ne.jp>
|
63
|
+
Subject: =?ISO-2022-JP?B?GyRCIVowbEE3IVsbKEIgGyRCMnEwd0VQTz8kTkZiTUYkciQ0M04bKEI=?= =?ISO-2022-JP?B?GyRCRyckLyRAJDUkJCEjGyhC?=
|
64
|
+
MIME-Version: 1.0
|
65
|
+
From: Shironeko <shironeko@example.org>
|
66
|
+
Date: Thu, 29 Apr 2014 23:34:45 +0900
|
67
|
+
Content-Transfer-Encoding: 7bit
|
68
|
+
Content-Type: text/plain; charset="ISO-2022-JP"
|
69
|
+
|
70
|
+
--f00000000000.000000000/mx1.example.jp--
|
71
|
+
|
data/sisimai-java.gemspec
CHANGED
@@ -25,5 +25,10 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency 'bundler', '~> 1.8'
|
26
26
|
spec.add_development_dependency 'rake', '~> 10.0'
|
27
27
|
spec.add_development_dependency 'rspec', '~> 0'
|
28
|
-
|
28
|
+
|
29
|
+
if RUBY_PLATFORM == 'java'
|
30
|
+
spec.add_runtime_dependency 'jrjackson','~> 0.3', '>= 0.3.8'
|
31
|
+
else
|
32
|
+
spec.add_runtime_dependency 'oj', '~> 2.14', '>= 2.14.4'
|
33
|
+
end
|
29
34
|
end
|
data/sisimai.gemspec
CHANGED
@@ -24,5 +24,10 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency 'bundler', '~> 1.8'
|
25
25
|
spec.add_development_dependency 'rake', '~> 10.0'
|
26
26
|
spec.add_development_dependency 'rspec', '~> 0'
|
27
|
-
|
27
|
+
|
28
|
+
if RUBY_PLATFORM == 'java'
|
29
|
+
spec.add_runtime_dependency 'jrjackson','~> 0.3', '>= 0.3.8'
|
30
|
+
else
|
31
|
+
spec.add_runtime_dependency 'oj', '~> 2.14', '>= 2.14.4'
|
32
|
+
end
|
28
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sisimai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.18.
|
4
|
+
version: 4.18.1
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- azumakuniyuki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -53,25 +53,25 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: oj
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '2.14'
|
62
62
|
- - ">="
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version:
|
64
|
+
version: 2.14.4
|
65
65
|
type: :runtime
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
69
|
- - "~>"
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version: '
|
71
|
+
version: '2.14'
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
74
|
+
version: 2.14.4
|
75
75
|
description: Sisimai is a Ruby library for analyzing RFC5322 bounce emails and generating
|
76
76
|
structured data from parsed results.
|
77
77
|
email:
|
@@ -431,6 +431,7 @@ files:
|
|
431
431
|
- set-of-emails/maildir/bsd/sendmail-37.eml
|
432
432
|
- set-of-emails/maildir/bsd/sendmail-38.eml
|
433
433
|
- set-of-emails/maildir/bsd/sendmail-39.eml
|
434
|
+
- set-of-emails/maildir/bsd/sendmail-40.eml
|
434
435
|
- set-of-emails/maildir/bsd/surfcontrol-01.eml
|
435
436
|
- set-of-emails/maildir/bsd/surfcontrol-02.eml
|
436
437
|
- set-of-emails/maildir/bsd/surfcontrol-03.eml
|