sisimai 5.0.0 → 5.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake-test.yml +55 -0
  3. data/ChangeLog.md +40 -1
  4. data/README-JA.md +223 -111
  5. data/README.md +54 -31
  6. data/lib/sisimai/fact.rb +46 -8
  7. data/lib/sisimai/lhost/amazonses.rb +0 -1
  8. data/lib/sisimai/lhost/amazonworkmail.rb +0 -1
  9. data/lib/sisimai/lhost/aol.rb +0 -1
  10. data/lib/sisimai/lhost/bigfoot.rb +0 -1
  11. data/lib/sisimai/lhost/domino.rb +0 -1
  12. data/lib/sisimai/lhost/exchange2007.rb +1 -1
  13. data/lib/sisimai/lhost/exim.rb +7 -16
  14. data/lib/sisimai/lhost/facebook.rb +0 -1
  15. data/lib/sisimai/lhost/googlegroups.rb +2 -1
  16. data/lib/sisimai/lhost/gsuite.rb +0 -1
  17. data/lib/sisimai/lhost/mailru.rb +8 -17
  18. data/lib/sisimai/lhost/messagelabs.rb +0 -1
  19. data/lib/sisimai/lhost/mfilter.rb +1 -1
  20. data/lib/sisimai/lhost/mxlogic.rb +8 -18
  21. data/lib/sisimai/lhost/office365.rb +1 -1
  22. data/lib/sisimai/lhost/outlook.rb +0 -1
  23. data/lib/sisimai/lhost/postfix.rb +0 -1
  24. data/lib/sisimai/lhost/receivingses.rb +0 -1
  25. data/lib/sisimai/lhost/sendgrid.rb +1 -3
  26. data/lib/sisimai/lhost/sendmail.rb +0 -1
  27. data/lib/sisimai/lhost/yandex.rb +0 -1
  28. data/lib/sisimai/message.rb +13 -4
  29. data/lib/sisimai/reason/authfailure.rb +1 -0
  30. data/lib/sisimai/reason/blocked.rb +2 -0
  31. data/lib/sisimai/reason/expired.rb +1 -0
  32. data/lib/sisimai/reason/mailboxfull.rb +1 -0
  33. data/lib/sisimai/reason/securityerror.rb +1 -0
  34. data/lib/sisimai/reason/spamdetected.rb +1 -0
  35. data/lib/sisimai/reason/suspend.rb +1 -0
  36. data/lib/sisimai/rfc5322.rb +120 -64
  37. data/lib/sisimai/rhost/google.rb +320 -59
  38. data/lib/sisimai/rhost/mimecast.rb +9 -2
  39. data/lib/sisimai/smtp/status.rb +3 -0
  40. data/lib/sisimai/version.rb +1 -1
  41. data/lib/sisimai.rb +12 -11
  42. data/set-of-emails/maildir/bsd/lhost-sendmail-60.eml +85 -0
  43. metadata +4 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ef306c6a29b146ce55a4c7831a1ffaf0e046e3b5d65612bfc7b585beb68c320
4
- data.tar.gz: 3ff98584b1324bbdba388e045bc07f56b639b3c4f0f1171fb736296fcd3e09de
3
+ metadata.gz: 7090710f97dbdd17e7bf971fdad787f7eeab1656de2e93012e32430b9a7d64fb
4
+ data.tar.gz: 4dd096852de6cb0c9a44a78fc11058a86494fb4e032f8aa6c8a31bf65149cec8
5
5
  SHA512:
6
- metadata.gz: 41c85d376f12ae20f7e5ea5af7b9d5eeeff62857a5855a4900585755f045c7134ea7df02426c0279943c6a505aa10d201e506754daab946443a06170b3cfd761
7
- data.tar.gz: e9953915998b5e5438a8f0e5646d0bc2a81c319ef5aaf419124dd473f58e18b94d11e7efb96224774802c6061ee83694a1566ce8b2aabdde6d10e7592e11b2fc
6
+ metadata.gz: d4f9752e00950e8965c6328ddea6f82f80e436e9e7788d41ab9e5484fce8a64be99c23d193d902f118d158eed5246b4601f4c9ce618cd219e04a943db79df860
7
+ data.tar.gz: ee66c1d20a46c49a11fc07c111039a3322fc89cd2e682d9b09a59040f35fa3d2a93348c975f7d6cb10884d29c80962df4e6c65e51e7a90dfe03b2fd0c36cad4e
@@ -0,0 +1,55 @@
1
+ name: rake test
2
+ on:
3
+ push:
4
+ branches: ["5-stable"]
5
+ pull_request:
6
+ branches: ["5-stable"]
7
+ jobs:
8
+ test-cruby:
9
+ name: rake test with CRuby ${{ matrix.cruby }}
10
+ runs-on: ubuntu-latest
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ cruby: ["2.4", "3.3"]
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - name: Setup CRuby
18
+ uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: ${{ matrix.cruby }}
21
+ - run: gem install minitest -v 5.15.0
22
+ - run: gem install oj -v 3.10.0
23
+ - run: gem install bundle rake
24
+ - name: Cache the dependent gems
25
+ uses: actions/cache@v2
26
+ with:
27
+ path: ./cache
28
+ key: ${{ runner.os }}-ruby-${{ matrix.cruby }}-${{ hashFiles('./gem.snapshot') }}
29
+ - run: ruby -v
30
+ - run: rake publictest
31
+ - run: rake privatetest
32
+ test-jruby:
33
+ name: rake test with JRuby ${{ matrix.jruby }}
34
+ runs-on: ubuntu-latest
35
+ strategy:
36
+ fail-fast: false
37
+ matrix:
38
+ jruby: ["jruby-9.2", "jruby-9.4"]
39
+ steps:
40
+ - uses: actions/checkout@v2
41
+ - name: Setup JRuby
42
+ uses: ruby/setup-ruby@v1
43
+ with:
44
+ ruby-version: ${{ matrix.jruby }}
45
+ - run: gem install minitest -v 5.15.0
46
+ - run: gem install bundle rake jrjackson
47
+ - name: Cache the dependent gems
48
+ uses: actions/cache@v2
49
+ with:
50
+ path: ./cache
51
+ key: ${{ runner.os }}-ruby-${{ matrix.jruby }}-${{ hashFiles('./gem.snapshot') }}
52
+ - run: ruby -v
53
+ - run: rake publictest
54
+ - run: rake privatetest
55
+
data/ChangeLog.md CHANGED
@@ -3,9 +3,48 @@ RELEASE NOTES for Ruby version of Sisimai
3
3
  - releases: "https://github.com/sisimai/rb-sisimai/releases"
