sisimai 4.14.2 → 4.15.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sisimai might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.rubocop.yml +19 -2
- data/.travis.yml +0 -1
- data/Changes +16 -0
- data/README.md +69 -17
- data/appveyor.yml +23 -0
- data/lib/sisimai.rb +9 -7
- data/lib/sisimai/address.rb +8 -2
- data/lib/sisimai/arf.rb +1 -6
- data/lib/sisimai/data.rb +35 -47
- data/lib/sisimai/data/json.rb +16 -12
- data/lib/sisimai/datetime.rb +1 -8
- data/lib/sisimai/mail/maildir.rb +0 -3
- data/lib/sisimai/mail/mbox.rb +1 -1
- data/lib/sisimai/mail/stdin.rb +2 -1
- data/lib/sisimai/message.rb +46 -31
- data/lib/sisimai/mime.rb +2 -2
- data/lib/sisimai/msp.rb +3 -3
- data/lib/sisimai/msp/de/einsundeins.rb +1 -1
- data/lib/sisimai/msp/de/gmx.rb +1 -1
- data/lib/sisimai/msp/jp/biglobe.rb +2 -2
- data/lib/sisimai/msp/jp/ezweb.rb +10 -10
- data/lib/sisimai/msp/jp/kddi.rb +1 -1
- data/lib/sisimai/msp/ru/yandex.rb +1 -1
- data/lib/sisimai/msp/uk/messagelabs.rb +1 -1
- data/lib/sisimai/msp/us/amazonses.rb +1 -1
- data/lib/sisimai/msp/us/amazonworkmail.rb +224 -0
- data/lib/sisimai/msp/us/aol.rb +1 -1
- data/lib/sisimai/msp/us/bigfoot.rb +1 -1
- data/lib/sisimai/msp/us/facebook.rb +1 -1
- data/lib/sisimai/msp/us/google.rb +1 -1
- data/lib/sisimai/msp/us/office365.rb +273 -0
- data/lib/sisimai/msp/us/outlook.rb +2 -3
- data/lib/sisimai/msp/us/receivingses.rb +1 -1
- data/lib/sisimai/msp/us/sendgrid.rb +2 -2
- data/lib/sisimai/msp/us/verizon.rb +7 -7
- data/lib/sisimai/msp/us/yahoo.rb +1 -1
- data/lib/sisimai/msp/us/zoho.rb +1 -1
- data/lib/sisimai/mta.rb +8 -9
- data/lib/sisimai/mta/activehunter.rb +1 -1
- data/lib/sisimai/mta/apachejames.rb +1 -1
- data/lib/sisimai/mta/courier.rb +1 -1
- data/lib/sisimai/mta/domino.rb +1 -1
- data/lib/sisimai/mta/exchange.rb +15 -15
- data/lib/sisimai/mta/imailserver.rb +1 -1
- data/lib/sisimai/mta/interscanmss.rb +1 -1
- data/lib/sisimai/mta/mailfoundry.rb +1 -1
- data/lib/sisimai/mta/mailmarshalsmtp.rb +1 -1
- data/lib/sisimai/mta/mcafee.rb +1 -1
- data/lib/sisimai/mta/messagingserver.rb +1 -1
- data/lib/sisimai/mta/mxlogic.rb +2 -2
- data/lib/sisimai/mta/notes.rb +1 -1
- data/lib/sisimai/mta/opensmtpd.rb +1 -1
- data/lib/sisimai/mta/postfix.rb +2 -2
- data/lib/sisimai/mta/qmail.rb +1 -1
- data/lib/sisimai/mta/sendmail.rb +2 -2
- data/lib/sisimai/mta/surfcontrol.rb +1 -1
- data/lib/sisimai/mta/v5sendmail.rb +1 -1
- data/lib/sisimai/mta/x1.rb +1 -1
- data/lib/sisimai/mta/x2.rb +1 -1
- data/lib/sisimai/mta/x3.rb +1 -1
- data/lib/sisimai/mta/x4.rb +1 -1
- data/lib/sisimai/mta/x5.rb +1 -1
- data/lib/sisimai/order.rb +4 -1
- data/lib/sisimai/reason.rb +15 -18
- data/lib/sisimai/reason/hostunknown.rb +5 -0
- data/lib/sisimai/reason/mesgtoobig.rb +5 -0
- data/lib/sisimai/reason/userunknown.rb +1 -1
- data/lib/sisimai/rfc3464.rb +3 -3
- data/lib/sisimai/rfc3834.rb +1 -1
- data/lib/sisimai/time.rb +1 -1
- data/lib/sisimai/version.rb +1 -1
- data/set-of-emails/maildir/bsd/us-amazonworkmail-01.eml +156 -0
- data/set-of-emails/maildir/bsd/us-amazonworkmail-02.eml +160 -0
- data/set-of-emails/maildir/bsd/us-amazonworkmail-03.eml +161 -0
- data/set-of-emails/maildir/bsd/us-amazonworkmail-04.eml +156 -0
- data/set-of-emails/maildir/bsd/us-amazonworkmail-05.eml +157 -0
- data/set-of-emails/maildir/bsd/us-office365-01.eml +102 -0
- data/sisimai.gemspec +7 -0
- metadata +26 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ec1fa777a75634e47ecb872e204b2a984bc5e7f
|
4
|
+
data.tar.gz: fe7c0c885e57e2ce3f1d71097bc3aea0f9172f09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 626b2742d7733d7345aa8aa4fc9ab06e3966854cf1a1bd778bce4c8603f14173167ec610997c2561dbd80010b4534e1c099c607f57dddb03e0c751bbfbe66bda
|
7
|
+
data.tar.gz: 93e4f36be4ee5787f0f2172fed282cde3e239e4190b65ea4ee32a19c77f92d00f1762a67a761cc772fb6627984e4a5cff27b9530fc8385bbad30a8357f3df0ff
|
data/.rubocop.yml
CHANGED
@@ -12,6 +12,9 @@ AllCops:
|
|
12
12
|
Lint/AssignmentInCondition:
|
13
13
|
Enabled: false
|
14
14
|
|
15
|
+
Metrics/AbcSize:
|
16
|
+
Max: 30
|
17
|
+
|
15
18
|
Metrics/CyclomaticComplexity:
|
16
19
|
Enabled: false
|
17
20
|
|
@@ -32,9 +35,20 @@ Metrics/ModuleLength:
|
|
32
35
|
Metrics/PerceivedComplexity:
|
33
36
|
Enabled: false
|
34
37
|
|
38
|
+
Style/AsciiComments:
|
39
|
+
Exclude:
|
40
|
+
- 'lib/sisimai/mta/*.rb'
|
41
|
+
- 'lib/sisimai/msp/ru/*.rb'
|
42
|
+
|
35
43
|
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
36
44
|
Style/ClassAndModuleChildren:
|
37
|
-
|
45
|
+
EnforcedStyle: nested
|
46
|
+
Exclude:
|
47
|
+
- 'lib/sisimai/datetime.rb'
|
48
|
+
- 'lib/sisimai/rfc5322.rb'
|
49
|
+
- 'lib/sisimai/rhost.rb'
|
50
|
+
- 'lib/sisimai/string.rb'
|
51
|
+
- 'lib/sisimai/msp/*/*.rb'
|
38
52
|
|
39
53
|
Style/ClassVars:
|
40
54
|
Enabled: false
|
@@ -87,6 +101,9 @@ Style/FileName:
|
|
87
101
|
Style/FormatString:
|
88
102
|
EnforcedStyle: sprintf
|
89
103
|
|
104
|
+
Style/HashSyntax:
|
105
|
+
Enabled: false
|
106
|
+
|
90
107
|
# Cop supports --auto-correct.
|
91
108
|
Style/LeadingCommentSpace:
|
92
109
|
Enabled: false
|
@@ -134,7 +151,7 @@ Style/SingleLineMethods:
|
|
134
151
|
- 'lib/sisimai/msp.rb'
|
135
152
|
- 'lib/sisimai/mta/*'
|
136
153
|
- 'lib/sisimai/msp/*/*'
|
137
|
-
- 'lib/sisimai/
|
154
|
+
- 'lib/sisimai/rfc3464.rb'
|
138
155
|
- 'lib/sisimai/rfc3834.rb'
|
139
156
|
- 'lib/sisimai/reason/*.rb'
|
140
157
|
|
data/.travis.yml
CHANGED
data/Changes
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
Revision history for Ruby version of Sisimai
|
2
2
|
|
3
|
+
4.15.0 Sat, 13 Feb 2016 12:40:15 +0900 (JST)
|
4
|
+
- Beginning with this version, Sisimai requires Oj(MRI) or JrJackson(JRuby)
|
5
|
+
for encoding parsed data to JSON string more faster (about 10%-20% faster
|
6
|
+
than before). Implemented at pull-request #44 and discussed in issue #42.
|
7
|
+
Thanks to @hiroyuki-sato.
|
8
|
+
- Implement new MTA/MSP module "Sisimai::MSP::US::AmazonWorkMail" to parse
|
9
|
+
bounce mails via Amazon WorkMail. The module and test codes are imported
|
10
|
+
from https://github.com/sisimai/p5-Sisimai/pull/162.
|
11
|
+
- Implement new MTA/MSP module "Sisimai::MSP::US::Office365" to parse error
|
12
|
+
mails via Microsoft Office 365. The module, test codes, and sample emails
|
13
|
+
are imported from https://github.com/sisimai/p5-Sisimai/pull/164.
|
14
|
+
- New method Sisimai::Address#to_s to get a email address as String, it is
|
15
|
+
implemented at pull-request #39. Thanks to @hiroyuki-sato.
|
16
|
+
- Almost all of the class variables are removed for resolving issue #40 and
|
17
|
+
merged pull-request #43, thanks to @hiroyuki-sato.
|
18
|
+
|
3
19
|
4.14.2 Wed, 3 Feb 2016 13:29:17 +0900 (JST)
|
4
20
|
- The first release of rb-Sisimai.
|
5
21
|
|
data/README.md
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
[![Build Status](https://travis-ci.org/sisimai/rb-Sisimai.svg?branch=master)](https://travis-ci.org/sisimai/rb-Sisimai)
|
4
4
|
[![Codacy Badge](https://api.codacy.com/project/badge/grade/38340177e6284a65be69c0c7c3dc2b58)](https://www.codacy.com/app/azumakuniyuki/rb-Sisimai)
|
5
5
|
[![Ruby](https://img.shields.io/badge/ruby-v2.1.0--v2.3.0-red.svg)](https://www.ruby-lang.org/)
|
6
|
+
[![Gem Version](https://badge.fury.io/rb/sisimai.svg)](https://badge.fury.io/rb/sisimai)
|
6
7
|
|
7
8
|
![](http://41.media.tumblr.com/45c8d33bea2f92da707f4bbe66251d6b/tumblr_nuf7bgeyH51uz9e9oo1_1280.png)
|
8
9
|
|
@@ -23,7 +24,12 @@ Key Features | 主な特徴的機能
|
|
23
24
|
* __Easy to Install, Use.__ | __インストールも使用も簡単__
|
24
25
|
* gem install
|
25
26
|
* git clone & make
|
26
|
-
|
27
|
+
* __High Precision of Analysis__ | __高い解析精度__
|
28
|
+
* 2 times higher than bounceHammer | 解析精度はbounceHammerの二倍
|
29
|
+
* Support 21 known MTAs and 5 unknown MTAs | 26種類のMTAに対応
|
30
|
+
* Support 21 major MSPs(Mail Service Providers) | 21種類の著名なMSPに対応
|
31
|
+
* Support Feedback Loop Message(ARF) | Feedback Loopにも対応
|
32
|
+
* Can detect 25 error reasons | 25種類のエラー理由を検出
|
27
33
|
|
28
34
|
Setting Up Sisimai | シシマイを使う準備
|
29
35
|
=======================================
|
@@ -35,8 +41,50 @@ More details about system requirements are available at available at
|
|
35
41
|
[Sisimai | Getting Started](http://libsisimai.org/start) page.
|
36
42
|
|
37
43
|
* [Ruby 2.1.0 or later](http://www.ruby-lang.org/)
|
38
|
-
*
|
44
|
+
* [__Oj | The fastest JSON parser and object serializer__](https://rubygems.org/gems/oj)
|
45
|
+
* Also works on [JRuby 9.0.0.0 or later](http://jruby.org)
|
46
|
+
* [__JrJackson | A mostly native JRuby wrapper for the java jackson json processor jar__](https://rubygems.org/gems/jrjackson)
|
47
|
+
|
48
|
+
Install | インストール
|
49
|
+
----------------------
|
50
|
+
|
51
|
+
### From RubyGems.org
|
52
|
+
|
53
|
+
```shell
|
54
|
+
% sudo gem install sisimai
|
55
|
+
Fetching: sisimai-4.14.2.gem (100%)
|
56
|
+
Successfully installed sisimai-4.14.2
|
57
|
+
Parsing documentation for sisimai-4.14.2
|
58
|
+
Installing ri documentation for sisimai-4.14.2
|
59
|
+
Done installing documentation for sisimai after 6 seconds
|
60
|
+
1 gem installed
|
61
|
+
```
|
39
62
|
|
63
|
+
### From GitHub
|
64
|
+
|
65
|
+
```shell
|
66
|
+
% cd /usr/local/src
|
67
|
+
% git clone https://github.com/sisimai/rb-Sisimai.git
|
68
|
+
% cd ./rb-Sisimai
|
69
|
+
% sudo make depend install-from-local
|
70
|
+
gem install bundle rake rspec coveralls
|
71
|
+
Successfully installed bundle-0.0.1
|
72
|
+
Parsing documentation for bundle-0.0.1
|
73
|
+
Done installing documentation for bundle after 0 seconds
|
74
|
+
Successfully installed rake-10.5.0
|
75
|
+
Parsing documentation for rake-10.5.0
|
76
|
+
Done installing documentation for rake after 1 seconds
|
77
|
+
Successfully installed rspec-3.4.0
|
78
|
+
Parsing documentation for rspec-3.4.0
|
79
|
+
Done installing documentation for rspec after 0 seconds
|
80
|
+
Successfully installed coveralls-0.8.10
|
81
|
+
Parsing documentation for coveralls-0.8.10
|
82
|
+
Done installing documentation for coveralls after 0 seconds
|
83
|
+
4 gems installed
|
84
|
+
bundle exec rake install
|
85
|
+
sisimai 4.14.2 built to pkg/sisimai-4.14.2.gem.
|
86
|
+
sisimai (4.14.2) installed.
|
87
|
+
```
|
40
88
|
|
41
89
|
Usage | 使い方
|
42
90
|
==============
|
@@ -93,17 +141,18 @@ Differences between Perl version and Ruby version | Perl版との違い
|
|
93
141
|
The following table show the differences between Perl version of Sisimai
|
94
142
|
and Ruby version of Sisimai.
|
95
143
|
|
96
|
-
| Features | Ruby version | Perl version|
|
97
|
-
|
98
|
-
| System requirements | Ruby 2.1-2.3 | Perl 5.10 -
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
144
|
+
| Features | Ruby version | Perl version |
|
145
|
+
|------------------------------------------------|---------------|--------------|
|
146
|
+
| System requirements | Ruby 2.1-2.3 | Perl 5.10 - |
|
147
|
+
| | JRuby 9.0.0.0-| |
|
148
|
+
| Analytical precision ratio(2000 emails)[1] | 1.00 | 1.00 |
|
149
|
+
| The speed of parsing email(1000 emails) | 3.81s | 2.50s |
|
150
|
+
| How to install | gem install | cpanm |
|
151
|
+
| Dependencies (Except core modules) | 1 modules | 2 modules |
|
152
|
+
| LOC:Source lines of code | 11700 lines | 9100 lines |
|
153
|
+
| The number of tests in t/, xt/ directory | 90700 tests | 162400 tests |
|
154
|
+
| License | BSD 2-Clause | BSD 2-Clause |
|
155
|
+
| Support Contract provided by Developer | Coming soon | Available |
|
107
156
|
|
108
157
|
1. See ./ANALYTICAL-PRECISION
|
109
158
|
|
@@ -113,12 +162,13 @@ and Ruby version of Sisimai.
|
|
113
162
|
| 機能 | Ruby version | Perl version|
|
114
163
|
|------------------------------------------------|---------------|-------------|
|
115
164
|
| 動作環境 | Ruby 2.1-2.3 | Perl 5.10 - |
|
165
|
+
| | JRuby 9.0.0.0-| |
|
116
166
|
| 解析精度の割合(2000通のメール)[1] | 1.00 | 1.00 |
|
117
|
-
| メール解析速度(1000通のメール) | 3.
|
167
|
+
| メール解析速度(1000通のメール) | 3.81秒 | 2.50秒 |
|
118
168
|
| インストール方法 | gem install | cpanm |
|
119
|
-
| 依存モジュール数(コアモジュールを除く) |
|
120
|
-
| LOC:ソースコードの行数 |
|
121
|
-
| テスト件数(t/,xt/ディレクトリ) |
|
169
|
+
| 依存モジュール数(コアモジュールを除く) | 1モジュール | 2モジュール |
|
170
|
+
| LOC:ソースコードの行数 | 11700行 | 9100行 |
|
171
|
+
| テスト件数(t/,xt/ディレクトリ) | 90700件 | 162400件 |
|
122
172
|
| ライセンス | 二条項BSD | 二条項BSD |
|
123
173
|
| 開発会社によるサポート契約 | 準備中 | 提供中 |
|
124
174
|
|
@@ -167,10 +217,12 @@ details about these modules are available at
|
|
167
217
|
| MSP::RU::Yandex | Yandex.Mail: http://www.yandex.ru |
|
168
218
|
| MSP::UK::MessageLabs | Symantec.cloud http://www.messagelabs.com |
|
169
219
|
| MSP::US::AmazonSES | AmazonSES(Sending): http://aws.amazon.com/ses/ |
|
220
|
+
| MSP::US::AmazonWorkMail | Amazon WorkMail: https://aws.amazon.com/workmail/ |
|
170
221
|
| MSP::US::Aol | Aol Mail: http://www.aol.com |
|
171
222
|
| MSP::US::Bigfoot | Bigfoot: http://www.bigfoot.com |
|
172
223
|
| MSP::US::Facebook | Facebook: https://www.facebook.com |
|
173
224
|
| MSP::US::Google | Google Gmail: https://mail.google.com |
|
225
|
+
| MSP::US::Office365 | Microsoft Office 365: http://office.microsoft.com/|
|
174
226
|
| MSP::US::Outlook | Microsoft Outlook.com: https://www.outlook.com/ |
|
175
227
|
| MSP::US::ReceivingSES | AmazonSES(Receiving): http://aws.amazon.com/ses/ |
|
176
228
|
| MSP::US::SendGrid | SendGrid: http://sendgrid.com/ |
|
data/appveyor.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
version: '{build}'
|
2
|
+
|
3
|
+
install:
|
4
|
+
- SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
|
5
|
+
- "%devkit%\\devkitvars.bat"
|
6
|
+
- ruby --version
|
7
|
+
- gem --version
|
8
|
+
- bundle install
|
9
|
+
build: off
|
10
|
+
test_script:
|
11
|
+
- bundle exec rake spec TESTOPTS=-v
|
12
|
+
|
13
|
+
environment:
|
14
|
+
matrix:
|
15
|
+
- ruby_version: "22-x64"
|
16
|
+
devkit: C:\Ruby21-x64\DevKit
|
17
|
+
- ruby_version: "22"
|
18
|
+
devkit: C:\Ruby21\DevKit
|
19
|
+
- ruby_version: "21-x64"
|
20
|
+
devkit: C:\Ruby21-x64\DevKit
|
21
|
+
- ruby_version: "21"
|
22
|
+
devkit: C:\Ruby21\DevKit
|
23
|
+
|
data/lib/sisimai.rb
CHANGED
@@ -46,14 +46,16 @@ module Sisimai
|
|
46
46
|
def dump(path)
|
47
47
|
return nil unless path
|
48
48
|
|
49
|
-
require 'json'
|
50
49
|
parseddata = Sisimai.make(path) || []
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
50
|
+
if RUBY_PLATFORM =~ /java/
|
51
|
+
# java-based ruby environment like JRuby.
|
52
|
+
require 'jrjackson'
|
53
|
+
jsonstring = JrJackson::Json.dump(parseddata)
|
54
|
+
else
|
55
|
+
require 'oj'
|
56
|
+
jsonstring = Oj.dump(parseddata, :mode => :compat)
|
57
|
+
end
|
58
|
+
return jsonstring
|
57
59
|
end
|
58
60
|
end
|
59
61
|
|
data/lib/sisimai/address.rb
CHANGED
@@ -10,7 +10,7 @@ module Sisimai
|
|
10
10
|
# Undef when the $argv1 is neither 'r' nor 's'
|
11
11
|
def self.undisclosed(argv1)
|
12
12
|
return nil unless argv1
|
13
|
-
return nil unless
|
13
|
+
return nil unless %w|r s|.index(argv1)
|
14
14
|
|
15
15
|
local = argv1 == 'r' ? 'recipient' : 'sender'
|
16
16
|
return sprintf('undisclosed-%s-in-headers@dummy-domain.invalid', local)
|
@@ -210,7 +210,13 @@ module Sisimai
|
|
210
210
|
|
211
211
|
# Returns the value of address as String
|
212
212
|
# @return [String] Email address
|
213
|
-
def to_json
|
213
|
+
def to_json(*)
|
214
|
+
return to_s
|
215
|
+
end
|
216
|
+
|
217
|
+
# Returns the value of address as String
|
218
|
+
# @return [String] Email address
|
219
|
+
def to_s
|
214
220
|
return self.address.to_s
|
215
221
|
end
|
216
222
|
|
data/lib/sisimai/arf.rb
CHANGED
@@ -88,8 +88,6 @@ module Sisimai
|
|
88
88
|
require 'sisimai/address'
|
89
89
|
dscontents = []; dscontents << Sisimai::MTA.DELIVERYSTATUS
|
90
90
|
hasdivided = mbody.split("\n")
|
91
|
-
havepassed = ['']
|
92
|
-
rfc822next = { 'from' => false, 'to' => false, 'subject' => false }
|
93
91
|
rfc822part = '' # (String) message/rfc822-headers part
|
94
92
|
previousfn = '' # (String) Previous field name
|
95
93
|
readcursor = 0 # (Integer) Points the current cursor position
|
@@ -130,9 +128,6 @@ module Sisimai
|
|
130
128
|
# this specification is set to "1".
|
131
129
|
#
|
132
130
|
hasdivided.each do |e|
|
133
|
-
# Save the current line for the next loop
|
134
|
-
havepassed << e; p = havepassed[-2]
|
135
|
-
|
136
131
|
if readcursor == 0
|
137
132
|
# Beginning of the bounce message or delivery status part
|
138
133
|
if e =~ Re1[:begin]
|
@@ -323,7 +318,7 @@ module Sisimai
|
|
323
318
|
if mhead['received'].size > 0
|
324
319
|
# Get localhost and remote host name from Received header.
|
325
320
|
r0 = mhead['received']
|
326
|
-
|
321
|
+
%w|lhost rhost|.each { |a| e[a] ||= '' }
|
327
322
|
e['lhost'] = Sisimai::RFC5322.received(r0[0]).shift if e['lhost'].empty?
|
328
323
|
e['rhost'] = Sisimai::RFC5322.received(r0[-1]).pop if e['rhost'].empty?
|
329
324
|
end
|
data/lib/sisimai/data.rb
CHANGED
@@ -13,29 +13,29 @@ module Sisimai
|
|
13
13
|
require 'sisimai/datetime'
|
14
14
|
|
15
15
|
@@rwaccessors = [
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
16
|
+
:token, # [String] Message token/MD5 Hex digest value
|
17
|
+
:lhost, # [String] local host name/Local MTA
|
18
|
+
:rhost, # [String] Remote host name/Remote MTA
|
19
|
+
:alias, # [String] Alias of the recipient address
|
20
|
+
:listid, # [String] List-Id header of each ML
|
21
|
+
:reason, # [String] Bounce reason
|
22
|
+
:action, # [String] The value of Action: header
|
23
|
+
:subject, # [String] UTF-8 Subject text
|
24
|
+
:timestamp, # [Sisimai::Time] Date: header in the original message
|
25
|
+
:addresser, # [Sisimai::Address] From address
|
26
|
+
:recipient, # [Sisimai::Address] Recipient address which bounced
|
27
|
+
:messageid, # [String] Message-Id: header
|
28
|
+
:replycode, # [String] SMTP Reply Code
|
29
|
+
:smtpagent, # [String] MTA name
|
30
|
+
:softbounce, # [Integer] 1 = Soft bounce, 0 = Hard bounce, -1 = ?
|
31
|
+
:smtpcommand, # [String] The last SMTP command
|
32
|
+
:destination, # [String] The domain part of the "recipinet"
|
33
|
+
:senderdomain, # [String] The domain part of the "addresser"
|
34
|
+
:feedbacktype, # [String] Feedback Type
|
35
|
+
:diagnosticcode, # [String] Diagnostic-Code: Header
|
36
|
+
:diagnostictype, # [String] The 1st part of Diagnostic-Code: Header
|
37
|
+
:deliverystatus, # [String] Delivery Status(DSN)
|
38
|
+
:timezoneoffset, # [Integer] Time zone offset(seconds)
|
39
39
|
]
|
40
40
|
@@rwaccessors.each { |e| attr_accessor e }
|
41
41
|
|
@@ -236,7 +236,7 @@ module Sisimai
|
|
236
236
|
# Convert from the date string to an object then calculate time
|
237
237
|
# zone offset.
|
238
238
|
t = Sisimai::Time.strptime(datestring, '%a, %d %b %Y %T')
|
239
|
-
p['timestamp'] = (
|
239
|
+
p['timestamp'] = (t.to_time.to_i - zoneoffset) || nil
|
240
240
|
rescue
|
241
241
|
warn ' ***warning: Failed to strptime ' + datestring.to_s
|
242
242
|
end
|
@@ -244,7 +244,7 @@ module Sisimai
|
|
244
244
|
|
245
245
|
# OTHER_TEXT_HEADERS:
|
246
246
|
# Remove square brackets and curly brackets from the host variable
|
247
|
-
|
247
|
+
%w|rhost lhost|.each do |v|
|
248
248
|
p[v] = p[v].delete('[]()') # Remove square brackets and curly brackets from the host variable
|
249
249
|
p[v] = p[v].sub(/\A.+=/, '') # Remove string before "="
|
250
250
|
p[v] = p[v].gsub(/\r\z/, '') # Remove CR at the end of the value
|
@@ -316,7 +316,7 @@ module Sisimai
|
|
316
316
|
# not have the value of "deliverystatus".
|
317
317
|
if o.softbounce.to_s.empty?
|
318
318
|
# The value is not set yet
|
319
|
-
|
319
|
+
%w|deliverystatus diagnosticcode|.each do |v|
|
320
320
|
# Set the value of softbounce
|
321
321
|
next unless p[v].size > 0
|
322
322
|
r = Sisimai::SMTP.is_softbounce(p[v])
|
@@ -361,35 +361,24 @@ module Sisimai
|
|
361
361
|
# Convert from object to hash reference
|
362
362
|
# @return [Hash] Data in Hash reference
|
363
363
|
def damn
|
364
|
-
data =
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
token lhost rhost listid alias reason subject messageid smtpagent
|
369
|
-
smtpcommand destination diagnosticcode senderdomain deliverystatus
|
370
|
-
timezoneoffset feedbacktype diagnostictype action replycode softbounce
|
371
|
-
]
|
372
|
-
|
373
|
-
stringdata.each do |e|
|
374
|
-
# Copy string data
|
375
|
-
v[e] = self.send(e) || ''
|
376
|
-
end
|
377
|
-
v['addresser'] = self.addresser.address
|
378
|
-
v['recipient'] = self.recipient.address
|
379
|
-
v['timestamp'] = self.timestamp.to_time.to_i
|
380
|
-
data = v
|
381
|
-
rescue
|
382
|
-
warn '***warning: Failed to damn()'
|
364
|
+
data = {}
|
365
|
+
@@rwaccessors.each do |e|
|
366
|
+
next if e.to_s =~ /(?:addresser|recipient|timestamp)/
|
367
|
+
data[e.to_s] = self.send(e) || ''
|
383
368
|
end
|
369
|
+
data['addresser'] = self.addresser.address
|
370
|
+
data['recipient'] = self.recipient.address
|
371
|
+
data['timestamp'] = self.timestamp.to_time.to_i
|
384
372
|
return data
|
385
373
|
end
|
374
|
+
alias :to_hash :damn
|
386
375
|
|
387
376
|
# Data dumper
|
388
377
|
# @param [String] type Data format: json, yaml
|
389
378
|
# @return [String, Undef] Dumped data or Undef if the value of first
|
390
379
|
# argument is neither "json" nor "yaml"
|
391
380
|
def dump(type = 'json')
|
392
|
-
return nil unless
|
381
|
+
return nil unless %w|json yaml|.index(type)
|
393
382
|
referclass = sprintf('Sisimai::Data::%s', type.upcase)
|
394
383
|
|
395
384
|
begin
|
@@ -403,7 +392,6 @@ module Sisimai
|
|
403
392
|
end
|
404
393
|
|
405
394
|
# JSON handler
|
406
|
-
# @param [JSON::State] argv JSON::Ext::Generator::State object
|
407
395
|
# @return [String] JSON string converted from Sisimai::Data
|
408
396
|
def to_json(*)
|
409
397
|
return self.dump('json')
|