sisimai 4.25.16-java → 5.0.0-java
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.
- checksums.yaml +5 -5
- data/.travis.yml +3 -3
- data/ANALYTICAL-PRECISION +2 -2
- data/Benchmarks.mk +3 -3
- data/CONTRIBUTING +1 -1
- data/ChangeLog.md +412 -393
- data/Developers.mk +5 -6
- data/Gemfile +1 -1
- data/Makefile +15 -15
- data/README-JA.md +140 -78
- data/README.md +290 -143
- data/Rakefile +9 -3
- data/Repository.mk +2 -3
- data/lib/sisimai/address.rb +118 -74
- data/lib/sisimai/arf.rb +84 -82
- data/lib/sisimai/datetime.rb +5 -52
- data/lib/sisimai/{data → fact}/json.rb +7 -9
- data/lib/sisimai/fact/yaml.rb +31 -0
- data/lib/sisimai/fact.rb +468 -0
- data/lib/sisimai/lhost/activehunter.rb +12 -14
- data/lib/sisimai/lhost/amavis.rb +11 -14
- data/lib/sisimai/lhost/amazonses.rb +37 -41
- data/lib/sisimai/lhost/amazonworkmail.rb +15 -18
- data/lib/sisimai/lhost/aol.rb +12 -14
- data/lib/sisimai/lhost/apachejames.rb +19 -21
- data/lib/sisimai/lhost/barracuda.rb +10 -12
- data/lib/sisimai/lhost/bigfoot.rb +21 -21
- data/lib/sisimai/lhost/biglobe.rb +15 -16
- data/lib/sisimai/lhost/courier.rb +20 -20
- data/lib/sisimai/lhost/domino.rb +23 -19
- data/lib/sisimai/lhost/einsundeins.rb +23 -18
- data/lib/sisimai/lhost/exchange2003.rb +30 -29
- data/lib/sisimai/lhost/exchange2007.rb +70 -58
- data/lib/sisimai/lhost/exim.rb +175 -161
- data/lib/sisimai/lhost/ezweb.rb +31 -56
- data/lib/sisimai/lhost/facebook.rb +21 -33
- data/lib/sisimai/lhost/fml.rb +43 -48
- data/lib/sisimai/lhost/gmail.rb +29 -29
- data/lib/sisimai/lhost/gmx.rb +18 -17
- data/lib/sisimai/lhost/googlegroups.rb +9 -10
- data/lib/sisimai/lhost/gsuite.rb +21 -27
- data/lib/sisimai/lhost/imailserver.rb +25 -39
- data/lib/sisimai/lhost/interscanmss.rb +28 -31
- data/lib/sisimai/lhost/kddi.rb +22 -28
- data/lib/sisimai/lhost/mailfoundry.rb +11 -12
- data/lib/sisimai/lhost/mailmarshalsmtp.rb +25 -29
- data/lib/sisimai/lhost/mailru.rb +33 -27
- data/lib/sisimai/lhost/mcafee.rb +21 -31
- data/lib/sisimai/lhost/messagelabs.rb +17 -20
- data/lib/sisimai/lhost/messagingserver.rb +40 -37
- data/lib/sisimai/lhost/mfilter.rb +15 -16
- data/lib/sisimai/lhost/mxlogic.rb +24 -23
- data/lib/sisimai/lhost/notes.rb +17 -17
- data/lib/sisimai/lhost/office365.rb +63 -27
- data/lib/sisimai/lhost/opensmtpd.rb +12 -13
- data/lib/sisimai/lhost/outlook.rb +12 -15
- data/lib/sisimai/lhost/postfix.rb +179 -129
- data/lib/sisimai/lhost/powermta.rb +12 -14
- data/lib/sisimai/lhost/qmail.rb +44 -47
- data/lib/sisimai/lhost/receivingses.rb +15 -20
- data/lib/sisimai/lhost/sendgrid.rb +34 -32
- data/lib/sisimai/lhost/sendmail.rb +66 -53
- data/lib/sisimai/lhost/surfcontrol.rb +19 -19
- data/lib/sisimai/lhost/v5sendmail.rb +45 -39
- data/lib/sisimai/lhost/verizon.rb +35 -39
- data/lib/sisimai/lhost/x1.rb +18 -17
- data/lib/sisimai/lhost/x2.rb +17 -14
- data/lib/sisimai/lhost/x3.rb +19 -19
- data/lib/sisimai/lhost/x4.rb +72 -57
- data/lib/sisimai/lhost/x5.rb +17 -19
- data/lib/sisimai/lhost/x6.rb +41 -17
- data/lib/sisimai/lhost/yahoo.rb +17 -16
- data/lib/sisimai/lhost/yandex.rb +16 -20
- data/lib/sisimai/lhost/zoho.rb +16 -15
- data/lib/sisimai/lhost.rb +8 -10
- data/lib/sisimai/mail/maildir.rb +1 -3
- data/lib/sisimai/mail/mbox.rb +3 -4
- data/lib/sisimai/mail/memory.rb +0 -1
- data/lib/sisimai/mail/stdin.rb +1 -3
- data/lib/sisimai/mail.rb +3 -7
- data/lib/sisimai/mda.rb +28 -42
- data/lib/sisimai/message.rb +435 -326
- data/lib/sisimai/order.rb +5 -5
- data/lib/sisimai/reason/authfailure.rb +64 -0
- data/lib/sisimai/reason/badreputation.rb +53 -0
- data/lib/sisimai/reason/blocked.rb +94 -160
- data/lib/sisimai/reason/contenterror.rb +8 -9
- data/lib/sisimai/reason/delivered.rb +4 -6
- data/lib/sisimai/reason/exceedlimit.rb +10 -12
- data/lib/sisimai/reason/expired.rb +6 -8
- data/lib/sisimai/reason/feedback.rb +2 -3
- data/lib/sisimai/reason/filtered.rb +17 -19
- data/lib/sisimai/reason/hasmoved.rb +9 -10
- data/lib/sisimai/reason/hostunknown.rb +15 -15
- data/lib/sisimai/reason/mailboxfull.rb +10 -12
- data/lib/sisimai/reason/mailererror.rb +18 -20
- data/lib/sisimai/reason/mesgtoobig.rb +9 -11
- data/lib/sisimai/reason/networkerror.rb +5 -8
- data/lib/sisimai/reason/norelaying.rb +8 -11
- data/lib/sisimai/reason/notaccept.rb +13 -14
- data/lib/sisimai/reason/notcompliantrfc.rb +43 -0
- data/lib/sisimai/reason/onhold.rb +6 -9
- data/lib/sisimai/reason/policyviolation.rb +14 -12
- data/lib/sisimai/reason/rejected.rb +26 -24
- data/lib/sisimai/reason/requireptr.rb +69 -0
- data/lib/sisimai/reason/securityerror.rb +33 -36
- data/lib/sisimai/reason/spamdetected.rb +114 -147
- data/lib/sisimai/reason/speeding.rb +49 -0
- data/lib/sisimai/reason/suspend.rb +11 -11
- data/lib/sisimai/reason/syntaxerror.rb +11 -10
- data/lib/sisimai/reason/systemerror.rb +7 -9
- data/lib/sisimai/reason/systemfull.rb +7 -8
- data/lib/sisimai/reason/toomanyconn.rb +9 -11
- data/lib/sisimai/reason/undefined.rb +2 -3
- data/lib/sisimai/reason/userunknown.rb +129 -146
- data/lib/sisimai/reason/vacation.rb +3 -4
- data/lib/sisimai/reason/virusdetected.rb +10 -11
- data/lib/sisimai/reason.rb +59 -64
- data/lib/sisimai/rfc1894.rb +55 -28
- data/lib/sisimai/rfc2045.rb +373 -0
- data/lib/sisimai/rfc3464.rb +250 -308
- data/lib/sisimai/rfc3834.rb +42 -45
- data/lib/sisimai/rfc5322.rb +75 -100
- data/lib/sisimai/rfc5965.rb +31 -0
- data/lib/sisimai/rhost/cox.rb +5 -6
- data/lib/sisimai/rhost/franceptt.rb +6 -8
- data/lib/sisimai/rhost/godaddy.rb +12 -12
- data/lib/sisimai/rhost/{googleapps.rb → google.rb} +80 -72
- data/lib/sisimai/rhost/iua.rb +9 -10
- data/lib/sisimai/rhost/kddi.rb +6 -8
- data/lib/sisimai/rhost/{exchangeonline.rb → microsoft.rb} +115 -114
- data/lib/sisimai/rhost/mimecast.rb +42 -40
- data/lib/sisimai/rhost/nttdocomo.rb +12 -12
- data/lib/sisimai/rhost/spectrum.rb +10 -12
- data/lib/sisimai/rhost/{tencentqq.rb → tencent.rb} +7 -8
- data/lib/sisimai/rhost.rb +23 -31
- data/lib/sisimai/smtp/command.rb +59 -0
- data/lib/sisimai/smtp/error.rb +4 -7
- data/lib/sisimai/smtp/reply.rb +161 -74
- data/lib/sisimai/smtp/status.rb +504 -393
- data/lib/sisimai/smtp/transcript.rb +124 -0
- data/lib/sisimai/smtp.rb +0 -1
- data/lib/sisimai/string.rb +74 -5
- data/lib/sisimai/time.rb +1 -2
- data/lib/sisimai/version.rb +1 -1
- data/lib/sisimai.rb +35 -21
- data/set-of-emails/maildir/bsd/lhost-domino-02.eml +6 -3
- data/set-of-emails/maildir/bsd/lhost-googlegroups-15.eml +174 -0
- data/set-of-emails/maildir/bsd/lhost-gsuite-15.eml +229 -0
- data/set-of-emails/maildir/bsd/lhost-postfix-75.eml +51 -0
- data/set-of-emails/maildir/bsd/lhost-postfix-76.eml +101 -0
- data/set-of-emails/maildir/bsd/lhost-postfix-77.eml +74 -0
- data/set-of-emails/maildir/bsd/lhost-postfix-78.eml +91 -0
- data/set-of-emails/maildir/bsd/lhost-receivingses-08.eml +88 -0
- data/set-of-emails/maildir/bsd/rfc3464-43.eml +88 -0
- data/set-of-emails/maildir/bsd/rhost-google-03.eml +101 -0
- data/set-of-emails/maildir/bsd/rhost-google-04.eml +102 -0
- data/set-of-emails/maildir/bsd/rhost-google-05.eml +82 -0
- data/set-of-emails/maildir/bsd/rhost-google-06.eml +102 -0
- data/set-of-emails/maildir/bsd/rhost-google-07.eml +69 -0
- data/set-of-emails/maildir/bsd/rhost-google-08.eml +99 -0
- data/sisimai-java.gemspec +1 -1
- data/sisimai.gemspec +1 -1
- metadata +42 -22
- data/.rspec +0 -2
- data/lib/sisimai/data/yaml.rb +0 -33
- data/lib/sisimai/data.rb +0 -411
- data/lib/sisimai/mime.rb +0 -456
- /data/set-of-emails/maildir/bsd/{rfc3464-41.eml → rfc3834-05.eml} +0 -0
- /data/set-of-emails/maildir/bsd/{rhost-googleapps-01.eml → rhost-google-01.eml} +0 -0
- /data/set-of-emails/maildir/bsd/{rhost-googleapps-02.eml → rhost-google-02.eml} +0 -0
- /data/set-of-emails/maildir/bsd/{rhost-exchangeonline-01.eml → rhost-microsoft-01.eml} +0 -0
- /data/set-of-emails/maildir/bsd/{rhost-exchangeonline-02.eml → rhost-microsoft-02.eml} +0 -0
- /data/set-of-emails/maildir/bsd/{rhost-exchangeonline-03.eml → rhost-microsoft-03.eml} +0 -0
- /data/set-of-emails/maildir/bsd/{rhost-tencentqq-01.eml → rhost-tencent-01.eml} +0 -0
- /data/set-of-emails/maildir/bsd/{rhost-tencentqq-02.eml → rhost-tencent-02.eml} +0 -0
- /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
|
-
|
|
39
|
-
|
|
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
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,36 +12,34 @@ 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
|
|
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-
|
|
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:
|
|
31
29
|
gem install $(DEPENDENCIES)
|
|
32
|
-
if [
|
|
30
|
+
if [ -d "$(JRUBY)" ]; then \
|
|
33
31
|
PATH="$(JRUBY)/bin:$$PATH" $(JRUBY)/bin/gem install $(DEPENDENCIES); \
|
|
34
32
|
fi
|
|
35
33
|
|
|
36
34
|
install-from-rubygems:
|
|
37
35
|
gem install $(NAME)
|
|
38
|
-
if [
|
|
36
|
+
if [ -d "$(JRUBY)" ]; then \
|
|
39
37
|
PATH="$(JRUBY)/bin:$$PATH" $(JRUBY)/bin/gem install $(NAME); \
|
|
40
38
|
fi
|
|
41
39
|
|
|
42
40
|
install-from-local:
|
|
43
41
|
$(RAKE) install
|
|
44
|
-
if [
|
|
42
|
+
if [ -d "$(JRUBY)" ]; then \
|
|
45
43
|
PATH="$(JRUBY)/bin:$$PATH" $(JRUBY)/bin/rake install; \
|
|
46
44
|
fi
|
|
47
45
|
|
|
@@ -57,18 +55,20 @@ release:
|
|
|
57
55
|
PATH="$(JRUBY)/bin:$$PATH" $(JRUBY)/bin/rake release; \
|
|
58
56
|
fi
|
|
59
57
|
|
|
60
|
-
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
|
|
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,12 +1,25 @@
|
|
|
1
1
|

|
|
2
|
-
|
|
3
2
|
[](https://github.com/sisimai/rb-sisimai/blob/master/LICENSE)
|
|
4
3
|
[](https://coveralls.io/r/sisimai/rb-sisimai)
|
|
5
|
-
[](https://www.codacy.com/app/azumakuniyuki/rb-sisimai)
|
|
7
|
-
[](https://www.ruby-lang.org/)
|
|
4
|
+
[](https://www.ruby-lang.org/)
|
|
8
5
|
[](https://badge.fury.io/rb/sisimai)
|
|
9
6
|
|
|
7
|
+
> [!IMPORTANT]
|
|
8
|
+
> **2024年2月2日の時点でこのリポジトリのデフォルトブランチは[5-stable](https://github.com/sisimai/rb-sisimai/tree/5-stable)
|
|
9
|
+
> (Sisimai 5)になりました。** もし古いバージョンを使いたい場合は[4-stable](https://github.com/sisimai/rb-sisimai/tree/4-stable)[^1]
|
|
10
|
+
> ブランチを見てください。また`main`や`master`ブランチはもうこのリポジトリでは使用していません。
|
|
11
|
+
[^1]: 4系を`clone`する場合は`git clone -b 4-stable https://github.com/sisimai/rb-sisimai.git`
|
|
12
|
+
|
|
13
|
+
> [!WARNING]
|
|
14
|
+
> Sisimai 5はRuby 2.4以上が必要です。インストール/アップグレードを実行する前に`ruby -v`コマンドで
|
|
15
|
+
> システムに入っているRubyのバージョンを確認してください。
|
|
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
|
+
|
|
10
23
|
- [**README(English)**](README.md)
|
|
11
24
|
- [シシマイ? | What is Sisimai](#what-is-sisimai)
|
|
12
25
|
- [主な特徴的機能 | Key features](#key-features)
|
|
@@ -36,16 +49,15 @@
|
|
|
36
49
|
- [ライセンス | License](#license)
|
|
37
50
|
|
|
38
51
|
What is Sisimai
|
|
39
|
-
|
|
40
|
-
Sisimai(シシマイ)はRFC5322
|
|
41
|
-
|
|
42
|
-
[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/)
|
|
43
55
|
で公開しているPerl版シシマイから移植しました。
|
|
44
56
|
|
|
45
57
|

|
|
46
58
|
|
|
47
59
|
Key features
|
|
48
|
-
|
|
60
|
+
---------------------------------------------------------------------------------------------------
|
|
49
61
|
* __エラーメールをデータ構造に変換__
|
|
50
62
|
* Rubyのデータ形式(HashとArray)とJSON(String)に対応
|
|
51
63
|
* __インストールも使用も簡単__
|
|
@@ -55,24 +67,23 @@ Key features
|
|
|
55
67
|
* 解析精度はbounceHammerの2倍
|
|
56
68
|
* 68種類のMTA/MDA/ESPに対応
|
|
57
69
|
* Feedback Loopにも対応
|
|
58
|
-
*
|
|
70
|
+
* 32種類のエラー理由を検出
|
|
59
71
|
|
|
60
72
|
Setting Up Sisimai
|
|
61
|
-
|
|
62
|
-
|
|
73
|
+
===================================================================================================
|
|
63
74
|
System requirements
|
|
64
|
-
|
|
65
|
-
Sisimaiの動作環境についての詳細は
|
|
66
|
-
|
|
75
|
+
---------------------------------------------------------------------------------------------------
|
|
76
|
+
Sisimaiの動作環境についての詳細は[Sisimai | シシマイを使ってみる](https://libsisimai.org/ja/start/)
|
|
77
|
+
をご覧ください。
|
|
67
78
|
|
|
68
79
|
|
|
69
|
-
* [Ruby 2.
|
|
80
|
+
* [Ruby 2.4.0 or later](http://www.ruby-lang.org/)
|
|
70
81
|
* [__Oj | The fastest JSON parser and object serializer__](https://rubygems.org/gems/oj)
|
|
71
82
|
* Also works on [JRuby 9.0.4.0 or later](http://jruby.org)
|
|
72
83
|
* [__JrJackson | A mostly native JRuby wrapper for the java jackson json processor jar__](https://rubygems.org/gems/jrjackson)
|
|
73
84
|
|
|
74
85
|
Install
|
|
75
|
-
|
|
86
|
+
---------------------------------------------------------------------------------------------------
|
|
76
87
|
### From RubyGems.org
|
|
77
88
|
|
|
78
89
|
```shell
|
|
@@ -92,7 +103,7 @@ $ cd /usr/local/src
|
|
|
92
103
|
$ git clone https://github.com/sisimai/rb-sisimai.git
|
|
93
104
|
$ cd ./rb-sisimai
|
|
94
105
|
$ sudo make depend install-from-local
|
|
95
|
-
gem install bundle rake
|
|
106
|
+
gem install bundle rake minitest coveralls
|
|
96
107
|
...
|
|
97
108
|
4 gems installed
|
|
98
109
|
bundle exec rake install
|
|
@@ -102,26 +113,29 @@ sisimai (4.25.5) installed.
|
|
|
102
113
|
|
|
103
114
|
Usage
|
|
104
115
|
======
|
|
105
|
-
|
|
106
116
|
Basic usage
|
|
107
|
-
|
|
108
|
-
下記のようにSisimaiの`
|
|
109
|
-
|
|
110
|
-
PATHを保持する`origin`が利用できます。
|
|
117
|
+
---------------------------------------------------------------------------------------------------
|
|
118
|
+
下記のようにSisimaiの`rise()`メソッドをmboxかMaildirのPATHを引数にして実行すると解析結果が配列で
|
|
119
|
+
返ってきます。v4.25.6から元データとなった電子メールファイルへのPATHを保持する`origin`が利用できます。
|
|
111
120
|
|
|
112
121
|
```ruby
|
|
113
122
|
#! /usr/bin/env ruby
|
|
114
123
|
require 'sisimai'
|
|
115
|
-
v = Sisimai.
|
|
124
|
+
v = Sisimai.rise('/path/to/mbox') # or path to Maildir/
|
|
116
125
|
|
|
117
|
-
# Beginning with v4.23.0, both
|
|
118
|
-
#
|
|
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
|
|
119
128
|
f = File.open('/path/to/mbox', 'r'); # or path to Maildir/
|
|
120
|
-
v = Sisimai.
|
|
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)
|
|
121
134
|
|
|
122
|
-
#
|
|
123
|
-
#
|
|
124
|
-
|
|
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);
|
|
125
139
|
|
|
126
140
|
if v.is_a? Array
|
|
127
141
|
v.each do |e|
|
|
@@ -136,6 +150,7 @@ if v.is_a? Array
|
|
|
136
150
|
puts e.replycode # 550
|
|
137
151
|
puts e.reason # userunknown
|
|
138
152
|
puts e.origin # /var/spool/bounce/Maildir/new/1740074341.eml
|
|
153
|
+
puts e.hardbounce # true
|
|
139
154
|
|
|
140
155
|
h = e.damn # Convert to HASH
|
|
141
156
|
j = e.dump('json') # Convert to JSON string
|
|
@@ -145,9 +160,9 @@ end
|
|
|
145
160
|
```
|
|
146
161
|
|
|
147
162
|
Convert to JSON
|
|
148
|
-
|
|
149
|
-
下記のようにSisimaiの`dump()`メソッドをmboxかMaildirのPATH
|
|
150
|
-
|
|
163
|
+
---------------------------------------------------------------------------------------------------
|
|
164
|
+
下記のようにSisimaiの`dump()`メソッドをmboxかMaildirのPATHを引数にして実行すると解析結果が文字列(JSON)
|
|
165
|
+
で返ってきます。
|
|
151
166
|
|
|
152
167
|
```ruby
|
|
153
168
|
# Get JSON string from parsed mailbox or Maildir/
|
|
@@ -158,70 +173,119 @@ puts Sisimai.dump('/path/to/mbox', delivered: true)
|
|
|
158
173
|
```
|
|
159
174
|
|
|
160
175
|
Callback feature
|
|
161
|
-
|
|
162
|
-
Sisimai
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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()`で呼び出されます。
|
|
166
185
|
|
|
167
186
|
```ruby
|
|
168
187
|
#! /usr/bin/env ruby
|
|
169
188
|
require 'sisimai'
|
|
170
|
-
|
|
171
|
-
|
|
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' => '' }
|
|
172
193
|
|
|
173
|
-
if cv =
|
|
174
|
-
|
|
194
|
+
if cv = body.match(/^X-Postfix-Queue-ID:\s*(.+)$/)
|
|
195
|
+
adds['queue-id'] = cv[1]
|
|
175
196
|
end
|
|
176
|
-
r['x-mailer'] =
|
|
177
|
-
return
|
|
197
|
+
r['x-mailer'] = head['x-mailer'] || ''
|
|
198
|
+
return adds
|
|
178
199
|
end
|
|
179
200
|
|
|
180
|
-
data = Sisimai.
|
|
181
|
-
json = Sisimai.dump('/path/to/mbox',
|
|
201
|
+
data = Sisimai.rise('/path/to/mbox', c___: [code, nil])
|
|
202
|
+
json = Sisimai.dump('/path/to/mbox', c___: [code, nil])
|
|
182
203
|
|
|
183
|
-
puts data[0].catch['x-mailer']
|
|
204
|
+
puts data[0].catch['x-mailer'] # "Apple Mail (2.1283)"
|
|
205
|
+
puts data[0].catch['queue-id'] # "43f4KX6WR7z1xcMG"
|
|
184
206
|
```
|
|
185
207
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
208
|
+
### 各メールのファイルに対して
|
|
209
|
+
`Sisimai->rise()`と`Sisimai->dump()`の両メソッドに渡せる引数`c___`(配列リファレンス)の2番目に入れた
|
|
210
|
+
コードリファレンスは解析したメールのファイルごとに呼び出されます。
|
|
189
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
|
|
190
246
|
|
|
191
|
-
|
|
192
|
-
|
|
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
|
+
```
|
|
193
253
|
|
|
254
|
+
コールバック機能のより詳細な使い方は
|
|
255
|
+
[Sisimai | 解析方法 - コールバック機能](https://libsisimai.org/ja/usage/#callback)をご覧ください。
|
|
256
|
+
|
|
257
|
+
One-Liner
|
|
258
|
+
---------------------------------------------------------------------------------------------------
|
|
194
259
|
```shell
|
|
195
260
|
$ ruby -rsisimai -e 'puts Sisimai.dump($*.shift)' /path/to/mbox
|
|
196
261
|
```
|
|
197
262
|
|
|
198
263
|
Output example
|
|
199
|
-
|
|
264
|
+
---------------------------------------------------------------------------------------------------
|
|
200
265
|

|
|
201
266
|
|
|
202
267
|
```json
|
|
203
|
-
[{"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","
|
|
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}]
|
|
204
269
|
```
|
|
205
270
|
|
|
206
271
|
Sisimai Specification
|
|
207
|
-
|
|
208
|
-
|
|
272
|
+
===================================================================================================
|
|
209
273
|
Differences between Ruby version and Perl version
|
|
210
|
-
|
|
211
|
-
公開中のPerl版Sisimai(p5-sisimai)とRuby版Sisimai(rb-sisimai)
|
|
212
|
-
|
|
213
|
-
|
|
274
|
+
---------------------------------------------------------------------------------------------------
|
|
275
|
+
公開中のPerl版Sisimai(p5-sisimai)とRuby版Sisimai(rb-sisimai)は下記のような違いがあります。bounceHammer
|
|
276
|
+
2.7.13p3とSisimai(シシマイ)の違いについては[Sisimai | 違いの一覧](https://libsisimai.org/ja/diff/)を
|
|
277
|
+
ご覧ください。
|
|
214
278
|
|
|
215
279
|
| 機能 | Ruby version | Perl version |
|
|
216
280
|
|---------------------------------------------|----------------|---------------|
|
|
217
|
-
| 動作環境 | Ruby 2.
|
|
281
|
+
| 動作環境 | Ruby 2.4 - 2.7 | Perl 5.10 - |
|
|
218
282
|
| | JRuby 9.0.4.0- | |
|
|
219
283
|
| 解析精度の割合(2000通のメール)[1] | 1.00 | 1.00 |
|
|
220
284
|
| メール解析速度(1000通のメール) | 2.22秒[2] | 1.35秒 |
|
|
221
285
|
| インストール方法 | gem install | cpanm, cpm |
|
|
222
286
|
| 依存モジュール数(コアモジュールを除く) | 1モジュール | 2モジュール |
|
|
223
|
-
| LOC:ソースコードの行数 |
|
|
224
|
-
| テスト件数(spec/,t/,xt/ディレクトリ) |
|
|
287
|
+
| LOC:ソースコードの行数 | 10300行 | 10500行 |
|
|
288
|
+
| テスト件数(spec/,t/,xt/ディレクトリ) | 453000件 | 311000件 |
|
|
225
289
|
| ライセンス | 二条項BSD | 二条項BSD |
|
|
226
290
|
| 開発会社によるサポート契約 | 提供中 | 提供中 |
|
|
227
291
|
|
|
@@ -229,29 +293,27 @@ Differences between Ruby version and Perl version
|
|
|
229
293
|
2. Xeon E5-2640 2.5GHz x 2 cores | 5000 bogomips | 1GB RAM | Ruby 2.3.4p301
|
|
230
294
|
|
|
231
295
|
Other spec of Sisimai
|
|
232
|
-
|
|
296
|
+
---------------------------------------------------------------------------------------------------
|
|
233
297
|
- [**解析モジュールの一覧**](https://libsisimai.org/ja/engine/)
|
|
234
298
|
- [**バウンス理由の一覧**](https://libsisimai.org/ja/reason/)
|
|
235
299
|
- [**Sisimai::Dataのデータ構造**](https://libsisimai.org/ja/data/)
|
|
236
300
|
|
|
237
301
|
Contributing
|
|
238
|
-
|
|
239
|
-
|
|
302
|
+
===================================================================================================
|
|
240
303
|
Bug report
|
|
241
|
-
|
|
242
|
-
もしもSisimaiにバグを発見した場合は[Issues](https://github.com/sisimai/rb-sisimai/issues)
|
|
243
|
-
|
|
304
|
+
---------------------------------------------------------------------------------------------------
|
|
305
|
+
もしもSisimaiにバグを発見した場合は[Issues](https://github.com/sisimai/rb-sisimai/issues)にて連絡を
|
|
306
|
+
いただけると助かります。
|
|
244
307
|
|
|
245
308
|
Emails could not be parsed
|
|
246
|
-
|
|
309
|
+
---------------------------------------------------------------------------------------------------
|
|
247
310
|
Sisimaiで解析できないバウンスメールは
|
|
248
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を送ってください。
|
|
249
312
|
|
|
250
313
|
Other Information
|
|
251
|
-
|
|
252
|
-
|
|
314
|
+
===================================================================================================
|
|
253
315
|
Related sites
|
|
254
|
-
|
|
316
|
+
---------------------------------------------------------------------------------------------------
|
|
255
317
|
* __@libsisimai__ | [Sisimai on Twitter (@libsisimai)](https://twitter.com/libsisimai)
|
|
256
318
|
* __libSISIMAI.ORG__ | [Sisimai | The successor to bounceHammer, Library to parse bounce mails](https://libsisimai.org/)
|
|
257
319
|
* __Sisimai Blog__ | [blog.libsisimai.org](http://blog.libsisimai.org/)
|
|
@@ -262,7 +324,7 @@ Related sites
|
|
|
262
324
|
* __Fixtures__ | [set-of-emails - Sample emails for "make test"](https://github.com/sisimai/set-of-emails)
|
|
263
325
|
|
|
264
326
|
See also
|
|
265
|
-
|
|
327
|
+
---------------------------------------------------------------------------------------------------
|
|
266
328
|
* [README.md - README.md in English](https://github.com/sisimai/rb-sisimai/blob/master/README.md)
|
|
267
329
|
* [RFC3463 - Enhanced Mail System Status Codes](https://tools.ietf.org/html/rfc3463)
|
|
268
330
|
* [RFC3464 - An Extensible Message Format for Delivery Status Notifications](https://tools.ietf.org/html/rfc3464)
|
|
@@ -271,14 +333,14 @@ See also
|
|
|
271
333
|
* [RFC5322 - Internet Message Format](https://tools.ietf.org/html/rfc5322)
|
|
272
334
|
|
|
273
335
|
Author
|
|
274
|
-
|
|
336
|
+
===================================================================================================
|
|
275
337
|
[@azumakuniyuki](https://twitter.com/azumakuniyuki)
|
|
276
338
|
|
|
277
339
|
Copyright
|
|
278
|
-
|
|
279
|
-
Copyright (C) 2015-
|
|
340
|
+
===================================================================================================
|
|
341
|
+
Copyright (C) 2015-2023 azumakuniyuki, All Rights Reserved.
|
|
280
342
|
|
|
281
343
|
License
|
|
282
|
-
|
|
344
|
+
===================================================================================================
|
|
283
345
|
This software is distributed under The BSD 2-Clause License.
|
|
284
346
|
|