sisimai 4.16.0 → 4.17.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.

Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/ANALYTICAL-PRECISION +7 -7
  4. data/Changes +15 -0
  5. data/Makefile +1 -1
  6. data/README.md +30 -28
  7. data/lib/sisimai.rb +20 -1
  8. data/lib/sisimai/address.rb +28 -9
  9. data/lib/sisimai/arf.rb +37 -46
  10. data/lib/sisimai/data.rb +67 -43
  11. data/lib/sisimai/datetime.rb +210 -210
  12. data/lib/sisimai/mda.rb +30 -30
  13. data/lib/sisimai/message.rb +3 -5
  14. data/lib/sisimai/msp/de/einsundeins.rb +14 -42
  15. data/lib/sisimai/msp/de/gmx.rb +17 -44
  16. data/lib/sisimai/msp/jp/biglobe.rb +15 -44
  17. data/lib/sisimai/msp/jp/ezweb.rb +20 -50
  18. data/lib/sisimai/msp/jp/kddi.rb +16 -43
  19. data/lib/sisimai/msp/ru/mailru.rb +20 -48
  20. data/lib/sisimai/msp/ru/yandex.rb +16 -50
  21. data/lib/sisimai/msp/uk/messagelabs.rb +17 -51
  22. data/lib/sisimai/msp/us/amazonses.rb +18 -40
  23. data/lib/sisimai/msp/us/amazonworkmail.rb +17 -35
  24. data/lib/sisimai/msp/us/aol.rb +17 -41
  25. data/lib/sisimai/msp/us/bigfoot.rb +15 -48
  26. data/lib/sisimai/msp/us/facebook.rb +63 -90
  27. data/lib/sisimai/msp/us/google.rb +15 -44
  28. data/lib/sisimai/msp/us/office365.rb +21 -46
  29. data/lib/sisimai/msp/us/outlook.rb +17 -50
  30. data/lib/sisimai/msp/us/receivingses.rb +20 -43
  31. data/lib/sisimai/msp/us/sendgrid.rb +13 -37
  32. data/lib/sisimai/msp/us/verizon.rb +30 -74
  33. data/lib/sisimai/msp/us/yahoo.rb +12 -40
  34. data/lib/sisimai/msp/us/zoho.rb +14 -42
  35. data/lib/sisimai/mta/activehunter.rb +11 -40
  36. data/lib/sisimai/mta/apachejames.rb +18 -40
  37. data/lib/sisimai/mta/courier.rb +20 -57
  38. data/lib/sisimai/mta/domino.rb +24 -56
  39. data/lib/sisimai/mta/exchange.rb +26 -54
  40. data/lib/sisimai/mta/exim.rb +20 -39
  41. data/lib/sisimai/mta/imailserver.rb +26 -71
  42. data/lib/sisimai/mta/interscanmss.rb +26 -44
  43. data/lib/sisimai/mta/mailfoundry.rb +12 -42
  44. data/lib/sisimai/mta/mailmarshalsmtp.rb +13 -43
  45. data/lib/sisimai/mta/mcafee.rb +17 -46
  46. data/lib/sisimai/mta/messagingserver.rb +14 -47
  47. data/lib/sisimai/mta/mfilter.rb +12 -35
  48. data/lib/sisimai/mta/mxlogic.rb +18 -42
  49. data/lib/sisimai/mta/notes.rb +22 -45
  50. data/lib/sisimai/mta/opensmtpd.rb +18 -48
  51. data/lib/sisimai/mta/postfix.rb +15 -45
  52. data/lib/sisimai/mta/qmail.rb +32 -60
  53. data/lib/sisimai/mta/sendmail.rb +13 -38
  54. data/lib/sisimai/mta/surfcontrol.rb +15 -44
  55. data/lib/sisimai/mta/userdefined.rb +14 -30
  56. data/lib/sisimai/mta/v5sendmail.rb +18 -40
  57. data/lib/sisimai/mta/x1.rb +12 -41
  58. data/lib/sisimai/mta/x2.rb +12 -41
  59. data/lib/sisimai/mta/x3.rb +12 -39
  60. data/lib/sisimai/mta/x4.rb +33 -66
  61. data/lib/sisimai/mta/x5.rb +15 -42
  62. data/lib/sisimai/reason.rb +8 -71
  63. data/lib/sisimai/reason/blocked.rb +3 -0
  64. data/lib/sisimai/reason/contenterror.rb +3 -0
  65. data/lib/sisimai/reason/delivered.rb +27 -0
  66. data/lib/sisimai/reason/exceedlimit.rb +3 -0
  67. data/lib/sisimai/reason/expired.rb +3 -0
  68. data/lib/sisimai/reason/feedback.rb +18 -0
  69. data/lib/sisimai/reason/filtered.rb +4 -0
  70. data/lib/sisimai/reason/hasmoved.rb +3 -0
  71. data/lib/sisimai/reason/hostunknown.rb +3 -0
  72. data/lib/sisimai/reason/mailboxfull.rb +3 -0
  73. data/lib/sisimai/reason/mailererror.rb +3 -0
  74. data/lib/sisimai/reason/mesgtoobig.rb +3 -0
  75. data/lib/sisimai/reason/networkerror.rb +3 -0
  76. data/lib/sisimai/reason/norelaying.rb +3 -0
  77. data/lib/sisimai/reason/notaccept.rb +3 -0
  78. data/lib/sisimai/reason/onhold.rb +3 -0
  79. data/lib/sisimai/reason/rejected.rb +3 -0
  80. data/lib/sisimai/reason/securityerror.rb +3 -0
  81. data/lib/sisimai/reason/spamdetected.rb +3 -0
  82. data/lib/sisimai/reason/suspend.rb +3 -0
  83. data/lib/sisimai/reason/syntaxerror.rb +41 -0
  84. data/lib/sisimai/reason/systemerror.rb +3 -0
  85. data/lib/sisimai/reason/systemfull.rb +3 -0
  86. data/lib/sisimai/reason/toomanyconn.rb +3 -0
  87. data/lib/sisimai/reason/undefined.rb +18 -0
  88. data/lib/sisimai/reason/userunknown.rb +3 -0
  89. data/lib/sisimai/reason/vacation.rb +18 -0
  90. data/lib/sisimai/rfc3464.rb +15 -40
  91. data/lib/sisimai/rfc3834.rb +1 -10
  92. data/lib/sisimai/rfc5322.rb +57 -19
  93. data/lib/sisimai/rhost/googleapps.rb +82 -82
  94. data/lib/sisimai/smtp/reply.rb +2 -1
  95. data/lib/sisimai/smtp/status.rb +154 -152
  96. data/lib/sisimai/string.rb +2 -3
  97. data/lib/sisimai/version.rb +1 -1
  98. data/set-of-emails/maildir/bsd/rfc3464-29.eml +60 -0
  99. data/set-of-emails/maildir/bsd/us-amazonworkmail-06.eml +156 -0
  100. data/set-of-emails/maildir/bsd/us-amazonworkmail-07.eml +158 -0
  101. data/set-of-emails/maildir/bsd/us-google-15.eml +97 -0
  102. data/set-of-emails/maildir/bsd/us-google-16.eml +99 -0
  103. data/set-of-emails/maildir/bsd/us-google-17.eml +104 -0
  104. data/set-of-emails/maildir/dos/apachejames-01.eml +4 -4
  105. data/set-of-emails/maildir/dos/us-amazonworkmail-01.eml +156 -0
  106. data/set-of-emails/maildir/dos/us-office365-01.eml +102 -0
  107. data/set-of-emails/maildir/mac/apachejames-01.eml +1 -9
  108. data/set-of-emails/maildir/mac/us-amazonworkmail-01.eml +1 -7
  109. data/set-of-emails/maildir/mac/us-office365-01.eml +1 -4
  110. metadata +17 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82738ed0361880b40c6cea5b67f0214a54d21c6a
