sisimai 4.25.17 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -3
  3. data/ANALYTICAL-PRECISION +2 -2
  4. data/Benchmarks.mk +3 -3
  5. data/CONTRIBUTING +1 -1
  6. data/ChangeLog.md +406 -407
  7. data/Developers.mk +5 -6
  8. data/Gemfile +1 -1
  9. data/Makefile +12 -12
  10. data/README-JA.md +142 -94
  11. data/README.md +282 -150
  12. data/Rakefile +9 -3
  13. data/Repository.mk +2 -3
  14. data/lib/sisimai/address.rb +118 -74
  15. data/lib/sisimai/arf.rb +84 -82
  16. data/lib/sisimai/datetime.rb +5 -52
  17. data/lib/sisimai/{data → fact}/json.rb +7 -9
  18. data/lib/sisimai/fact/yaml.rb +31 -0
  19. data/lib/sisimai/fact.rb +468 -0
  20. data/lib/sisimai/lhost/activehunter.rb +12 -14
  21. data/lib/sisimai/lhost/amavis.rb +11 -14
  22. data/lib/sisimai/lhost/amazonses.rb +37 -41
  23. data/lib/sisimai/lhost/amazonworkmail.rb +15 -18
  24. data/lib/sisimai/lhost/aol.rb +12 -14
  25. data/lib/sisimai/lhost/apachejames.rb +19 -21
  26. data/lib/sisimai/lhost/barracuda.rb +10 -12
  27. data/lib/sisimai/lhost/bigfoot.rb +21 -21
  28. data/lib/sisimai/lhost/biglobe.rb +15 -16
  29. data/lib/sisimai/lhost/courier.rb +20 -20
  30. data/lib/sisimai/lhost/domino.rb +23 -19
  31. data/lib/sisimai/lhost/einsundeins.rb +20 -16
  32. data/lib/sisimai/lhost/exchange2003.rb +30 -29
  33. data/lib/sisimai/lhost/exchange2007.rb +70 -58
  34. data/lib/sisimai/lhost/exim.rb +175 -161
  35. data/lib/sisimai/lhost/ezweb.rb +31 -56
  36. data/lib/sisimai/lhost/facebook.rb +21 -33
  37. data/lib/sisimai/lhost/fml.rb +43 -48
  38. data/lib/sisimai/lhost/gmail.rb +29 -29
  39. data/lib/sisimai/lhost/gmx.rb +18 -17
  40. data/lib/sisimai/lhost/googlegroups.rb +9 -10
  41. data/lib/sisimai/lhost/gsuite.rb +21 -27
  42. data/lib/sisimai/lhost/imailserver.rb +25 -39
  43. data/lib/sisimai/lhost/interscanmss.rb +28 -31
  44. data/lib/sisimai/lhost/kddi.rb +22 -28
  45. data/lib/sisimai/lhost/mailfoundry.rb +11 -12
  46. data/lib/sisimai/lhost/mailmarshalsmtp.rb +25 -29
  47. data/lib/sisimai/lhost/mailru.rb +33 -27
  48. data/lib/sisimai/lhost/mcafee.rb +21 -31
  49. data/lib/sisimai/lhost/messagelabs.rb +17 -20
  50. data/lib/sisimai/lhost/messagingserver.rb +40 -37
  51. data/lib/sisimai/lhost/mfilter.rb +15 -16
  52. data/lib/sisimai/lhost/mxlogic.rb +24 -23
  53. data/lib/sisimai/lhost/notes.rb +17 -17
  54. data/lib/sisimai/lhost/office365.rb +63 -27
  55. data/lib/sisimai/lhost/opensmtpd.rb +12 -13
  56. data/lib/sisimai/lhost/outlook.rb +12 -15
  57. data/lib/sisimai/lhost/postfix.rb +179 -129
  58. data/lib/sisimai/lhost/powermta.rb +12 -14
  59. data/lib/sisimai/lhost/qmail.rb +44 -47
  60. data/lib/sisimai/lhost/receivingses.rb +15 -20
  61. data/lib/sisimai/lhost/sendgrid.rb +34 -32
  62. data/lib/sisimai/lhost/sendmail.rb +66 -53
  63. data/lib/sisimai/lhost/surfcontrol.rb +19 -19
  64. data/lib/sisimai/lhost/v5sendmail.rb +45 -39
  65. data/lib/sisimai/lhost/verizon.rb +35 -39
  66. data/lib/sisimai/lhost/x1.rb +18 -17
  67. data/lib/sisimai/lhost/x2.rb +17 -14
  68. data/lib/sisimai/lhost/x3.rb +19 -19
  69. data/lib/sisimai/lhost/x4.rb +72 -57
  70. data/lib/sisimai/lhost/x5.rb +17 -19
  71. data/lib/sisimai/lhost/x6.rb +41 -17
  72. data/lib/sisimai/lhost/yahoo.rb +17 -16
  73. data/lib/sisimai/lhost/yandex.rb +16 -20
  74. data/lib/sisimai/lhost/zoho.rb +16 -15
  75. data/lib/sisimai/lhost.rb +8 -10
  76. data/lib/sisimai/mail/maildir.rb +1 -3
  77. data/lib/sisimai/mail/mbox.rb +3 -4
  78. data/lib/sisimai/mail/memory.rb +0 -1
  79. data/lib/sisimai/mail/stdin.rb +1 -3
  80. data/lib/sisimai/mail.rb +3 -7
  81. data/lib/sisimai/mda.rb +28 -42
  82. data/lib/sisimai/message.rb +435 -325
  83. data/lib/sisimai/order.rb +5 -5
  84. data/lib/sisimai/reason/authfailure.rb +64 -0
  85. data/lib/sisimai/reason/badreputation.rb +53 -0
  86. data/lib/sisimai/reason/blocked.rb +94 -160
  87. data/lib/sisimai/reason/contenterror.rb +8 -9
  88. data/lib/sisimai/reason/delivered.rb +4 -6
  89. data/lib/sisimai/reason/exceedlimit.rb +10 -12
  90. data/lib/sisimai/reason/expired.rb +6 -8
  91. data/lib/sisimai/reason/feedback.rb +2 -3
  92. data/lib/sisimai/reason/filtered.rb +17 -19
  93. data/lib/sisimai/reason/hasmoved.rb +9 -10
  94. data/lib/sisimai/reason/hostunknown.rb +15 -15
  95. data/lib/sisimai/reason/mailboxfull.rb +10 -12
  96. data/lib/sisimai/reason/mailererror.rb +18 -20
  97. data/lib/sisimai/reason/mesgtoobig.rb +9 -11
  98. data/lib/sisimai/reason/networkerror.rb +5 -8
  99. data/lib/sisimai/reason/norelaying.rb +8 -11
  100. data/lib/sisimai/reason/notaccept.rb +13 -14
  101. data/lib/sisimai/reason/notcompliantrfc.rb +43 -0
  102. data/lib/sisimai/reason/onhold.rb +6 -9
  103. data/lib/sisimai/reason/policyviolation.rb +14 -12
  104. data/lib/sisimai/reason/rejected.rb +26 -24
  105. data/lib/sisimai/reason/requireptr.rb +69 -0
  106. data/lib/sisimai/reason/securityerror.rb +33 -36
  107. data/lib/sisimai/reason/spamdetected.rb +114 -147
  108. data/lib/sisimai/reason/speeding.rb +49 -0
  109. data/lib/sisimai/reason/suspend.rb +11 -11
  110. data/lib/sisimai/reason/syntaxerror.rb +11 -10
  111. data/lib/sisimai/reason/systemerror.rb +7 -9
  112. data/lib/sisimai/reason/systemfull.rb +7 -8
  113. data/lib/sisimai/reason/toomanyconn.rb +9 -11
  114. data/lib/sisimai/reason/undefined.rb +2 -3
  115. data/lib/sisimai/reason/userunknown.rb +129 -146
  116. data/lib/sisimai/reason/vacation.rb +3 -4
  117. data/lib/sisimai/reason/virusdetected.rb +10 -11
  118. data/lib/sisimai/reason.rb +59 -64
  119. data/lib/sisimai/rfc1894.rb +55 -28
  120. data/lib/sisimai/rfc2045.rb +373 -0
  121. data/lib/sisimai/rfc3464.rb +250 -308
  122. data/lib/sisimai/rfc3834.rb +42 -45
  123. data/lib/sisimai/rfc5322.rb +75 -100
  124. data/lib/sisimai/rfc5965.rb +31 -0
  125. data/lib/sisimai/rhost/cox.rb +5 -6
  126. data/lib/sisimai/rhost/franceptt.rb +6 -8
  127. data/lib/sisimai/rhost/godaddy.rb +12 -12
  128. data/lib/sisimai/rhost/{googleapps.rb → google.rb} +80 -72
  129. data/lib/sisimai/rhost/iua.rb +9 -10
  130. data/lib/sisimai/rhost/kddi.rb +6 -8
  131. data/lib/sisimai/rhost/{exchangeonline.rb → microsoft.rb} +115 -114
  132. data/lib/sisimai/rhost/mimecast.rb +42 -40
  133. data/lib/sisimai/rhost/nttdocomo.rb +13 -18
  134. data/lib/sisimai/rhost/spectrum.rb +10 -12
  135. data/lib/sisimai/rhost/{tencentqq.rb → tencent.rb} +7 -8
  136. data/lib/sisimai/rhost.rb +23 -31
  137. data/lib/sisimai/smtp/command.rb +59 -0
  138. data/lib/sisimai/smtp/error.rb +4 -7
  139. data/lib/sisimai/smtp/reply.rb +161 -74
  140. data/lib/sisimai/smtp/status.rb +504 -393
  141. data/lib/sisimai/smtp/transcript.rb +124 -0
  142. data/lib/sisimai/smtp.rb +0 -1
  143. data/lib/sisimai/string.rb +74 -5
  144. data/lib/sisimai/time.rb +1 -2
  145. data/lib/sisimai/version.rb +1 -1
  146. data/lib/sisimai.rb +35 -21
  147. data/set-of-emails/maildir/bsd/lhost-domino-02.eml +6 -3
  148. data/set-of-emails/maildir/bsd/lhost-googlegroups-15.eml +174 -0
  149. data/set-of-emails/maildir/bsd/lhost-gsuite-15.eml +229 -0
  150. data/set-of-emails/maildir/bsd/lhost-postfix-75.eml +51 -0
  151. data/set-of-emails/maildir/bsd/lhost-postfix-76.eml +101 -0
  152. data/set-of-emails/maildir/bsd/lhost-postfix-77.eml +74 -0
  153. data/set-of-emails/maildir/bsd/lhost-postfix-78.eml +91 -0
  154. data/set-of-emails/maildir/bsd/lhost-receivingses-08.eml +88 -0
  155. data/set-of-emails/maildir/bsd/rfc3464-43.eml +88 -0
  156. data/set-of-emails/maildir/bsd/rhost-google-03.eml +101 -0
  157. data/set-of-emails/maildir/bsd/rhost-google-04.eml +102 -0
  158. data/set-of-emails/maildir/bsd/rhost-google-05.eml +82 -0
  159. data/set-of-emails/maildir/bsd/rhost-google-06.eml +102 -0
  160. data/set-of-emails/maildir/bsd/rhost-google-07.eml +69 -0
  161. data/set-of-emails/maildir/bsd/rhost-google-08.eml +99 -0
  162. data/sisimai-java.gemspec +1 -1
  163. data/sisimai.gemspec +1 -1
  164. metadata +41 -21
  165. data/.rspec +0 -2
  166. data/lib/sisimai/data/yaml.rb +0 -33
  167. data/lib/sisimai/data.rb +0 -411
  168. data/lib/sisimai/mime.rb +0 -456
  169. data/set-of-emails/maildir/mac/reported-from-nick4tech-san-01.eml +0 -6
  170. /data/set-of-emails/maildir/bsd/{rfc3464-41.eml → rfc3834-05.eml} +0 -0
  171. /data/set-of-emails/maildir/bsd/{rhost-googleapps-01.eml → rhost-google-01.eml} +0 -0
  172. /data/set-of-emails/maildir/bsd/{rhost-googleapps-02.eml → rhost-google-02.eml} +0 -0
  173. /data/set-of-emails/maildir/bsd/{rhost-exchangeonline-01.eml → rhost-microsoft-01.eml} +0 -0
  174. /data/set-of-emails/maildir/bsd/{rhost-exchangeonline-02.eml → rhost-microsoft-02.eml} +0 -0
  175. /data/set-of-emails/maildir/bsd/{rhost-exchangeonline-03.eml → rhost-microsoft-03.eml} +0 -0
  176. /data/set-of-emails/maildir/bsd/{rhost-tencentqq-01.eml → rhost-tencent-01.eml} +0 -0
  177. /data/set-of-emails/maildir/bsd/{rhost-tencentqq-02.eml → rhost-tencent-02.eml} +0 -0
  178. /data/set-of-emails/maildir/bsd/{rhost-tencentqq-03.eml → rhost-tencent-03.eml} +0 -0