4
4
  - download: "https://rubygems.org/gems/sisimai"
5
5
 
6
+ v5.0.2
7
+ ---------------------------------------------------------------------------------------------------
8
+ - release: "Wed, 13 Mar 2024 13:00:00 +0900 (JST)"
9
+ - version: "5.0.2"
10
+ - changes:
11
+ - #271 #267 Sisimai 5 works on JRuby again. Thanks to @hiroyuki-sato
12
+ - #159 Implement workarounds at `Sisimai::Fact` and some public tests with `DateTime` class to
13
+ run Sisimai on JRuby, to avoid failing `strptime()`
14
+ - #269 Replace `Array#append` with `Array#push` at `Sisimai::RFC5322` because `Array#append` is
15
+ only available in Ruby 2.5 and above
16
+ - We have started testing JRuby 9.2 and 9.4 on GitHub Actions
17
+ - Disable 2 tests in `test/public/mail-test.rb` that fails on GitHub Actions only
18
+ - `5.7.23` returned from Office365 is an error related to SPF vilation (authfailure)
19
+ - #272 Fixed an issue that Sisimai could not get the value of `alias` address correctly when an
20
+ email forwarded and bounced
21
+ - `Sisimai::RFC5322.received` now returns a list including all the elements except date time and
22
+ (comments) found in the `Received` header
23
+ - Update the error message patterns in `Sisimai::Rhost::Mimecast`
24
+ - Update the error message patterns in the followings:
25
+ - `AuthFailure`
26
+ - `Blocked`
27
+ - `Expired`
28
+ - `MailboxFull`
29
+ - `SecurityError`
30
+ - `SpamDetected`
31
+ - `Suspend`
32
+
33
+ v5.0.1
34
+ ---------------------------------------------------------------------------------------------------
35
+ - release: "Sun, 3 Mar 2024 17:17:17 +0900 (JST)"
36
+ - version: "5.0.1"
37
+ - changes:
38
+ - #263 Implement three SMTP status codes as follows: `5.7.28`, `5.7.29` and `5.7.30` described in
39
+ https://www.iana.org/assignments/smtp-enhanced-status-codes/smtp-enhanced-status-codes.xhtml
40
+ - #264 The values of `reason` of `postfix-28.eml` and `postfix-29.eml` in decoded results have
41
+ been fixed to `notcompliantrfc`.
42
+ - #265 Implement and update SMTP error codes, reply codes, and error messages described at Google
43
+ https://support.google.com/a/answer/3726730?hl=en in `Sisimai::Rhost::Google`.
44
+
6
45
  v5.0.0
7
46
  ---------------------------------------------------------------------------------------------------
8
- - release: ""Fri, 2 Feb 2024 23:22:22 +0900 (JST)
47
+ - release: "Fri, 2 Feb 2024 23:22:22 +0900 (JST)"
9
48
  - version: "5.0.0"
10
49
  - changes:
11
50
  - **INCOMPATIBLE CHANGES SINCE SISIMAI VERSION 4**