4
- data.tar.gz: fb585810f00aa5bcf2a1df3efeebabfbbdfe25c3
3
+ metadata.gz: 7f8417def53786b484d3142cc70aab3ef509f4dd
4
+ data.tar.gz: da9f64d09e10a477b98ac366d2fb814f346ed1db
5
5
  SHA512:
6
- metadata.gz: 2118f34578542ec270941872781cd2db5880d946448046e6b8872d7d4c20321586e4216595f2f7612669725f47c68800e0de1481f7de489e8fc5cabd5a75b75c
7
- data.tar.gz: ec163cac4184853b36ac22e205ec26e4075b4b061dec396291779e7230c273aa350a1188863a888adf26a5116d95f5c68daf45e6918aef54aa4ed60422926301
6
+ metadata.gz: 8cff802da78f62b22f8d79fde792abcf63d805f3bdcba0896cad87223526f0203c7117be7d1d903e0897b5965e283a0c74a2bda6b32c9c27b783c057922451df
7
+ data.tar.gz: 6718be8fd7fd8c46ca9829fbe02108d7631207ca065b6042d5dc05fab9b4c2a0d320bf8d972332064aac33b1560f36170b28f7e594ca2b24b5adc43b6732392c
data/.rubocop.yml CHANGED
@@ -15,6 +15,9 @@ Lint/AssignmentInCondition:
15
15
  Metrics/AbcSize:
16
16
  Max: 30
17
17
 
18
+ Metrics/BlockNesting:
19
+ Max: 4
20
+
18
21
  Metrics/CyclomaticComplexity:
19
22
  Enabled: false
20
23
 
data/ANALYTICAL-PRECISION CHANGED
@@ -25,8 +25,8 @@ MTA::X2 ................. 0/0069 0.0000 Unknown MTA #2
25
25
  MTA::X3 ................. 0/0012 0.0000 Unknown MTA #3