data/Developers.mk CHANGED
@@ -5,7 +5,7 @@
5
5
  # | |_| | __/\ V / __/ | (_) | |_) | __/ | \__ \_| | | | | | <
6
6
  # |____/ \___| \_/ \___|_|\___/| .__/ \___|_| |___(_)_| |_| |_|_|\_\
7
7
  # |_|
8
- # -----------------------------------------------------------------------------
8
+ # -------------------------------------------------------------------------------------------------
9
9
  SHELL := /bin/sh
10
10
  HERE := $(shell pwd)
11
11
  NAME := Sisimai
@@ -34,11 +34,10 @@ MACFORMATSET := $(SET_OF_EMAIL)/maildir/mac
34
34
 
35
35
  INDEX_LENGTH := 24
36
36
  DESCR_LENGTH := 50
37
- BH_CAN_PARSE := AmazonSES AmazonWorkMail Aol Bigfoot Biglobe Courier EZweb Exim \
38
- Facebook GSuite Google KDDI MessageLabs MessagingServer Office365 \
39
- Postfix SendGrid Sendmail Verizon X5 Yandex qmail
40
-
41
- # -----------------------------------------------------------------------------
37
+ BH_CAN_PARSE := AmazonSES AmazonWorkMail Aol Bigfoot Biglobe Courier EZweb Exim Facebook GSuite \
38
+ Google KDDI MessageLabs MessagingServer Office365 Postfix SendGrid Sendmail Verizon \
39
+ X5 Yandex qmail
40
+ # -------------------------------------------------------------------------------------------------
42
41
  .PHONY: clean