data/README-JA.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ![](https://libsisimai.org/static/images/logo/sisimai-x01.png)
2
2
  [![License](https://img.shields.io/badge/license-BSD%202--Clause-orange.svg)](https://github.com/sisimai/rb-sisimai/blob/master/LICENSE)
3
3
  [![Coverage Status](https://img.shields.io/coveralls/sisimai/rb-sisimai.svg)](https://coveralls.io/r/sisimai/rb-sisimai)
4
- [![Ruby](https://img.shields.io/badge/ruby-v2.4.0--v2.7.0-red.svg)](https://www.ruby-lang.org/)
4
+ [![Ruby](https://img.shields.io/badge/ruby-v2.4.0--v3.3.0-red.svg)](https://www.ruby-lang.org/)
5
5
  [![Gem Version](https://badge.fury.io/rb/sisimai.svg)](https://badge.fury.io/rb/sisimai)
6
6
 
7
7
  > [!IMPORTANT]
@@ -14,15 +14,13 @@
14
14
  > Sisimai 5はRuby 2.4以上が必要です。インストール/アップグレードを実行する前に`ruby -v`コマンドで
15
15
  > システムに入っているRubyのバージョンを確認してください。
16
16
 
17
- > [!CAUTION]
18
- > 2024年2月2日の時点で[Sisimai 5](https://github.com/sisimai/rb-sisimai/releases/tag/v5.0.0)は
19
- > [RubyGems.org](https://rubygems.org/gems/sisimai)にアップロードしていません。数ヶ月以内には
20
- > アップロードをする予定ですが、それまではこのリポジトリではから`git clone`してください。
21
-
17
+ > [!NOTE]
18
+ > SisimaiはPerlモジュールまたはRuby Gemですが、PHPやPython、GoやRustなどJSONを読める言語であれば
19
+ > どのような環境においても解析結果を得ることでバウンスの発生状況を捉えるのにとても有用です。
22
20
 
23
21
  - [**README(English)**](README.md)
24
22
  - [シシマイ? | What is Sisimai](#what-is-sisimai)
25
- - [主な特徴的機能 | Key features](#key-features)
23
+ - [主な特徴的機能 | The key features](#the-key-features-of-sisimai)
26
24
  - [コマンドラインでのデモ | Command line demo](#command-line-demo)
27
25
  - [シシマイを使う準備 | Setting Up Sisimai](#setting-up-sisimai)
28
26
  - [動作環境 | System requirements](#system-requirements)
@@ -35,12 +33,14 @@
35
33
  - [コールバック機能 | Callback feature](#callback-feature)
36
34
  - [ワンライナー | One-Liner](#one-liner)
37
35
  - [出力例 | Output example](#output-example)
38
- - [シシマイの仕様 | Sisimai Specification](#sisimai-specification)
39
- - [Ruby版とPerl版の違い | Differences between Ruby version and Perl version](#differences-between-ruby-version-and-perl-version)
40
- - [その他の仕様詳細 | Other specification of Sisimai](#other-specification-of-sisimai)
36
+ - [Sisimai 4とSisimai 5の違い](#differences-between-sisimai-4-and-sisimai-5)
37
+ - [機能など](#features)
38
+ - [解析メソッド](#decoding-methods)
39
+ - [MTA/ESPモジュール](#mtaesp-module-names)
40
+ - [バウンス理由](#bounce-reasons)
41
41
  - [Contributing](#contributing)
42
42
  - [バグ報告 | Bug report](#bug-report)
43
- - [解析できないメール | Emails could not be parsed](#emails-could-not-be-parsed)
43
+ - [解析できないメール | Emails could not be decoded](#emails-could-not-be-decoded)
44
44
  - [その他の情報 | Other Information](#other-information)
45
45
  - [関連サイト | Related sites](#related-sites)
46
46
  - [参考情報| See also](#see-also)
@@ -50,24 +50,47 @@
50
50
 
51
51
  What is Sisimai
52
52
  ===================================================================================================
53
- Sisimai(シシマイ)はRFC5322準拠のエラーメールを解析し、解析結果をデータ構造に変換するインターフェイス
54
- を提供するRubyライブラリです。[github.com/sisimai/p5-sisimai](https://github.com/sisimai/p5-sisimai/)
55
- で公開しているPerl版シシマイから移植しました。
53
+ Sisimai(シシマイ)は複雑で多種多様なバウンスメールを解析してバウンスした理由や宛先メールアドレスなど
54
+ 配信が失敗した結果を構造化データで出力するライブラリでJSONでの出力も可能です。Ruby版シシマイは
55
+ [github.com/sisimai/p5-sisimai](https://github.com/sisimai/p5-sisimai/)で公開しているPerl版シシマイ
56
+ から移植しました。
56
57
 
57
- ![](https://libsisimai.org/static/images/figure/sisimai-overview-1.png)
58
+ ![](https://libsisimai.org/static/images/figure/sisimai-overview-2.png)
58
59
 
59
- Key features
60
+ The key features of Sisimai
61
+ ---------------------------------------------------------------------------------------------------
62
+ * __バウンスメールを構造化したデータに変換__
63
+ * 以下24項目の情報を含むデータ構造[^2]
64
+ * __基本的情報__: `timestamp`, `origin`
65
+ * __発信者情報__: `addresser`, `senderdomain`,
66
+ * __受信者情報__: `recipient`, `destination`, `alias`
67
+ * __配信の情報__: `action`, `replycode`,`action`, `replycode`, `deliverystatus`
68
+ * __エラー情報__: `reason`, `diagnosticcode`, `diagnostictype`, `feedbacktype`, `hardbounce`
69
+ * __メール情報__: `subject`, `messageid`, `listid`,
70
+ * __その他情報__: `smtpagent`, `timezoneoffset`, `lhost`, `rhost`, `token`, `catch`
71
+ * __出力可能な形式__
72
+ * Ruby (Hash, Array)
73
+ * JSON
74
+ * ([`oj`](https://rubygems.org/gems/oj)を使用(CRuby))
75
+ * ([`jrjackson`](https://rubygems.org/gems/jrjackson)を使用(JRuby))
76
+ * YAML ([`yaml`](https://rubygems.org/gems/yaml)が必要)
77
+ * __インストールも使用も簡単__
78
+ * `gem install`
79
+ * `git clone && make`
80
+ * __高い解析精度__
81
+ * [70種類のMTAs/MDAs/ESPs](https://libsisimai.org/en/engine/)に対応
82
+ * Feedback Loop(ARF)にも対応
83
+ * [34種類のバウンス理由](https://libsisimai.org/en/reason/)を検出
84
+
85
+ [^2]: コールバック機能を使用すると`catch`アクセサの下に独自のデータを追加できます
86
+
87
+
88
+ Command line demo
60
89
  ---------------------------------------------------------------------------------------------------
61
- * __エラーメールをデータ構造に変換__
62
- * Rubyのデータ形式(HashとArray)とJSON(String)に対応
63
- * __インストールも使用も簡単__
64
- * gem install
65
- * git clone & make
66
- * __高い解析精度__
67
- * 解析精度はbounceHammerの2倍
68
- * 68種類のMTA/MDA/ESPに対応
69
- * Feedback Loopにも対応
70
- * 32種類のエラー理由を検出
90
+ 次の画像のように、Ruby版シシマイ(rb-sisimai)はコマンドラインから簡単にバウンスメールを解析すること
91
+ ができます。
92
+ ![](https://libsisimai.org/static/images/demo/sisimai-5-cli-dump-r01.gif)
93
+
71
94
 
72
95
  Setting Up Sisimai
73
96
  ===================================================================================================
@@ -78,37 +101,53 @@ Sisimaiの動作環境についての詳細は[Sisimai | シシマイを使っ
78
101
 
79
102
 
80
103
  * [Ruby 2.4.0 or later](http://www.ruby-lang.org/)
81
- * [__Oj | The fastest JSON parser and object serializer__](https://rubygems.org/gems/oj)
82
- * Also works on [JRuby 9.0.4.0 or later](http://jruby.org)
83
- * [__JrJackson | A mostly native JRuby wrapper for the java jackson json processor jar__](https://rubygems.org/gems/jrjackson)
104
+ * [__oj | The fastest JSON parser and object serializer__](https://rubygems.org/gems/oj)
105
+ * Also works on [JRuby 9.2 or later](http://jruby.org)
106
+ * [__jrjackson | A mostly native JRuby wrapper for the java jackson json processor jar__](https://rubygems.org/gems/jrjackson)
84
107
 
85
108
  Install
86
109
  ---------------------------------------------------------------------------------------------------
87
110
  ### From RubyGems.org
88
-
89
111
  ```shell
90
112
  $ sudo gem install sisimai
91
- Fetching: sisimai-4.25.5.gem (100%)
92
- Successfully installed sisimai-4.25.5
93
- Parsing documentation for sisimai-4.25.5
94
- Installing ri documentation for sisimai-4.25.5
113
+ Fetching: sisimai-5.0.2.gem (100%)
114
+ Successfully installed sisimai-5.0.2
115
+ Parsing documentation for sisimai-5.0.2
116
+ Installing ri documentation for sisimai-5.0.2
95
117
  Done installing documentation for sisimai after 6 seconds
96
118
  1 gem installed
97
119
  ```
98
120
 
99
121
  ### From GitHub
122
+ > [!WARNING]
123
+ > Sisimai 5はRuby 2.4以上が必要です。インストール/アップグレードを実行する前に`ruby -v`コマンドで
124
+ > システムに入っているRubyのバージョンを確認してください。
100
125
 
101
126
  ```shell
127
+ % ruby -v
128
+ ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin21]
129
+
102
130
  $ cd /usr/local/src
103
131
  $ git clone https://github.com/sisimai/rb-sisimai.git
132
+
104
133
  $ cd ./rb-sisimai
105
134
  $ sudo make depend install-from-local
106
- gem install bundle rake minitest coveralls
135
+ gem install bundle rake minitest
107
136
  ...
108
- 4 gems installed
109
- bundle exec rake install
110
- sisimai 4.25.5 built to pkg/sisimai-4.25.5.gem.
111
- sisimai (4.25.5) installed.
137
+ 3 gems installed
138
+ if [ -d "/usr/local/jr" ]; then \
139
+ PATH="/usr/local/jr/bin:$PATH" /usr/local/jr/bin/gem install bundle rake minitest; \
140
+ fi
141
+ ...
142
+ 3 gems installed
143
+ /opt/local/bin/rake install
144
+ sisimai 5.0.2 built to pkg/sisimai-5.0.2.gem.
145
+ sisimai (5.0.2) installed.
146
+ if [ -d "/usr/local/jr" ]; then \
147
+ PATH="/usr/local/jr/bin:$PATH" /usr/local/jr/bin/rake install; \
148
+ fi
149
+ sisimai 5.0.2 built to pkg/sisimai-5.0.2-java.gem.
150
+ sisimai (5.0.2) installed.
112
151
  ```
113
152
 
114
153
  Usage
@@ -121,64 +160,65 @@ Basic usage
121
160
  ```ruby
122
161
  #! /usr/bin/env ruby
123
162
  require 'sisimai'
124
- v = Sisimai.rise('/path/to/mbox') # or path to Maildir/
163
+ v = Sisimai.rise('/path/to/mbox') # またはMaildir/へのPATH
125
164
 
126
- # Beginning with v4.23.0, both rise() and dump() method of Sisimai class can read bounce messages
127
- # from variable instead of a path to mailbox
128
- f = File.open('/path/to/mbox', 'r'); # or path to Maildir/
165
+ # v4.23.0からSisimaiクラスのrise()メソッドとdump()メソッドはPATH以外にもバウンスメール全体を文字列
166
+ # として読めるようになりました
167
+ f = File.open('/path/to/mbox', 'r'); # またはMaildir/へのPATH
129
168
  v = Sisimai.rise(f.read)
130
169
 
131
- # If you want to get bounce records which reason is "delivered", set "delivered" option to rise()
132
- # method like the following:
170
+ # もし"delivered"(配信成功)となる解析結果も必要な場合は以下に示すとおりrise()メソッドに"delivered"
171
+ # オプションを指定してください
133
172
  v = Sisimai.rise('/path/to/mbox', delivered: true)
134
173
 
135
- # Beginning with v5.0.0, sisimai does not return the reulst which "reason" is "vaction" by default.
136
- # If you want to get bounce records which reason is "vacation", set "vacation" option to rise()
137
- # method like the following:
174
+ # v5.0.0からSisimaiはバウンス理由が"vacation"となる解析結果をデフォルトで返さなくなりました。もし
175
+ # "vacation"となる解析結果も必要な場合は次のコードで示すようにrise()メソッドに"vacation"オプション
176
+ # を指定してください。
138
177
  v = Sisimai.rise('/path/to/mbox', vacation: true);
139
178
 
140
179
  if v.is_a? Array
141
180
  v.each do |e|
142
- puts e.class # Sisimai::Data
181
+ puts e.class # Sisimai::Fact
143
182
  puts e.recipient.class # Sisimai::Address
144
183
  puts e.timestamp.class # Sisimai::Time
145
184
 
146
- puts e.addresser.address # shironeko@example.org # From
147
- puts e.recipient.address # kijitora@example.jp # To
148
- puts e.recipient.host # example.jp
149
- puts e.deliverystatus # 5.1.1
150
- puts e.replycode # 550
151
- puts e.reason # userunknown
152
- puts e.origin # /var/spool/bounce/Maildir/new/1740074341.eml
185
+ puts e.addresser.address # "michitsuna@example.org" # From
186
+ puts e.recipient.address # "kijitora@example.jp" # To
187
+ puts e.recipient.host # "example.jp"
188
+ puts e.deliverystatus # "5.1.1"
189
+ puts e.replycode # "550"
190
+ puts e.reason # "userunknown"
191
+ puts e.origin # "/var/spool/bounce/Maildir/new/1740074341.eml"
153
192
  puts e.hardbounce # true
154
193
 
155
- h = e.damn # Convert to HASH
156
- j = e.dump('json') # Convert to JSON string
157
- puts e.dump('json') # JSON formatted bounce data
194
+ h = e.damn # Hashに変換
195
+ j = e.dump('json') # JSON(文字列)に変換
196
+ puts e.dump('json') # JSON化したバウンスメールの解析結果を表示
158
197
  end
159
198
  end
160
199
  ```
161
200
 
162
201
  Convert to JSON
163
202
  ---------------------------------------------------------------------------------------------------
164
- 下記のようにSisimaiの`dump()`メソッドをmboxかMaildirのPATHを引数にして実行すると解析結果が文字列(JSON)
165
- で返ってきます。
203
+ 下記のようにSisimaiの`dump()`メソッドをmboxかMaildirのPATHを引数にして実行すると解析結果が文字列
204
+ (JSON)で返ってきます。
166
205
 
167
206
  ```ruby
168
- # Get JSON string from parsed mailbox or Maildir/
169
- puts Sisimai.dump('/path/to/mbox') # or path to Maildir/
207
+ # メールボックスまたはMaildir/から解析した結果をJSONにする
208
+ puts Sisimai.dump('/path/to/mbox') # またはMaildir/へのPATH
170
209
 
171
- # dump() method also accepts "delivered" option like the following code:
172
- puts Sisimai.dump('/path/to/mbox', delivered: true)
210
+ # dump()メソッドは"delivered"オプションや"vacation"オプションも指定可能
211
+ puts Sisimai.dump('/path/to/mbox', delivered: true, vacation: true)
173
212
  ```
174
213
 
175
214
  Callback feature
176
215
  ---------------------------------------------------------------------------------------------------
177
- `Sisimai.rise`と`Sisimai.dump`の`:c___`引数はコールバック機能で呼び出されるProcオブジェクトを保持する
178
- 配列です。`:c___`の1番目の要素には`Sisimai::Message.parse`で呼び出されるProcオブジェクトでメールヘッダ
179
- と本文に対して行う処理を、2番目の要素には、解析対象のメールファイルに対して行う処理をそれぞれ入れます。
216
+ `Sisimai.rise`と`Sisimai.dump`の`:c___`引数(`c`と`_`が三個/魚用の釣り針に見える)はコールバック機能
217
+ で呼び出される`Proc`オブジェクトを保持する配列です。`:c___`の1番目の要素には`Sisimai::Message.sift`
218
+ で呼び出される`Proc`オブジェクトでメールヘッダと本文に対して行う処理を、2番目の要素には、解析対象の
219
+ メールファイルに対して行う処理をそれぞれ入れます。
180
220
 
181
- 各Procオブジェクトで処理した結果は`Sisimai::Data.catch`を通して得られます。
221
+ 各Procオブジェクトで処理した結果は`Sisimai::Fact.catch`を通して得られます。
182
222
 
183
223
  ### [0] メールヘッダと本文に対して
184
224
  `:c___`に渡す配列の最初の要素に入れたProcオブジェクトは`Sisimai::Message->parse()`で呼び出されます。
@@ -187,8 +227,8 @@ Callback feature
187
227
  #! /usr/bin/env ruby
188
228
  require 'sisimai'
189
229
  code = lambda do |args|
190
- head = args['headers'] # (*Hash) Email headers
191
- body = args['message'] # (String) Message body
230
+ head = args['headers'] # (*Hash) メールヘッダー
231
+ body = args['message'] # (String) メールの本文
192
232
  adds = { 'x-mailer' => '', 'queue-id' => '' }
193
233
 
194
234
  if cv = body.match(/^X-Postfix-Queue-ID:\s*(.+)$/)
@@ -206,8 +246,8 @@ puts data[0].catch['queue-id'] # "43f4KX6WR7z1xcMG"
206
246
  ```
207
247
 
208
248
  ### 各メールのファイルに対して
209
- `Sisimai->rise()`と`Sisimai->dump()`の両メソッドに渡せる引数`c___`(配列リファレンス)の2番目に入れた
210
- コードリファレンスは解析したメールのファイルごとに呼び出されます。
249
+ `Sisimai.rise`と`Sisimai.dump`の両メソッドに渡せる引数`:c___`(配列)の2番目に入れた`Proc`オブジェクト
250
+ は解析したメールのファイルごとに呼び出されます。
211
251
 
212
252
  ```ruby
213
253
  path = '/path/to/maildir'
@@ -215,10 +255,10 @@ code = lambda do |args|
215
255
  kind = args['kind'] # (String) Sisimai::Mail.kind
216
256
  mail = args['mail'] # (String) Entire email message
217
257
  path = args['path'] # (String) Sisimai::Mail.path
218
- sisi = args['sisi'] # (Array) List of Sisimai::Data
258
+ fact = args['fact'] # (Array) List of Sisimai::Fact
219
259
 
220
- sisi.each do |e|
221
- # Insert custom fields into the parsed results
260
+ fact.each do |e|
261
+ # "catch"アクセサの中に独自の情報を保存する
222
262
  e.catch ||= {}
223
263
  e.catch['size'] = mail.size
224
264
  e.catch['kind'] = kind.capitalize
@@ -229,18 +269,18 @@ code = lambda do |args|
229
269
  end
230
270
  e.catch['parsedat'] = Time.new.localtime.to_s
231
271
 
232
- # Append X-Sisimai-Parsed: header and save into other path
233
- a = sprintf("X-Sisimai-Parsed: %d", sisi.size)
272
+ # "X-Sisimai-Parsed:"ヘッダーを追加して別のPATHに元メールを保存する
273
+ a = sprintf("X-Sisimai-Parsed: %d", fact.size)
234
274
  p = sprintf("/path/to/another/directory/sisimai-%s.eml", e.token)
235
275
  v = mail.sub(/^(From:.+?)$/, '\1' + "\n" + a)
236
276
  f = File.open(p, 'w:UTF-8')
237
277
  f.write(v)
238
278
  f.close
239
279
 
240
- # Remove the email file in Maildir/ after parsed
280
+ # 解析が終わったらMaildir/にあるファイルを削除する
241
281
  File.delete(path) if kind == 'maildir'
242
282
 
243
- # Need to not return a value
283
+ # 特に何か値をReturnする必要はない
244
284
  end
245
285
  end
246
286
 
@@ -262,41 +302,113 @@ $ ruby -rsisimai -e 'puts Sisimai.dump($*.shift)' /path/to/mbox
262
302
 
263
303
  Output example
264
304
  ---------------------------------------------------------------------------------------------------
265
- ![](https://libsisimai.org/static/images/demo/sisimai-dump-02.gif)
305
+ ![](https://libsisimai.org/static/images/demo/sisimai-5-cli-dump-r01.gif)
266
306
 
267
307
  ```json
268
- [{"catch":{"x-mailer":"","return-path":"neko@example.com"},"token":"7e81d3b9306fc7a7f3fb4c7b705189d6806d3d6b","lhost":"omls-1.kuins.neko.example.jp","rhost":"nekonyaan0022.apcprd01.prod.exchangelabs.com","alias":"","listid":"","reason":"userunknown","action":"failed","origin":"set-of-emails/maildir/bsd/lhost-office365-13.eml","subject":"にゃーん","messageid":"","replycode":"550","smtpagent":"Office365","hardbounce":true,"smtpcommand":"","destination":"neko.kyoto.example.jp","senderdomain":"example.com","feedbacktype":"","diagnosticcode":"Error Details Reported error: 550 5.1.10 RESOLVER.ADR.RecipientNotFound; Recipient not found by SMTP address lookup DSN generated by: NEKONYAAN0022.apcprd01.prod.exchangelabs.com","diagnostictype":"","deliverystatus":"5.1.10","timezoneoffset":"+0000","addresser":"neko@example.com","recipient":"kijitora-nyaan@neko.kyoto.example.jp","timestamp":1493508885}]
308
+ [
309
+ {
310
+ "destination": "google.example.com",
311
+ "lhost": "gmail-smtp-in.l.google.com",
312
+ "hardbounce": 0,
313
+ "reason": "authfailure",
314
+ "catch": null,
315
+ "addresser": "michitsuna@example.jp",
316
+ "alias": "nekochan@example.co.jp",
317
+ "smtpagent": "Postfix",
318
+ "smtpcommand": "DATA",
319
+ "senderdomain": "example.jp",
320
+ "listid": "",
321
+ "action": "failed",
322
+ "feedbacktype": "",
323
+ "messageid": "hwK7pzjzJtz0RF9Y@relay3.example.com",
324
+ "origin": "./gmail-5.7.26.eml",
325
+ "recipient": "kijitora@google.example.com",
326
+ "rhost": "gmail-smtp-in.l.google.com",
327
+ "subject": "Nyaan",
328
+ "timezoneoffset": "+0900",
329
+ "replycode": 550,
330
+ "token": "84656774898baa90660be3e12fe0526e108d4473",
331
+ "diagnostictype": "SMTP",
332
+ "timestamp": 1650119685,
333
+ "diagnosticcode": "host gmail-smtp-in.l.google.com[64.233.187.27] said: This mail has been blocked because the sender is unauthenticated. Gmail requires all senders to authenticate with either SPF or DKIM. Authentication results: DKIM = did not pass SPF [relay3.example.com] with ip: [192.0.2.22] = did not pass For instructions on setting up authentication, go to https://support.google.com/mail/answer/81126#authentication c2-202200202020202020222222cat.127 - gsmtp (in reply to end of DATA command)",
334
+ "deliverystatus": "5.7.26"
335
+ }
336
+ ]
269
337
  ```
270
338
 
271
- Sisimai Specification
339
+ Differences between Sisimai 4 and Sisimai 5
272
340
  ===================================================================================================
273
- Differences between Ruby version and Perl version
341
+ [Sisimai 4.25.16p1](https://github.com/sisimai/rb-sisimai/releases/tag/v4.25.16p1)と
342
+ [Sisimai 5](https://github.com/sisimai/rb-sisimai/releases/tag/v5.0.0)には下記のような違いがあります。
343
+ それぞれの詳細は[Sisimai | 違いの一覧](https://libsisimai.org/ja/diff/)を参照してください。
344
+
345
+ Features
346
+ ---------------------------------------------------------------------------------------------------
347
+ Sisimai 5.0.0から**Ruby 2.4以上**が必要になります。
348
+
349
+ | 機能 | Sisimai 4 | Sisimai 5 |
350
+ |------------------------------------------------------|--------------------|---------------------|
351
+ | 動作環境(CRuby) | 2.1 - | **2.4** or later |
352
+ | 動作環境(JRuby) | 9.0.4.0 - 9.1.17.0 | **9.2** or later |
353
+ | 元メールファイルを操作可能なコールバック機能 | なし | あり[^3] |
354
+ | 解析エンジン(MTA/ESPモジュール)の数 | 68 | 70 |
355
+ | 検出可能なバウンス理由の数 | 29 | 34 |
356
+ | 依存Gem数(Ruby Standard Gemsを除く) | 1 Gem | 1 Gem |
357
+ | ソースコードの行数 | 10,800 行 | 11,370 行 |
358
+ | テストフレームワーク | rspec | minitest |
359
+ | テスト件数(spec/またはtest/ディレクトリ) | 311,000 件 | 338,000 件 |
360
+ | 1秒間に解析できるバウンスメール数[^4] | 231 通 | 305 通 |
361
+ | ライセンス | 2条項BSD | 2条項BSD |
362
+ | 開発会社による商用サポート | 提供中 | 提供中 |
363
+
364
+ [^3]: `Sisimai.rise`メソッドで指定する`:c___`パラメーター第二引数で指定可能
365
+ [^4]: macOS Monterey/1.6GHz Dual-Core Intel Core i5/16GB-RAM/Ruby 3.3.0
366
+
367
+ Decoding Method
368
+ ---------------------------------------------------------------------------------------------------
369
+ いくつかの解析メソッド名、クラス名、パラメーター名がSisimai 5で変更になっています。解析済みデータの
370
+ 各項目は[LIBSISIMAI.ORG/JA/DATA](https://libsisimai.org/ja/data/)を参照してください。
371
+
372
+ | 解析用メソッド周辺の変更箇所 | Sisimai 4 | Sisimai 5 |
373
+ |------------------------------------------------------|--------------------|---------------------|
374
+ | 解析メソッド名 | `Sisimai.make` | `Sisimai.rise` |
375
+ | 出力メソッド名 | `Sisimai.dump` | `Sisimai.dump` |
376
+ | 解析メソッドが返すオブジェクトのクラス | `Sisimai::Data` | `Sisimai::Fact` |
377
+ | コールバック用のパラメーター名 | `hook` | `c___`[^5] |
378
+ | ハードバウンスかソフトバウンスかを識別するメソッド名 | `softbounce` | `hardbounce` |
379
+ | "vacation"をデフォルトで検出するかどうか | 検出する | 検出しない |
380
+ | Sisimai::Messageがオブジェクトを返すかどうか | 返す | 返さない |
381
+ | MIME解析用クラスの名前 | `Sisimai::MIME` | `Sisimai::RFC2045` |
382
+ | SMTPセッションの解析をするかどうか | しない | する[^6] |
383
+
384
+ [^5]: `:c___`は漁港で使う釣り針に見える
385
+ [^6]: `Sisimai::SMTP::Transcript.rise`メソッドによる
386
+
387
+ MTA/ESP Module Names
274
388
  ---------------------------------------------------------------------------------------------------
275
- 公開中のPerl版Sisimai(p5-sisimai)とRuby版Sisimai(rb-sisimai)は下記のような違いがあります。bounceHammer
276
- 2.7.13p3とSisimai(シシマイ)の違いについては[Sisimai | 違いの一覧](https://libsisimai.org/ja/diff/)
277
- ご覧ください。
278
-
279
- | 機能 | Ruby version | Perl version |
280
- |---------------------------------------------|----------------|---------------|
281
- | 動作環境 | Ruby 2.4 - 2.7 | Perl 5.10 - |
282
- | | JRuby 9.0.4.0- | |
283
- | 解析精度の割合(2000通のメール)[1] | 1.00 | 1.00 |
284
- | メール解析速度(1000通のメール) | 2.22秒[2] | 1.35秒 |
285
- | インストール方法 | gem install | cpanm, cpm |
286
- | 依存モジュール数(コアモジュールを除く) | 1モジュール | 2モジュール |
287
- | LOC:ソースコードの行数 | 10300行 | 10500行 |
288
- | テスト件数(spec/,t/,xt/ディレクトリ) | 453000件 | 311000件 |
289
- | ライセンス | 二条項BSD | 二条項BSD |
290
- | 開発会社によるサポート契約 | 提供中 | 提供中 |
291
-
292
- 1. [./ANALYTICAL-PRECISION](https://github.com/sisimai/rb-sisimai/blob/master/ANALYTICAL-PRECISION)を参照
293
- 2. Xeon E5-2640 2.5GHz x 2 cores | 5000 bogomips | 1GB RAM | Ruby 2.3.4p301
294
-
295
- Other spec of Sisimai
389
+ Sisimai 5で3個のESPモジュール名(解析エンジン)が変更になりました。詳細はMTA/ESPモジュールの一覧/
390
+ [LIBSISIMAI.ORG/JA/ENGINE](https://libsisimai.org/ja/engine/)を参照してください。
391
+
392
+ | `Sisimai::Rhost::` | Sisimai 4 | Sisimai 5 |
393
+ |------------------------------------------------------|--------------------|---------------------|
394
+ | Microsoft Exchange Online | `ExchangeOnline` | `Microsoft` |
395
+ | Google Workspace | `GoogleApps` | `Google` |
396
+ | Tencent | `TencentQQ` | `Tencent` |
397
+
398
+ Bounce Reasons
296
399
  ---------------------------------------------------------------------------------------------------
297
- - [**解析モジュールの一覧**](https://libsisimai.org/ja/engine/)
298
- - [**バウンス理由の一覧**](https://libsisimai.org/ja/reason/)
299
- - [**Sisimai::Dataのデータ構造**](https://libsisimai.org/ja/data/)
400
+ Sisimai 5では新たに5個のバウンス理由が増えました。検出可能なバウンス理由の一覧は
401
+ [LIBSISIMAI.ORG/JA/REASON](https://libsisimai.org/en/reason/)を参照してください。
402
+
403
+ | バウンスした理由 | Sisimai 4 | Sisimai 5 |
404
+ |------------------------------------------------------|--------------------|---------------------|
405
+ | ドメイン認証によるもの(SPF,DKIM,DMARC) | `SecurityError` | `AuthFailure` |
406
+ | 送信者のドメイン・IPアドレスの低いレピュテーション | `Blocked` | `BadReputation` |
407
+ | PTRレコードが未設定または無効なPTRレコード | `Blocked` | `RequirePTR` |
408
+ | RFCに準拠していないメール[^7] | `SecurityError` | `NotCompliantRFC` |
409
+ | 単位時間の流量制限・送信速度が速すぎる | `SecurityError` | `Speeding` |
410
+
411
+ [^7]: RFC5322など
300
412
 
301
413
  Contributing
302
414
  ===================================================================================================
@@ -305,7 +417,7 @@ Bug report
305
417
  もしもSisimaiにバグを発見した場合は[Issues](https://github.com/sisimai/rb-sisimai/issues)にて連絡を
306
418
  いただけると助かります。
307
419
 
308
- Emails could not be parsed
420
+ Emails could not be decoded
309
421
  ---------------------------------------------------------------------------------------------------
310
422
  Sisimaiで解析できないバウンスメールは
311
423
  [set-of-emails/to-be-debugged-because/sisimai-cannot-parse-yet](https://github.com/sisimai/set-of-emails/tree/master/to-be-debugged-because/sisimai-cannot-parse-yet)リポジトリに追加してPull-Requestを送ってください。
@@ -315,7 +427,7 @@ Other Information
315
427
  Related sites
316
428
  ---------------------------------------------------------------------------------------------------
317
429
  * __@libsisimai__ | [Sisimai on Twitter (@libsisimai)](https://twitter.com/libsisimai)
318
- * __libSISIMAI.ORG__ | [Sisimai | The successor to bounceHammer, Library to parse bounce mails](https://libsisimai.org/)
430
+ * __LIBSISIMAI.ORG__ | [SISIMAI | MAIL ANALYZING INTERFACE | DECODING BOUNCES, BETTER AND FASTER.](https://libsisimai.org/)
319
431
  * __Sisimai Blog__ | [blog.libsisimai.org](http://blog.libsisimai.org/)
320
432
  * __Facebook Page__ | [facebook.com/libsisimai](https://www.facebook.com/libsisimai/)
321
433
  * __GitHub__ | [github.com/sisimai/rb-sisimai](https://github.com/sisimai/rb-sisimai)
@@ -338,7 +450,7 @@ Author
338
450
 
339
451
  Copyright
340
452
  ===================================================================================================
341
- Copyright (C) 2015-2023 azumakuniyuki, All Rights Reserved.
453
+ Copyright (C) 2015-2024 azumakuniyuki, All Rights Reserved.
342
454
 
343
455
  License
344
456
  ===================================================================================================