26
26
  MTA::X4 ................. 0/0029 0.0000 Unknown MTA #4 qmail clones
27
27
  MTA::X5 ................. 3/0003 1.0000 Unknown MTA #5
28
- MTA::mFILTER ............ 0/0010 0.0000 Digital Arts m-FILTER
29
- MTA::qmail .............. 51/0078 0.6538 qmail
28
+ MTA::mFILTER ............ 0/0009 0.0000 Digital Arts m-FILTER
29
+ MTA::qmail .............. 52/0078 0.6667 qmail
30
30
  MSP::DE::EinsUndEins .... 0/0003 0.0000 1&1: http://www.1and1.de
31
31
  MSP::DE::GMX ............ 0/0010 0.0000 GMX: http://www.gmx.net
32
32
  MSP::JP::Biglobe ........ 0/0007 0.0000 BIGLOBE: http://www.biglobe.ne.jp
@@ -36,11 +36,11 @@ MSP::RU::MailRu ......... 4/0014 0.2857 @mail.ru: https://mail.ru
36
36
  MSP::RU::Yandex ......... 4/0007 0.5714 Yandex.Mail: http://www.yandex.ru
37
37
  MSP::UK::MessageLabs .... 2/0002 1.0000 Symantec.cloud http://www.messagelabs.com
38
38
  MSP::US::AmazonSES ...... 18/0018 1.0000 Amazon SES(Sending): http://aws.amazon.com/ses/
39
- MSP::US::AmazonWorkMail . 6/0010 0.6000 Amazon WorkMail: https://aws.amazon.com/workmail/
39
+ MSP::US::AmazonWorkMail . 8/0012 0.6667 Amazon WorkMail: https://aws.amazon.com/workmail/
40
40
  MSP::US::Aol ............ 18/0021 0.8571 Aol Mail: http://www.aol.com
41
41
  MSP::US::Bigfoot ........ 2/0002 1.0000 Bigfoot: http://www.bigfoot.com
42
42
  MSP::US::Facebook ....... 3/0003 1.0000 Facebook: https://www.facebook.com
43
- MSP::US::Google ......... 0/0058 0.0000 Google Gmail: https://mail.google.com
43
+ MSP::US::Google ......... 0/0061 0.0000 Google Gmail: https://mail.google.com
44
44
  MSP::US::Office365 ...... 6/0007 0.8571 Microsoft Office 365: http://office.microsoft.com/
45
45
  MSP::US::Outlook ........ 19/0021 0.9048 Microsoft Outlook.com: https://www.outlook.com/
46
46
  MSP::US::ReceivingSES ... 0/0007 0.0000 Amazon SES(Receiving): http://aws.amazon.com/ses/
@@ -49,8 +49,8 @@ MSP::US::Verizon ........ 3/0003 1.0000 Verizon Wireless: http://www.verizo
49
49
  MSP::US::Yahoo .......... 0/0009 0.0000 Yahoo! MAIL: https://www.yahoo.com
50
50
  MSP::US::Zoho ........... 0/0011 0.0000 Zoho Mail: https://www.zoho.com
51
51
  ARF ..................... 9/0050 0.1800 Abuse Feedback Reporting Format
52
- RFC3464 ................. 130/0273 0.4762 Fallback Module for MTAs
52
+ RFC3464 ................. 131/0274 0.4781 Fallback Module for MTAs
53
53
  RFC3834 ................. 0/0004 0.0000 Detector for auto replied message
54
54
  -------------------------------------------------------------------------------
55
- bounceHammer 2.7.13p3 1025/2125 0.4824
56
- Sisimai 4.16.0 2125/2125 1.0000
55
+ bounceHammer 2.7.13p3 1029/2130 0.4831
56
+ Sisimai 4.17.0 2130/2130 1.0000
data/Changes CHANGED
@@ -1,5 +1,20 @@
1
1
  Revision history for Ruby version of Sisimai
2
2
 