43
42
 
44
43
  private-sample:
data/Gemfile CHANGED
@@ -5,7 +5,7 @@ gemspec name: 'sisimai'
5
5
 
6
6
  group :development, :test do
7
7
  gem 'rake', :require => false
8
- gem 'rspec', :require => false
8
+ gem 'minitest', :require => false
9
9
  gem 'coveralls', :require => false
10
10
  end
11
11
 
data/Makefile CHANGED
@@ -4,7 +4,7 @@
4
4
  # | |\/| |/ _` | |/ / _ \ |_| | |/ _ \
5
5
  # | | | | (_| | < __/ _| | | __/
6
6
  # |_| |_|\__,_|_|\_\___|_| |_|_|\___|
7
- # -----------------------------------------------------------------------------
7
+ # -------------------------------------------------------------------------------------------------
8
8
  SHELL := /bin/sh
9
9
  TIME := $(shell date '+%s')
10
10
  NAME := sisimai
@@ -12,19 +12,17 @@ RUBY ?= ruby
12
12
  JRUBY ?= /usr/local/jr
13
13
  RAKE ?= rake
14
14
  MKDIR := mkdir -p
15
- RSPEC := rspec -Ilib -f progress
16
15
  CP := cp
17
16
  RM := rm -f
18
17
 
19
- DEPENDENCIES = bundle rake rspec
18
+ DEPENDENCIES = bundle rake minitest
20
19
  .DEFAULT_GOAL = git-status
21
- REPOS_TARGETS = git-status git-push git-commit-amend git-tag-list git-diff \
22
- git-reset-soft git-rm-cached git-branch
20
+ REPOS_TARGETS = git-status git-push git-commit-amend git-tag-list git-diff git-reset-soft \
21
+ git-rm-cached git-branch
23
22
  DEVEL_TARGETS = private-sample
24
23
  BENCH_TARGETS = profile speed-test loc
25
24
 
26
-
27
- # -----------------------------------------------------------------------------
25
+ # -------------------------------------------------------------------------------------------------
28
26
  .PHONY: clean
29
27
 
30
28
  depend:
@@ -57,18 +55,20 @@ release:
57
55
  PATH="$(JRUBY)/bin:$$PATH" $(JRUBY)/bin/rake release; \
58
56
  fi
59
57
 
60
- test: cruby-test
58
+ test: user-test author-test
59
+ user-test:
60
+ rake publictest
61
+
62
+ author-test:
63
+ rake privatetest
61
64
 
62
65
  check:
63
66
  find lib -type f -exec grep --color -E ' $$' {} /dev/null \;
64
67
  find lib -type f -exec grep --color -E '[;][ ]*$$' {} /dev/null \;
65
68
 
66
- cruby-test:
67
- $(RAKE) spec
68
-
69
69
  jruby-test:
70
70
  if [ -d "$(JRUBY)" ]; then \
71
- PATH="$(JRUBY)/bin:$$PATH" LS_HEAP_SIZE='1024m' $(JRUBY)/bin/rake spec; \
71
+ PATH="$(JRUBY)/bin:$$PATH" LS_HEAP_SIZE='1024m' $(JRUBY)/bin/rake publictest; \
72
72
  fi
73
73
 
74
74
  patrol:
data/README-JA.md CHANGED
@@ -1,24 +1,25 @@
1
1
  ![](https://libsisimai.org/static/images/logo/sisimai-x01.png)
2
-
3
2
  [![License](https://img.shields.io/badge/license-BSD%202--Clause-orange.svg)](https://github.com/sisimai/rb-sisimai/blob/master/LICENSE)
4
3
  [![Coverage Status](https://img.shields.io/coveralls/sisimai/rb-sisimai.svg)](https://coveralls.io/r/sisimai/rb-sisimai)
5
- [![Ruby](https://img.shields.io/badge/ruby-v2.1.0--v3.3.0-red.svg)](https://www.ruby-lang.org/)
4
+ [![Ruby](https://img.shields.io/badge/ruby-v2.4.0--v2.7.0-red.svg)](https://www.ruby-lang.org/)
6
5
  [![Gem Version](https://badge.fury.io/rb/sisimai.svg)](https://badge.fury.io/rb/sisimai)
7
6
 
8
7
  > [!IMPORTANT]
9
8
  > **2024年2月2日の時点でこのリポジトリのデフォルトブランチは[5-stable](https://github.com/sisimai/rb-sisimai/tree/5-stable)
10
- > (Sisimai 5)になりました。** もし古いバージョンを使いたい場合は[4-stable](https://github.com/sisimai/rb-sisimai/tree/4-stable)
9
+ > (Sisimai 5)になりました。** もし古いバージョンを使いたい場合は[4-stable](https://github.com/sisimai/rb-sisimai/tree/4-stable)[^1]
11
10
  > ブランチを見てください。また`main`や`master`ブランチはもうこのリポジトリでは使用していません。
12
-
13
- > [!CAUTION]
14
- > **Sisimai 4.25.14p11およびそれ以前のバージョンには 正規表現に関する脆弱性
15
- > [ReDoS: CVE-2022-4891](https://jvndb.jvn.jp/ja/contents/2022/JVNDB-2022-005663.html)があります。
16
- > 該当するバージョンをお使いの場合はv4.25.14p12以降へアップグレードしてください。**
11
+ [^1]: 4系を`clone`する場合は`git clone -b 4-stable https://github.com/sisimai/rb-sisimai.git`
17
12
 
18
13
  > [!WARNING]
19
14
  > Sisimai 5はRuby 2.4以上が必要です。インストール/アップグレードを実行する前に`ruby -v`コマンドで
20
15
  > システムに入っているRubyのバージョンを確認してください。
21
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
+
22
+
22
23
  - [**README(English)**](README.md)
23
24
  - [シシマイ? | What is Sisimai](#what-is-sisimai)
24
25
  - [主な特徴的機能 | Key features](#key-features)
@@ -48,16 +49,15 @@
48
49
  - [ライセンス | License](#license)
49
50
 
50
51
  What is Sisimai
51
- ===============================================================================
52
- Sisimai(シシマイ)はRFC5322準拠のエラーメールを解析し、解析結果をデータ構造に
53
- 変換するインターフェイスを提供するRubyライブラリです。
54
- [github.com/sisimai/p5-sisimai](https://github.com/sisimai/p5-sisimai/)
52
+ ===================================================================================================
53
+ Sisimai(シシマイ)はRFC5322準拠のエラーメールを解析し、解析結果をデータ構造に変換するインターフェイス
54
+ を提供するRubyライブラリです。[github.com/sisimai/p5-sisimai](https://github.com/sisimai/p5-sisimai/)
55
55
  で公開しているPerl版シシマイから移植しました。
56
56
 
57
57
  ![](https://libsisimai.org/static/images/figure/sisimai-overview-1.png)
58
58
 
59
59
  Key features
60
- -------------------------------------------------------------------------------
60
+ ---------------------------------------------------------------------------------------------------
61
61
  * __エラーメールをデータ構造に変換__
62
62
  * Rubyのデータ形式(HashとArray)とJSON(String)に対応
63
63
  * __インストールも使用も簡単__
@@ -67,32 +67,31 @@ Key features
67
67
  * 解析精度はbounceHammerの2倍
68
68
  * 68種類のMTA/MDA/ESPに対応
69
69
  * Feedback Loopにも対応
70
- * 29種類のエラー理由を検出
70
+ * 32種類のエラー理由を検出
71
71
 
72
72
  Setting Up Sisimai
73
- ===============================================================================
74
-
73
+ ===================================================================================================
75
74
  System requirements
76
- -------------------------------------------------------------------------------
77
- Sisimaiの動作環境についての詳細は
78
- [Sisimai | シシマイを使ってみる](https://libsisimai.org/ja/start/)をご覧ください。
75
+ ---------------------------------------------------------------------------------------------------
76
+ Sisimaiの動作環境についての詳細は[Sisimai | シシマイを使ってみる](https://libsisimai.org/ja/start/)
77
+ をご覧ください。
79
78
 
80
79
 
81
- * [Ruby 2.1.0 or later](http://www.ruby-lang.org/)
80
+ * [Ruby 2.4.0 or later](http://www.ruby-lang.org/)
82
81
  * [__Oj | The fastest JSON parser and object serializer__](https://rubygems.org/gems/oj)
83
- * Also works on [JRuby 9.0.4.0 - 9.1.17.0](http://jruby.org)
82
+ * Also works on [JRuby 9.0.4.0 or later](http://jruby.org)
84
83
  * [__JrJackson | A mostly native JRuby wrapper for the java jackson json processor jar__](https://rubygems.org/gems/jrjackson)
85
84
 
86
85
  Install
87
- -------------------------------------------------------------------------------
86
+ ---------------------------------------------------------------------------------------------------
88
87
  ### From RubyGems.org
89
88
 
90
89
  ```shell
91
90
  $ sudo gem install sisimai
92
- Fetching: sisimai-4.25.17.gem (100%)
93
- Successfully installed sisimai-4.25.17
94
- Parsing documentation for sisimai-4.25.17
95
- Installing ri documentation for sisimai-4.25.17
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
96
95
  Done installing documentation for sisimai after 6 seconds
97
96
  1 gem installed
98
97
  ```
@@ -104,36 +103,39 @@ $ cd /usr/local/src
104
103
  $ git clone https://github.com/sisimai/rb-sisimai.git
105
104
  $ cd ./rb-sisimai
106
105
  $ sudo make depend install-from-local
107
- gem install bundle rake rspec coveralls
106
+ gem install bundle rake minitest coveralls
108
107
  ...
109
108
  4 gems installed
110
109
  bundle exec rake install
111
- sisimai 4.25.17 built to pkg/sisimai-4.25.17.gem.
112
- sisimai (4.25.17) installed.
110
+ sisimai 4.25.5 built to pkg/sisimai-4.25.5.gem.
111
+ sisimai (4.25.5) installed.
113
112
  ```
114
113
 
115
114
  Usage
116
115
  ======
117
-
118
116
  Basic usage
119
- -------------------------------------------------------------------------------
120
- 下記のようにSisimaiの`make()`メソッドをmboxかMaildirのPATHを引数にして実行すると
121
- 解析結果が配列で返ってきます。v4.25.6から元データとなった電子メールファイルへの
122
- PATHを保持する`origin`が利用できます。
117
+ ---------------------------------------------------------------------------------------------------
118
+ 下記のようにSisimaiの`rise()`メソッドをmboxかMaildirのPATHを引数にして実行すると解析結果が配列で
119
+ 返ってきます。v4.25.6から元データとなった電子メールファイルへのPATHを保持する`origin`が利用できます。
123
120
 
124
121
  ```ruby
125
122
  #! /usr/bin/env ruby
126
123
  require 'sisimai'
127
- v = Sisimai.make('/path/to/mbox') # or path to Maildir/
124
+ v = Sisimai.rise('/path/to/mbox') # or path to Maildir/
128
125
 
129
- # Beginning with v4.23.0, both make() and dump() method of Sisimai class can
130
- # read bounce messages from variable instead of a path to mailbox
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
131
128
  f = File.open('/path/to/mbox', 'r'); # or path to Maildir/
132
- v = Sisimai.make(f.read)
129
+ v = Sisimai.rise(f.read)
130
+
131
+ # If you want to get bounce records which reason is "delivered", set "delivered" option to rise()
132
+ # method like the following:
133
+ v = Sisimai.rise('/path/to/mbox', delivered: true)
133
134
 
134
- # If you want to get bounce records which reason is "delivered", set "delivered"
135
- # option to make() method like the following:
136
- v = Sisimai.make('/path/to/mbox', delivered: true)
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:
138
+ v = Sisimai.rise('/path/to/mbox', vacation: true);
137
139
 
138
140
  if v.is_a? Array
139
141
  v.each do |e|
@@ -148,6 +150,7 @@ if v.is_a? Array
148
150
  puts e.replycode # 550
149
151
  puts e.reason # userunknown
150
152
  puts e.origin # /var/spool/bounce/Maildir/new/1740074341.eml
153
+ puts e.hardbounce # true
151
154
 
152
155
  h = e.damn # Convert to HASH
153
156
  j = e.dump('json') # Convert to JSON string
@@ -157,9 +160,9 @@ end
157
160
  ```
158
161
 
159
162
  Convert to JSON
160
- -------------------------------------------------------------------------------
161
- 下記のようにSisimaiの`dump()`メソッドをmboxかMaildirのPATHを引数にして実行すると
162
- 解析結果が文字列(JSON)で返ってきます。
163
+ ---------------------------------------------------------------------------------------------------
164
+ 下記のようにSisimaiの`dump()`メソッドをmboxかMaildirのPATHを引数にして実行すると解析結果が文字列(JSON)
165
+ で返ってきます。
163
166
 
164
167
  ```ruby
165
168
  # Get JSON string from parsed mailbox or Maildir/
@@ -170,71 +173,119 @@ puts Sisimai.dump('/path/to/mbox', delivered: true)
170
173
  ```
171
174
 
172
175
  Callback feature
173
- -------------------------------------------------------------------------------
174
- Sisimai 4.19.0から`Sisimai.make()`と`Sisimai.dump()`にLamda(Procオブジェクト)
175
- を引数`hook`に指定できるコールバック機能が実装されました。
176
- `hook`に指定したコードによって処理された結果は`Sisimai::Data.catch`
177
- メソッドで得ることができます。
176
+ ---------------------------------------------------------------------------------------------------
177
+ `Sisimai.rise`と`Sisimai.dump`の`:c___`引数はコールバック機能で呼び出されるProcオブジェクトを保持する
178
+ 配列です。`:c___`の1番目の要素には`Sisimai::Message.parse`で呼び出されるProcオブジェクトでメールヘッダ
179
+ と本文に対して行う処理を、2番目の要素には、解析対象のメールファイルに対して行う処理をそれぞれ入れます。
180
+
181
+ 各Procオブジェクトで処理した結果は`Sisimai::Data.catch`を通して得られます。
182
+
183
+ ### [0] メールヘッダと本文に対して
184
+ `:c___`に渡す配列の最初の要素に入れたProcオブジェクトは`Sisimai::Message->parse()`で呼び出されます。
178
185
 
179
186
  ```ruby
180
187
  #! /usr/bin/env ruby
181
188
  require 'sisimai'
182
- callbackto = lambda do |v|
183
- r = { 'x-mailer' => '', 'queue-id' => '' }
189
+ code = lambda do |args|
190
+ head = args['headers'] # (*Hash) Email headers
191
+ body = args['message'] # (String) Message body
192
+ adds = { 'x-mailer' => '', 'queue-id' => '' }
184
193
 
185
- if cv = v['message'].match(/^X-Postfix-Queue-ID:\s*(.+)$/)
186
- r['queue-id'] = cv[1]
194
+ if cv = body.match(/^X-Postfix-Queue-ID:\s*(.+)$/)
195
+ adds['queue-id'] = cv[1]
187
196
  end
188
- r['x-mailer'] = v['headers']['x-mailer'] || ''
189
- return r
197
+ r['x-mailer'] = head['x-mailer'] || ''
198
+ return adds
190
199
  end
191
200
 
192
- data = Sisimai.make('/path/to/mbox', hook: callbackto)
193
- json = Sisimai.dump('/path/to/mbox', hook: callbackto)
201
+ data = Sisimai.rise('/path/to/mbox', c___: [code, nil])
202
+ json = Sisimai.dump('/path/to/mbox', c___: [code, nil])
194
203
 
195
- puts data[0].catch['x-mailer'] # Apple Mail (2.1283)
204
+ puts data[0].catch['x-mailer'] # "Apple Mail (2.1283)"
205
+ puts data[0].catch['queue-id'] # "43f4KX6WR7z1xcMG"
196
206
  ```
197
207
 
198
- コールバック機能のより詳細な使い方は
199
- [Sisimai | 解析方法 - コールバック機能](https://libsisimai.org/ja/usage/#callback)
200
- をご覧ください。
208
+ ### 各メールのファイルに対して
209
+ `Sisimai->rise()`と`Sisimai->dump()`の両メソッドに渡せる引数`c___`(配列リファレンス)の2番目に入れた
210
+ コードリファレンスは解析したメールのファイルごとに呼び出されます。
201
211
 
212
+ ```ruby
213
+ path = '/path/to/maildir'
214
+ code = lambda do |args|
215
+ kind = args['kind'] # (String) Sisimai::Mail.kind
216
+ mail = args['mail'] # (String) Entire email message
217
+ path = args['path'] # (String) Sisimai::Mail.path
218
+ sisi = args['sisi'] # (Array) List of Sisimai::Data
219
+
220
+ sisi.each do |e|
221
+ # Insert custom fields into the parsed results
222
+ e.catch ||= {}
223
+ e.catch['size'] = mail.size
224
+ e.catch['kind'] = kind.capitalize
225
+
226
+ if cv = mail.match(/^Return-Path: (.+)$/)
227
+ # Return-Path: <MAILER-DAEMON>
228
+ e.catch['return-path'] = cv[1]
229
+ end
230
+ e.catch['parsedat'] = Time.new.localtime.to_s
231
+
232
+ # Append X-Sisimai-Parsed: header and save into other path
233
+ a = sprintf("X-Sisimai-Parsed: %d", sisi.size)
234
+ p = sprintf("/path/to/another/directory/sisimai-%s.eml", e.token)
235
+ v = mail.sub(/^(From:.+?)$/, '\1' + "\n" + a)
236
+ f = File.open(p, 'w:UTF-8')
237
+ f.write(v)
238
+ f.close
239
+
240
+ # Remove the email file in Maildir/ after parsed
241
+ File.delete(path) if kind == 'maildir'
242
+
243
+ # Need to not return a value
244
+ end
245
+ end
202
246
 
203
- One-Liner
204
- -------------------------------------------------------------------------------
247
+ list = Sisimai.rise(path, c___: [nil, code])
248
+
249
+ puts list[0].catch['size'] # 2202
250
+ puts list[0].catch['kind'] # "Maildir"
251
+ puts list[0].catch['return-path'] # "<MAILER-DAEMON>"
252
+ ```
205
253
 
254
+ コールバック機能のより詳細な使い方は
255
+ [Sisimai | 解析方法 - コールバック機能](https://libsisimai.org/ja/usage/#callback)をご覧ください。
256
+
257
+ One-Liner
258
+ ---------------------------------------------------------------------------------------------------
206
259
  ```shell
207
260
  $ ruby -rsisimai -e 'puts Sisimai.dump($*.shift)' /path/to/mbox
208
261
  ```
209
262
 
210
263
  Output example
211
- -------------------------------------------------------------------------------
264
+ ---------------------------------------------------------------------------------------------------
212
265
  ![](https://libsisimai.org/static/images/demo/sisimai-dump-02.gif)
213
266
 
214
267
  ```json
215
- [{"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","softbounce":0,"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}]
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}]
216
269
  ```
217
270
 
218
271
  Sisimai Specification
219
- ===============================================================================
220
-
272
+ ===================================================================================================
221
273
  Differences between Ruby version and Perl version
222
- -------------------------------------------------------------------------------
223
- 公開中のPerl版Sisimai(p5-sisimai)とRuby版Sisimai(rb-sisimai)は下記のような違いが
224
- あります。bounceHammer 2.7.13p3とSisimai(シシマイ)の違いについては
225
- [Sisimai | 違いの一覧](https://libsisimai.org/ja/diff/)をご覧ください。
274
+ ---------------------------------------------------------------------------------------------------
275
+ 公開中のPerl版Sisimai(p5-sisimai)とRuby版Sisimai(rb-sisimai)は下記のような違いがあります。bounceHammer
276
+ 2.7.13p3とSisimai(シシマイ)の違いについては[Sisimai | 違いの一覧](https://libsisimai.org/ja/diff/)を
277
+ ご覧ください。
226
278
 
227
279
  | 機能 | Ruby version | Perl version |
228
280
  |---------------------------------------------|----------------|---------------|
229
- | 動作環境 | Ruby 2.1 - 3.3 | Perl 5.10 - |
230
- | | JRuby 9.0.4.0 | |
231
- | | - 9.1.17.0 | |
281
+ | 動作環境 | Ruby 2.4 - 2.7 | Perl 5.10 - |
282
+ | | JRuby 9.0.4.0- | |
232
283
  | 解析精度の割合(2000通のメール)[1] | 1.00 | 1.00 |
233
284
  | メール解析速度(1000通のメール) | 2.22秒[2] | 1.35秒 |
234
285
  | インストール方法 | gem install | cpanm, cpm |
235
286
  | 依存モジュール数(コアモジュールを除く) | 1モジュール | 2モジュール |
236
- | LOC:ソースコードの行数 | 10600行 | 10800行 |
237
- | テスト件数(spec/,t/,xt/ディレクトリ) | 241000件 | 270000件 |
287
+ | LOC:ソースコードの行数 | 10300行 | 10500行 |
288
+ | テスト件数(spec/,t/,xt/ディレクトリ) | 453000件 | 311000件 |
238
289
  | ライセンス | 二条項BSD | 二条項BSD |
239
290
  | 開発会社によるサポート契約 | 提供中 | 提供中 |
240
291
 
@@ -242,41 +293,38 @@ Differences between Ruby version and Perl version
242
293
  2. Xeon E5-2640 2.5GHz x 2 cores | 5000 bogomips | 1GB RAM | Ruby 2.3.4p301
243
294
 
244
295
  Other spec of Sisimai
245
- -------------------------------------------------------------------------------
296
+ ---------------------------------------------------------------------------------------------------
246
297
  - [**解析モジュールの一覧**](https://libsisimai.org/ja/engine/)
247
298
  - [**バウンス理由の一覧**](https://libsisimai.org/ja/reason/)
248
299
  - [**Sisimai::Dataのデータ構造**](https://libsisimai.org/ja/data/)
249
300
 
250
301
  Contributing
251
- ===============================================================================
252
-
302
+ ===================================================================================================
253
303
  Bug report
254
- -------------------------------------------------------------------------------
255
- もしもSisimaiにバグを発見した場合は[Issues](https://github.com/sisimai/rb-sisimai/issues)
256
- にて連絡をいただけると助かります。
304
+ ---------------------------------------------------------------------------------------------------
305
+ もしもSisimaiにバグを発見した場合は[Issues](https://github.com/sisimai/rb-sisimai/issues)にて連絡を
306
+ いただけると助かります。
257
307
 
258
308
  Emails could not be parsed
259
- -------------------------------------------------------------------------------
309
+ ---------------------------------------------------------------------------------------------------
260
310
  Sisimaiで解析できないバウンスメールは
261
311
  [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を送ってください。
262
312
 
263
313
  Other Information
264
- ===============================================================================
265
-
314
+ ===================================================================================================
266
315
  Related sites
267
- -------------------------------------------------------------------------------
316
+ ---------------------------------------------------------------------------------------------------
268
317
  * __@libsisimai__ | [Sisimai on Twitter (@libsisimai)](https://twitter.com/libsisimai)
269
- * __LIBSISIMAI.ORG__ | [SISIMAI | MAIL ANALYZING INTERFACE | DECODING BOUNCES, BETTER AND FASTER.](https://libsisimai.org/)
318
+ * __libSISIMAI.ORG__ | [Sisimai | The successor to bounceHammer, Library to parse bounce mails](https://libsisimai.org/)
270
319
  * __Sisimai Blog__ | [blog.libsisimai.org](http://blog.libsisimai.org/)
271
320
  * __Facebook Page__ | [facebook.com/libsisimai](https://www.facebook.com/libsisimai/)
272
321
  * __GitHub__ | [github.com/sisimai/rb-sisimai](https://github.com/sisimai/rb-sisimai)
273
322
  * __RubyGems.org__ | [rubygems.org/gems/sisimai](https://rubygems.org/gems/sisimai)
274
- * __Perl version__ | [Perl version of Sisimai](https://github.com/sisimai/p5-sisimai)
275
- * __Go version__ | [Go version of Sisimai 5](https://github.com/sisimai/go-sisimai)
323
+ * __Perl verson__ | [Perl version of Sisimai](https://github.com/sisimai/p5-sisimai)
276
324
  * __Fixtures__ | [set-of-emails - Sample emails for "make test"](https://github.com/sisimai/set-of-emails)
277
325
 
278
326
  See also
279
- -------------------------------------------------------------------------------
327
+ ---------------------------------------------------------------------------------------------------
280
328
  * [README.md - README.md in English](https://github.com/sisimai/rb-sisimai/blob/master/README.md)
281
329
  * [RFC3463 - Enhanced Mail System Status Codes](https://tools.ietf.org/html/rfc3463)
282
330
  * [RFC3464 - An Extensible Message Format for Delivery Status Notifications](https://tools.ietf.org/html/rfc3464)
@@ -285,14 +333,14 @@ See also
285
333
  * [RFC5322 - Internet Message Format](https://tools.ietf.org/html/rfc5322)
286
334
 
287
335
  Author
288
- ===============================================================================
336
+ ===================================================================================================
289
337
  [@azumakuniyuki](https://twitter.com/azumakuniyuki)
290
338
 
291
339
  Copyright
292
- ===============================================================================
293
- Copyright (C) 2015-2025 azumakuniyuki, All Rights Reserved.
340
+ ===================================================================================================
341
+ Copyright (C) 2015-2023 azumakuniyuki, All Rights Reserved.
294
342
 
295
343
  License
296
- ===============================================================================
344
+ ===================================================================================================
297
345
  This software is distributed under The BSD 2-Clause License.
298
346