3
+ 4.17.0 Wed, 16 Mar 2016 12:22:44 +0900 (JST)
4
+ - Implement new reason "syntaxerror". Sisimai will set "syntaxerror" to the
5
+ raeson when the value of "replycode" begins with "50" such as 502, 503,
6
+ or 504. Imported from https://github.com/sisimai/p5-Sisimai/pull/170.
7
+ - Implement description() method at each class in sisimai/reason/*.rb and
8
+ Sisimai.reason method for getting the list of reasons Sisimai can detect
9
+ and its description: issue #48.
10
+ - Remove unused method Sisimai::Reason->match, issue #49.
11
+ - Some methods of Sisimai::Address allow "postmaster", and "mailer-daemon"
12
+ ( without a domain part ) as an email address.
13
+ - Sisimai::RFC5322.is_mailerdaemon() method returns true when the argument
14
+ includes "postmaster".
15
+ - Merge pull-request #51, new method Sisimai::RFC5322.weedout() and code
16
+ improvements in all the MTA/MSP modules.
17
+
3
18
  4.16.0 Thu, 18 Feb 2016 13:49:01 +0900 (JST)
4
19
  - Implement new reason "delivered". Sisimai set "delivered" to the reason
5
20
  when the value of Status: field in a bounce message begins with "2". This
data/Makefile CHANGED
@@ -44,7 +44,7 @@ install-from-local:
44
44
 
45
45
  release:
46
46
  $(RAKE) release
47
- if [ test -d "$(JRUBY)" ]; then \
47
+ if [ -d "$(JRUBY)" ]; then \
48
48
  PATH="$$PATH:$(JRUBY)/bin" $(JRUBY)/bin/rake release; \
49
49
  fi
50
50
 
data/README.md CHANGED
@@ -29,7 +29,7 @@ Key Features | 主な特徴的機能
29
29
  * Support 21 known MTAs and 5 unknown MTAs | 26種類のMTAに対応
30
30
  * Support 21 major MSPs(Mail Service Providers) | 21種類の著名なMSPに対応
31
31
  * Support Feedback Loop Message(ARF) | Feedback Loopにも対応
32
- * Can detect 26 error reasons | 26種類のエラー理由を検出
32
+ * Can detect 27 error reasons | 27種類のエラー理由を検出
33
33
 
34
34
  Setting Up Sisimai | シシマイを使う準備
35
35
  =======================================
@@ -149,36 +149,36 @@ Differences between Perl version and Ruby version | Perl版との違い
149
149
  The following table show the differences between Perl version of Sisimai
150
150
  and Ruby version of Sisimai.
151
151
 
152
- | Features | Ruby version | Perl version |
153
- |------------------------------------------------|---------------|--------------|
154
- | System requirements | Ruby 2.1-2.3 | Perl 5.10 - |
155
- | | JRuby 9.0.4.0-| |
156
- | Analytical precision ratio(2000 emails)[1] | 1.00 | 1.00 |
157
- | The speed of parsing email(1000 emails) | 3.81s | 2.50s |
158
- | How to install | gem install | cpanm |
159
- | Dependencies (Except core modules) | 1 modules | 2 modules |
160
- | LOC:Source lines of code | 11700 lines | 9100 lines |
161
- | The number of tests in t/, xt/ directory | 92400 tests | 166700 tests |
162
- | License | BSD 2-Clause | BSD 2-Clause |
163
- | Support Contract provided by Developer | Coming soon | Available |
152
+ | Features | Ruby version | Perl version |
153
+ |---------------------------------------------|----------------|---------------|
154
+ | System requirements | Ruby 2.1-2.3 | Perl 5.10 - |
155
+ | | JRuby 9.0.4.0- | |
156
+ | Analytical precision ratio(2000 emails)[1] | 1.00 | 1.00 |
157
+ | The speed of parsing email(1000 emails) | 3.30s | 2.33s |
158
+ | How to install | gem install | cpanm |
159
+ | Dependencies (Except core modules) | 1 modules | 2 modules |
160
+ | LOC:Source lines of code | 11000 lines | 8000 lines |
161
+ | The number of tests in t/, xt/ directory | 94300 tests | 170000 tests |
162
+ | License | BSD 2-Clause | BSD 2-Clause |
163
+ | Support Contract provided by Developer | Coming soon | Available |
164
164
 
165
165
  1. See ./ANALYTICAL-PRECISION
166
166
 
167
167
  公開中のPerl版Sisimai(p5-Sisimai)とRuby版Sisimai(rb-Sisimai)は下記のような違いが
168
168
  あります。
169
169
 
170
- | 機能 | Ruby version | Perl version|
171
- |------------------------------------------------|---------------|-------------|
172
- | 動作環境 | Ruby 2.1-2.3 | Perl 5.10 - |
173
- | | JRuby 9.0.4.0-| |
174
- | 解析精度の割合(2000通のメール)[1] | 1.00 | 1.00 |
175
- | メール解析速度(1000通のメール) | 3.81 | 2.50 |
176
- | インストール方法 | gem install | cpanm |
177
- | 依存モジュール数(コアモジュールを除く) | 1モジュール | 2モジュール |
178
- | LOC:ソースコードの行数 | 11700 | 9100 |
179
- | テスト件数(t/,xt/ディレクトリ) | 92400 | 166700 |
180
- | ライセンス | 二条項BSD | 二条項BSD |
181
- | 開発会社によるサポート契約 | 準備中 | 提供中 |
170
+ | 機能 | Ruby version | Perl version |
171
+ |---------------------------------------------|----------------|---------------|
172
+ | 動作環境 | Ruby 2.1-2.3 | Perl 5.10 - |
173
+ | | JRuby 9.0.4.0- | |
174
+ | 解析精度の割合(2000通のメール)[1] | 1.00 | 1.00 |
175
+ | メール解析速度(1000通のメール) | 3.30 | 2.33 |
176
+ | インストール方法 | gem install | cpanm |
177
+ | 依存モジュール数(コアモジュールを除く) | 1モジュール | 2モジュール |
178
+ | LOC:ソースコードの行数 | 11000 | 8000 |
179
+ | テスト件数(t/,xt/ディレクトリ) | 94300 | 170000 |
180
+ | ライセンス | 二条項BSD | 二条項BSD |
181
+ | 開発会社によるサポート契約 | 準備中 | 提供中 |
182
182
 
183
183
  1. ./ANALYTICAL-PRECISIONを参照
184
184
 
@@ -246,7 +246,7 @@ details about these modules are available at
246
246
 
247
247
  Bounce Reason List | バウンス理由の一覧
248
248
  ----------------------------------------
249
- Sisimai can detect the following 26 bounce reasons. More details about reasons
249
+ Sisimai can detect the following 27 bounce reasons. More details about reasons
250
250
  are available at [Sisimai | Bounce Reason List](http://libsisimai.org/reason)
251
251
  page.
252
252
 
@@ -254,7 +254,7 @@ page.
254
254
  |----------------|----------------------------------------|----------------------------------|
255
255
  | Blocked | Blocked due to client IP address | IPアドレスによる拒否 |
256
256
  | ContentError | Invalid format email | 不正な形式のメール |
257
- | Delivered | Successfully delivered (> v4.16.0) | 正常に配信された
257
+ | Delivered[1] | Successfully delivered (> v4.16.0) | 正常に配信された(> v4.16.0) |
258
258
  | ExceedLimit | Message size exceeded the limit(5.2.3) | メールサイズの超過 |
259
259
  | Expired | Delivery time expired | 配送時間切れ |
260
260
  | Feedback | Bounced for a complaint of the message | 元メールへの苦情によるバウンス |
@@ -272,6 +272,7 @@ page.
272
272
  | SecurityError | Virus detected or authentication error | ウィルスの検出または認証失敗 |
273
273
  | SpamDetected | Detected a message as spam | メールはスパムとして判定された |
274
274
  | Suspend | Recipient's account is suspended | 宛先アカウントは一時的に停止中 |
275
+ | SyntaxError | syntax error in SMTP (> v4.17.0) | SMTPの文法エラー(> v4.17.0) |
275
276
  | SystemError | Some error on the destination host | 宛先サーバでのOSレベルのエラー |
276
277
  | SystemFull | Disk full on the destination host | 宛先サーバのディスクが一杯 |
277
278
  | TooManyConn | Connection rate limit exceeded | 接続制限数を超過した |
@@ -279,7 +280,8 @@ page.
279
280
  | Undefined | Could not decide the error reason | バウンスした理由は特定出来ず |
280
281
  | Vacation | Auto replied message | 自動応答メッセージ |
281
282
 
282
- Sisimaiは上記のエラー26種を検出します。
283
+ Sisimaiは上記のエラー27種を検出します。
284
+ 1. This reason is not included by default | このバウンス理由は標準では解析結果に含まれません
283
285
 
284
286
 
285
287
  Parsed data structure | 解析後のデータ構造
data/lib/sisimai.rb CHANGED
@@ -90,6 +90,25 @@ module Sisimai
90
90
  return table
91
91
  end
92
92
 
93
- end
93
+ # Reason list Sisimai can detect
94
+ # @return [Hash] Reason list table
95
+ def reason
96
+ require 'sisimai/reason'
97
+ table = {}
98
+ names = Sisimai::Reason.index
99
+
100
+ # These reasons are not included in the results of Sisimai::Reason.index
101
+ names.concat(%w|Delivered Feedback Undefined Vacation|)
94
102
 
103
+ names.each do |e|
104
+ # Call .description() method of Sisimai::Reason::*
105
+ r = 'Sisimai::Reason::' + e
106
+ require r.gsub('::', '/').downcase
107
+ table[r.to_sym] = Module.const_get(r).send(:description)
108
+ end
109
+
110
+ return table
111
+ end
112
+ end
95
113
  end
114
+
@@ -5,18 +5,17 @@ module Sisimai
5
5
  require 'sisimai/rfc5322'
6
6
 
7
7
  # Return pseudo recipient or sender address
8
- # @param [String] argv1 Address type: 'r' or 's'
8
+ # @param [Symbol] argv1 Address type: :r or :s
9
9
  # @return [String, Nil] Pseudo recipient address or sender address or
10
- # Undef when the $argv1 is neither 'r' nor 's'
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 %w|r s|.index(argv1)
13
+ return nil unless %w|r s|.index(argv1.to_s)
14
14
 
15
- local = argv1 == 'r' ? 'recipient' : 'sender'
15
+ local = argv1 == :r ? 'recipient' : 'sender'
16
16
  return sprintf('undisclosed-%s-in-headers@dummy-domain.invalid', local)
17
17
  end
18
18
 
19
-
20
19
  # Email address parser
21
20
  # @param [Array] argvs List of strings including email address
22
21
  # @return [Array, Nil] Email address list or Undef when there is no
@@ -30,7 +29,10 @@ module Sisimai
30
29
  # 1. The element must include '@'.
31
30
  # 2. The element must not include character except from 0x20 to 0x7e.
32
31
  next unless e
33
- next unless e =~ /[@]/
32
+ unless e =~ /[@]/
33
+ # Allow if the argument is MAILER-DAEMON
34
+ next unless Sisimai::RFC5322.is_mailerdaemon(e)
35
+ end
34
36
  next if e =~ /[^\x20-\x7e]/
35
37
 
36
38
  v = Sisimai::Address.s3s4(e)
@@ -78,7 +80,10 @@ module Sisimai
78
80
  else
79
81
  token.each do |e|
80
82
  e.chomp
81
- next unless e =~ /\A[<]?.+[@][-.0-9A-Za-z]+[.]?[A-Za-z]{2,}[>]?\z/
83
+ unless e =~ /\A[<]?.+[@][-.0-9A-Za-z]+[.]?[A-Za-z]{2,}[>]?\z/
84
+ # Check whether the element is mailer-daemon or not
85
+ next unless Sisimai::RFC5322.is_mailerdaemon(e)
86
+ end
82
87
  addrs << e
83
88
  end
84
89
  end
@@ -162,7 +167,6 @@ module Sisimai
162
167
  # Remove MIME-Encoded comment part
163
168
  lpart = lpart.sub(/\A=[?].+[?]b[?].+[?]=/, '')
164
169
  lpart = lpart.delete(%q|`'"<>|) unless lpart =~ /\A["].+["]\z/
165
-
166
170
  aflag = false
167
171
  addr0 = sprintf('%s@%s', lpart, dpart)
168
172
  addr1 = Sisimai::Address.expand_verp(addr0)
@@ -197,7 +201,22 @@ module Sisimai
197
201
  @verp ||= ''
198
202
 
199
203
  else
200
- return nil
204
+ # The argument does not include "@"
205
+ return nil unless Sisimai::RFC5322.is_mailerdaemon(email)
206
+ @alias ||= ''
207
+ @verp ||= ''
208
+ @host ||= ''
209
+
210
+ if cv = email.match(/[<]([^ ]+)[>]/)
211
+ # Mail Delivery Subsystem <MAILER-DAEMON>
212
+ @user = cv[1]
213
+ @address = cv[1]
214
+ else
215
+ return nil if email =~ /[ ]/
216
+ # The argument does not include " "
217
+ @user = email
218
+ @address = email
219
+ end
201
220
  end
202
221
  end
203
222
 
data/lib/sisimai/arf.rb CHANGED
@@ -86,7 +86,7 @@ module Sisimai
86
86
  return nil unless self.is_arf(mhead)
87
87
 
88
88
  require 'sisimai/address'
89
- dscontents = []; dscontents << Sisimai::MTA.DELIVERYSTATUS
89
+ dscontents = [Sisimai::MTA.DELIVERYSTATUS]
90
90
  hasdivided = mbody.split("\n")
91
91
  rfc822part = '' # (String) message/rfc822-headers part
92
92
  previousfn = '' # (String) Previous field name
@@ -94,16 +94,16 @@ module Sisimai
94
94
  recipients = 0 # (Integer) The number of 'Final-Recipient' header
95
95
  rcptintext = '' # (String) Recipient address in the message body
96
96
  commondata = {
97
- 'diagnosis' => '', # Error message
98
- 'from' => '', # Original-Mail-From:
99
- 'rhost' => '', # Reporting-MTA:
97
+ :diagnosis => '', # Error message
98
+ :from => '', # Original-Mail-From:
99
+ :rhost => '', # Reporting-MTA:
100
100
  }
101
101
  arfheaders = {
102
- 'feedbacktype' => nil, # FeedBack-Type:
103
- 'rhost' => nil, # Source-IP:
104
- 'agent' => nil, # User-Agent:
105
- 'date' => nil, # Arrival-Date:
106
- 'authres' => nil, # Authentication-Results:
102
+ :feedbacktype => nil, # FeedBack-Type:
103
+ :rhost => nil, # Source-IP:
104
+ :agent => nil, # User-Agent:
105
+ :date => nil, # Arrival-Date:
106
+ :authres => nil, # Authentication-Results:
107
107
  }
108
108
  v = nil
109
109
 
@@ -131,7 +131,7 @@ module Sisimai
131
131
  if readcursor == 0
132
132
  # Beginning of the bounce message or delivery status part
133
133
  if e =~ Re1[:begin]
134
- readcursor |= Indicators[:'deliverystatus']
134
+ readcursor |= Indicators[:deliverystatus]
135
135
  next
136
136
  end
137
137
  end
@@ -154,13 +154,13 @@ module Sisimai
154
154
  # The "X-HmXmrOriginalRecipient" header appears only once so
155
155
  # we take this opportunity to hard-code ARF headers missing in
156
156
  # Microsoft's implementation.
157
- arfheaders['feedbacktype'] = 'abuse'
158
- arfheaders['agent'] = 'Microsoft Junk Mail Reporting Program'
157
+ arfheaders[:feedbacktype] = 'abuse'
158
+ arfheaders[:agent] = 'Microsoft Junk Mail Reporting Program'
159
159
 
160
160
  elsif cv = e.match(/\AFrom:[ ]*(.+)\z/)
161
161
  # Microsoft ARF: original sender.
162
- if commondata['from'].empty?
163
- commondata['from'] = Sisimai::Address.s3s4(cv[1])
162
+ if commondata[:from].empty?
163
+ commondata[:from] = Sisimai::Address.s3s4(cv[1])
164
164
  end
165
165
 
166
166
  elsif cv = e.match(/\A([-0-9A-Za-z]+?)[:][ ]*(.+)\z/)
@@ -184,7 +184,7 @@ module Sisimai
184
184
 
185
185
  else
186
186
  # Before "message/rfc822"
187
- next unless readcursor & Indicators[:'deliverystatus'] > 0
187
+ next unless readcursor & Indicators[:deliverystatus] > 0
188
188
  next unless e.size > 0
189
189
 
190
190
  # Feedback-Type: abuse
@@ -197,7 +197,7 @@ module Sisimai
197
197
  v = dscontents[-1]
198
198
 
199
199
  if cv = e.match(/\AOriginal-Rcpt-To:[ ]+[<]?(.+)[>]?\z/) ||
200
- cv = e.match(/\ARedacted-Address:[ ]([^ ].+[@])\z/)
200
+ e.match(/\ARedacted-Address:[ ]([^ ].+[@])\z/)
201
201
  # Original-Rcpt-To header field is optional and may appear any
202
202
  # number of times as appropriate:
203
203
  # Original-Rcpt-To: <user@example.com>
@@ -213,7 +213,7 @@ module Sisimai
213
213
  elsif cv = e.match(/\AFeedback-Type:[ ]*([^ ]+)\z/)
214
214
  # The header field MUST appear exactly once.
215
215
  # Feedback-Type: abuse
216
- arfheaders['feedbacktype'] = cv[1]
216
+ arfheaders[:feedbacktype] = cv[1]
217
217
 
218
218
  elsif cv = e.match(/\AAuthentication-Results:[ ]*(.+)\z/)
219
219
  # "Authentication-Results" indicates the result of one or more
@@ -221,35 +221,35 @@ module Sisimai
221
221
  #
222
222
  # Authentication-Results: mail.example.com;
223
223
  # spf=fail smtp.mail=somespammer@example.com
224
- arfheaders['authres'] = cv[1]
224
+ arfheaders[:authres] = cv[1]
225
225
 
226
226
  elsif cv = e.match(/\AUser-Agent:[ ]*(.+)\z/)
227
227
  # The header field MUST appear exactly once.
228
228
  # User-Agent: SomeGenerator/1.0
229
- arfheaders['agent'] = cv[1]
229
+ arfheaders[:agent] = cv[1]
230
230
 
231
231
  elsif cv = e.match(/\A(?:Received|Arrival)-Date:[ ]*(.+)\z/)
232
232
  # Arrival-Date header is optional and MUST NOT appear more than
233
233
  # once.
234
234
  # Received-Date: Thu, 29 Apr 2010 00:00:00 JST
235
235
  # Arrival-Date: Thu, 29 Apr 2010 00:00:00 +0000
236
- arfheaders['date'] = cv[1]
236
+ arfheaders[:date] = cv[1]
237
237
 
238
238
  elsif cv = e.match(/\AReporting-MTA:[ ]*dns;[ ]*(.+)\z/)
239
239
  # The header is optional and MUST NOT appear more than once.
240
240
  # Reporting-MTA: dns; mx.example.jp
241
- commondata['rhost'] = cv[1]
241
+ commondata[:rhost] = cv[1]
242
242
 
243
243
  elsif cv = e.match(/\ASource-IP:[ ]*(.+)\z/)
244
244
  # The header is optional and MUST NOT appear more than once.
245
245
  # Source-IP: 192.0.2.45
246
- arfheaders['rhost'] = cv[1]
246
+ arfheaders[:rhost] = cv[1]
247
247
 
248
248
  elsif cv = e.match(/\AOriginal-Mail-From:[ ]*(.+)\z/)
249
249
  # the header is optional and MUST NOT appear more than once.
250
250
  # Original-Mail-From: <somespammer@example.net>
251
- if commondata['from'].empty?
252
- commondata['from'] = Sisimai::Address.s3s4(cv[1])
251
+ if commondata[:from].empty?
252
+ commondata[:from] = Sisimai::Address.s3s4(cv[1])
253
253
  end
254
254
 
255
255
  elsif e =~ Re1[:begin]
@@ -257,37 +257,37 @@ module Sisimai
257
257
  # message-id of 0000-000000000000000000000000000000000@mx
258
258
  # received from IP address 192.0.2.1 on
259
259
  # Thu, 29 Apr 2010 00:00:00 +0900 (JST)
260
- commondata['diagnosis'] = e
260
+ commondata[:diagnosis] = e
261
261
  end
262
262
  end
263
263
  end
264
264
 
265
- if arfheaders['feedbacktype'] == 'auth-failure' && arfheaders['authres']
265
+ if arfheaders[:feedbacktype] == 'auth-failure' && arfheaders[:authres]
266
266
  # Append the value of Authentication-Results header
267
- commondata['diagnosis'] += ' ' + arfheaders['authres']
267
+ commondata[:diagnosis] += ' ' + arfheaders[:authres]
268
268
  end
269
269
 
270
270
  if recipients == 0
271
271
  # Insert pseudo recipient address when there is no valid recipient
272
272
  # address in the message.
273
- dscontents[-1]['recipient'] = Sisimai::Address.undisclosed('r')
273
+ dscontents[-1]['recipient'] = Sisimai::Address.undisclosed(:r)
274
274
  recipients = 1
275
275
  end
276
276
 
277
277
  unless rfc822part =~ /\bFrom: [^ ]+[@][^ ]+\b/
278
278
  # There is no "From:" header in the original message
279
- if commondata['from'].size > 0
279
+ if commondata[:from].size > 0
280
280
  # Append the value of "Original-Mail-From" value as a sender address.
281
- rfc822part += sprintf("From: %s\n", commondata['from'])
281
+ rfc822part += sprintf("From: %s\n", commondata[:from])
282
282
  end
283
283
  end
284
284
 
285
285
  if cv = mhead['subject'].match(/complaint about message from (\d{1,3}[.]\d{1,3}[.]\d{1,3}[.]\d{1,3})/)
286
286
  # Microsoft ARF: remote host address.
287
- arfheaders['rhost'] = cv[1]
288
- commondata['diagnosis'] = sprintf(
287
+ arfheaders[:rhost] = cv[1]
288
+ commondata[:diagnosis] = sprintf(
289
289
  'This is a Microsoft email abuse report for an email message received from IP %s on %s',
290
- arfheaders['rhost'], mhead['date'])
290
+ arfheaders[:rhost], mhead['date'])
291
291
  end
292
292
 
293
293
  dscontents.map do |e|
@@ -295,18 +295,18 @@ module Sisimai
295
295
  # AOL = http://forums.cpanel.net/f43/aol-brutal-work-71473.html
296
296
  e['recipient'] = Sisimai::Address.s3s4(rcptintext)
297
297
  end
298
- arfheaders.each_key { |a| e[a] ||= arfheaders[a] || '' }
298
+ arfheaders.each_key { |a| e[a.to_s] ||= arfheaders[a] || '' }
299
299
  e.delete('authres')
300
300
 
301
301
  e['softbounce'] = -1
302
- e['diagnosis'] = commondata['diagnosis'] unless e['diagnosis']
302
+ e['diagnosis'] = commondata[:diagnosis] unless e['diagnosis']
303
303
  e['date'] = mhead['date'] if e['date'].empty?
304
304
 
305
305
  if e['rhost'].empty?
306
306
  # Get the remote IP address from the message body
307
- if commondata['rhost'].size > 0
307
+ if commondata[:rhost].size > 0
308
308
  # The value of "Reporting-MTA" header
309
- e['rhost'] = commondata['rhost']
309
+ e['rhost'] = commondata[:rhost]
310
310
 
311
311
  elsif cv = e['diagnosis'].match(/\breceived from IP address ([^ ]+)/)
312
312
  # This is an email abuse report for an email message received
@@ -315,15 +315,6 @@ module Sisimai
315
315
  end
316
316
  end
317
317
 
318
- if mhead['received'].size > 0
319
- # Get localhost and remote host name from Received header.
320
- r0 = mhead['received']
321
- %w|lhost rhost|.each { |a| e[a] ||= '' }
322
- e['lhost'] = Sisimai::RFC5322.received(r0[0]).shift if e['lhost'].empty?
323
- e['rhost'] = Sisimai::RFC5322.received(r0[-1]).pop if e['rhost'].empty?
324
- end
325
-
326
- e['spec'] = 'SMTP'
327
318
  e['action'] = 'failed'
328
319
  e['reason'] = 'feedback'
329
320
  e['command'] = ''