sisimai 4.17.2-java → 4.18.0-java

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 (36) hide show
  1. checksums.yaml +4 -4
  2. data/ANALYTICAL-PRECISION +12 -11
  3. data/Changes +6 -0
  4. data/README-JA.md +5 -4
  5. data/README.md +5 -4
  6. data/Repository.mk +4 -1
  7. data/lib/sisimai/data.rb +44 -29
  8. data/lib/sisimai/msp/ru/mailru.rb +1 -5
  9. data/lib/sisimai/msp/us/amazonses.rb +0 -1
  10. data/lib/sisimai/msp/us/facebook.rb +0 -2
  11. data/lib/sisimai/msp/us/google.rb +0 -5
  12. data/lib/sisimai/msp/us/sendgrid.rb +4 -11
  13. data/lib/sisimai/mta.rb +4 -3
  14. data/lib/sisimai/mta/courier.rb +0 -2
  15. data/lib/sisimai/mta/{exchange.rb → exchange2003.rb} +9 -8
  16. data/lib/sisimai/mta/exchange2007.rb +172 -0
  17. data/lib/sisimai/mta/exim.rb +3 -23
  18. data/lib/sisimai/mta/mailfoundry.rb +3 -9
  19. data/lib/sisimai/mta/mxlogic.rb +1 -5
  20. data/lib/sisimai/mta/x4.rb +1 -5
  21. data/lib/sisimai/order.rb +4 -2
  22. data/lib/sisimai/smtp.rb +1 -0
  23. data/lib/sisimai/smtp/error.rb +149 -0
  24. data/lib/sisimai/smtp/reply.rb +14 -0
  25. data/lib/sisimai/version.rb +1 -1
  26. data/set-of-emails/maildir/bsd/README.md +8 -2
  27. data/set-of-emails/maildir/bsd/{exchange-01.eml → exchange2003-01.eml} +0 -0
  28. data/set-of-emails/maildir/bsd/{exchange-02.eml → exchange2003-02.eml} +0 -0
  29. data/set-of-emails/maildir/bsd/{exchange-03.eml → exchange2003-03.eml} +0 -0
  30. data/set-of-emails/maildir/bsd/{exchange-04.eml → exchange2003-04.eml} +0 -0
  31. data/set-of-emails/maildir/bsd/{exchange-05.eml → exchange2003-05.eml} +0 -0
  32. data/set-of-emails/maildir/bsd/{exchange-06.eml → exchange2003-06.eml} +0 -0
  33. data/set-of-emails/maildir/bsd/exchange2007-01.eml +151 -0
  34. data/set-of-emails/maildir/bsd/exchange2007-02.eml +252 -0
  35. data/set-of-emails/maildir/bsd/rfc3464-28.eml +0 -0
  36. metadata +13 -9
@@ -221,11 +221,7 @@ module Sisimai
221
221
  # host neko.example.jp [192.0.2.222]: 550 5.1.1 <kijitora@example.jp>... User Unknown
222
222
  v = dscontents[-1]
223
223
 
224
- if e =~ /[ \t]*This is a permanent error[.][ \t]*/
225
- # deliver.c:6811| "recipients. This is a permanent error. The following address(es) failed:\n");
226
- v['softbounce'] = 0
227
-
228
- elsif cv = e.match(/\A[ ][ ]+([^ \t]+[@][^ \t]+[.][a-zA-Z]+)(:.+)?\z/) || e.match(Re1[:alias])
224
+ if cv = e.match(/\A[ ][ ]+([^ \t]+[@][^ \t]+[.][a-zA-Z]+)(:.+)?\z/) || e.match(Re1[:alias])
229
225
  # kijitora@example.jp
230
226
  # sabineko@example.jp: forced freeze
231
227
  #
@@ -497,33 +493,17 @@ module Sisimai
497
493
 
498
494
  if v1 > 0
499
495
  # Status or SMTP reply code exists
500
- if v1 % 5 == 0
501
- # Both "Status" and SMTP reply code indicate permanent error
502
- e['softbounce'] = 0
503
-
504
- elsif v1 % 4 == 0
505
- # Both "Status" and SMTP reply code indicate temporary error
506
- e['softbounce'] = 1
507
-
508
- else
509
- # Mismatch error type...?
510
- if r1 > 0
511
- # Set pseudo DSN into the value of "status" accessor
512
- e['status'] = sv
513
- e['softbounce'] = r1 == 4 ? 1 : 0
514
- end
515
- end
496
+ # Set pseudo DSN into the value of "status" accessor
497
+ e['status'] = sv if r1 > 0
516
498
  else
517
499
  # Neither Status nor SMTP reply code exist
518
500
  if e['reason'] =~ /\A(?:expired|mailboxfull)/
519
501
  # Set pseudo DSN (temporary error)
520
502
  sv = Sisimai::SMTP::Status.code(e['reason'], true)
521
- e['softbounce'] = 1
522
503
 
523
504
  else
524
505
  # Set pseudo DSN (permanent error)
525
506
  sv = Sisimai::SMTP::Status.code(e['reason'], false)
526
- e['softbounce'] = 0
527
507
  end
528
508
  end
529
509
  e['status'] ||= sv
@@ -110,15 +110,9 @@ module Sisimai
110
110
  next if v['diagnosis'].nil? || v['diagnosis'].empty?
111
111
  next if e =~ /\A[-]+/
112
112
 
113
- if e =~ /\AThis has been a permanent failure/
114
- # This has been a permanent failure. No further delivery attempts will be made.
115
- v['softbounce'] = 0
116
-
117
- else
118
- # Server mx22.example.org[192.0.2.222] failed with: 550 <kijitora@example.org> No such user here
119
- v['diagnosis'] ||= ''
120
- v['diagnosis'] += ' ' + e
121
- end
113
+ # Server mx22.example.org[192.0.2.222] failed with: 550 <kijitora@example.org> No such user here
114
+ v['diagnosis'] ||= ''
115
+ v['diagnosis'] += ' ' + e
122
116
  end
123
117
  end
124
118
  end
@@ -152,11 +152,7 @@ module Sisimai
152
152
  # host neko.example.jp [192.0.2.222]: 550 5.1.1 <kijitora@example.jp>... User Unknown
153
153
  v = dscontents[-1]
154
154
 
155
- if e =~ /[ \t]*This is a permanent error[.][ \t]*/
156
- # deliver.c:6811| "recipients. This is a permanent error. The following address(es) failed:\n");
157
- v['softbounce'] = 0
158
-
159
- elsif cv = e.match(/\A[ \t]*[<]([^ ]+[@][^ ]+)[>]:(.+)\z/)
155
+ if cv = e.match(/\A[ \t]*[<]([^ ]+[@][^ ]+)[>]:(.+)\z/)
160
156
  # A message that you have sent could not be delivered to one or more
161
157
  # recipients. This is a permanent error. The following address failed:
162
158
  #
@@ -220,11 +220,7 @@ module Sisimai
220
220
  # Giving up on 192.0.2.153.
221
221
  v = dscontents[-1]
222
222
 
223
- if cv = e.match(/\AThis is a permanent error;/)
224
- # This is a permanent error; I've given up. Sorry it didn't work out.
225
- v['softbounce'] = 0
226
-
227
- elsif cv = e.match(/\A(?:To[ ]*:)?[<](.+[@].+)[>]:[ ]*\z/)
223
+ if cv = e.match(/\A(?:To[ ]*:)?[<](.+[@].+)[>]:[ ]*\z/)
228
224
  # <kijitora@example.jp>:
229
225
  if v['recipient']
230
226
  # There are multiple recipient addresses in the message body.
data/lib/sisimai/order.rb CHANGED
@@ -12,11 +12,12 @@ module Sisimai
12
12
  # These modules have many subject patterns or have MIME encoded subjects
13
13
  # which is hard to code as regular expression
14
14
  'Sisimai::MTA::Exim',
15
- 'Sisimai::MTA::Exchange',
15
+ 'Sisimai::MTA::Exchange2003',
16
16
  ]
17
17
  AnotherList2 = [
18
18
  # These modules have no MTA specific header and did not listed in the
19
19
  # following subject header based regular expressions.
20
+ 'Sisimai::MTA::Exchange2007',
20
21
  'Sisimai::MSP::US::Facebook',
21
22
  'Sisimai::MSP::JP::KDDI',
22
23
  ]
@@ -121,7 +122,8 @@ module Sisimai
121
122
  ],
122
123
  %r/undeliver/i => [
123
124
  'Sisimai::MTA::Postfix',
124
- 'Sisimai::MTA::Exchange',
125
+ 'Sisimai::MTA::Exchange2007',
126
+ 'Sisimai::MTA::Exchange2003',
125
127
  'Sisimai::MTA::Notes',
126
128
  'Sisimai::MSP::US::Office365',
127
129
  'Sisimai::MSP::US::Verizon',
data/lib/sisimai/smtp.rb CHANGED
@@ -10,6 +10,7 @@ module Sisimai
10
10
  # false: Hard bounce
11
11
  # nil: May not be bounce ?
12
12
  def is_softbounce(argv1 = '')
13
+ warn sprintf(" ***warning: Obsoleted method, use Sisimai::SMTP::Error.soft_or_hard() instead.");
13
14
  return nil unless argv1
14
15
  return nil unless argv1.size > 0
15
16
 
@@ -0,0 +1,149 @@
1
+ module Sisimai
2
+ module SMTP
3
+ # Sisimai::SMTP::Error is utilities for checking SMTP Errors from error
4
+ # message text.
5
+ module Error
6
+ # Imported from p5-Sisimail/lib/Sisimai/SMTP/Error.pm
7
+ class << self
8
+ require 'sisimai/smtp/reply'
9
+ require 'sisimai/smtp/status'
10
+
11
+ SoftOrHard = {
12
+ :soft => [
13
+ 'blocked', 'contenterror', 'exceedlimit', 'expired', 'filtered',
14
+ 'mailboxfull', 'mailererror', 'mesgtoobig', 'networkerror', 'norelaying',
15
+ 'rejected', 'securityerror', 'spamdetected', 'suspend', 'syntaxerror',
16
+ 'systemerror', 'systemfull', 'toomanyconn',
17
+ ],
18
+ :hard => ['hasmoved', 'hostunknown', 'userunknown']
19
+ }
20
+
21
+ # Permanent error or not
22
+ # @param [String] argv1 String including SMTP Status code
23
+ # @return [Boolean] true: Permanet error
24
+ # false: Temporary error
25
+ # nil: is not an error
26
+ # @since v4.17.3
27
+ def is_permanent(argv1 = '')
28
+ return nil unless argv1
29
+ return nil unless argv1.size > 0
30
+
31
+ statuscode = nil
32
+ classvalue = nil
33
+ getchecked = nil
34
+
35
+ statuscode = Sisimai::SMTP::Status.find(argv1)
36
+ statuscode = Sisimai::SMTP::Reply.find(argv1) if statuscode.empty?
37
+ classvalue = statuscode[0, 1].to_i
38
+
39
+ if classvalue > 0
40
+ # 2, 4, or 5
41
+ if classvalue == 5
42
+ # Permanent error
43
+ getchecked = true
44
+
45
+ elsif classvalue == 4
46
+ # Temporary error
47
+ getchecked = false
48
+
49
+ elsif classvalue == 2
50
+ # Succeeded
51
+ getchecked = nil
52
+ end
53
+ else
54
+ # Check with regular expression
55
+ if argv1 =~ /(?:temporar|persistent)/i
56
+ # Temporary failure
57
+ getchecked = false
58
+
59
+ elsif argv1 =~ /permanent/i
60
+ # Permanently failure
61
+ getchecked = true
62
+
63
+ else
64
+ # did not find information to decide that it is a soft bounce
65
+ # or a hard bounce.
66
+ getchecked = nil
67
+ end
68
+ end
69
+
70
+ return getchecked
71
+ end
72
+
73
+ # Check softbounce or not
74
+ # @param [String] argv1 Detected bounce reason
75
+ # @param [String] argv2 String including SMTP Status code
76
+ # @return [String] 'soft': Soft bounce
77
+ # 'hard': Hard bounce
78
+ # '': May not be bounce ?
79
+ # @since v4.17.3
80
+ def soft_or_hard(argv1 = '', argv2 = '')
81
+ return '' if argv1.empty?
82
+
83
+ getchecked = nil
84
+ statuscode = nil
85
+ classvalue = nil
86
+ softorhard = nil
87
+
88
+ if argv1 =~ /\A(?:delivered|feedback|vacation)\z/
89
+ # These are not dealt as a bounce reason
90
+ softorhard = ''
91
+
92
+ elsif argv1 == 'onhold' || argv1 == 'undefined'
93
+ # Check with the value of D.S.N. in $argv2
94
+ getchecked = Sisimai::SMTP::Error.is_permanent(argv2)
95
+
96
+ if getchecked.nil?
97
+ # The value is not defined (returned undef)
98
+ softorhard = ''
99
+ else
100
+ # The value is 0 or 1
101
+ softorhard = getchecked == 1 ? 'hard' : 'soft'
102
+ end
103
+ elsif argv1 == 'notaccept'
104
+ # NotAccept: 5xx => hard bounce, 4xx => soft bounce
105
+ if argv2.size > 0
106
+ # Get D.S.N. or SMTP reply code from The 2nd argument string
107
+ statuscode = Sisimai::SMTP::Status.find(argv2)
108
+ statuscode = Sisimai::SMTP::Reply.find(argv1) if statuscode.empty?
109
+ classvalue = statuscode[0, 1].to_i
110
+
111
+ if classvalue == 4
112
+ # Deal as a "soft bounce"
113
+ softorhard = 'soft'
114
+ else
115
+ # 5 or 0, deal as a "hard bounce"
116
+ softorhard = 'hard'
117
+ end
118
+ else
119
+ # "notaccept" is a hard bounce
120
+ softorhard = 'hard'
121
+ end
122
+ else
123
+ # Check all the reasons defined at the above
124
+ catch :SOFT_OR_HARD do
125
+ loop do
126
+ [:hard, :soft].each do |e|
127
+ # Soft or Hard?
128
+ SoftOrHard[e].each do |f|
129
+ # Hard bounce?
130
+ next unless argv1 == f
131
+ softorhard = e.to_s
132
+ throw :SOFT_OR_HARD
133
+ end
134
+ end
135
+
136
+ break
137
+ end
138
+ end
139
+ end
140
+
141
+ sortorhard = '' if softorhard.nil?
142
+ return softorhard
143
+ end
144
+
145
+ end
146
+ end
147
+ end
148
+ end
149
+
@@ -70,6 +70,20 @@ module Sisimai
70
70
  return '' unless argv1.size > 0
71
71
  return '' if argv1 =~ /X-Unix;/i
72
72
 
73
+ ip4re = %r{\b
74
+ (?:\d|[01]?\d\d|2[0-4]\d|25[0-5])[.]
75
+ (?:\d|[01]?\d\d|2[0-4]\d|25[0-5])[.]
76
+ (?:\d|[01]?\d\d|2[0-4]\d|25[0-5])[.]
77
+ (?:\d|[01]?\d\d|2[0-4]\d|25[0-5])
78
+ \b}x;
79
+
80
+ if argv1 =~ ip4re
81
+ # Convert found IPv4 addresses to '***.***.***.***' to avoid that
82
+ # the following code detects an octet of the IPv4 adress as an SMTP
83
+ # reply code.
84
+ argv1 = argv1.gsub(/#{ip4re}/, '***.***.***.***')
85
+ end
86
+
73
87
  if cv = argv1.match(/\b([45][0-5][0-9])\b/) || argv1.match(/\b(25[0-3])\b/)
74
88
  # 550, 447, or 250
75
89
  return cv[1]
@@ -1,4 +1,4 @@
1
1
  # Define the version number of Sisimai
2
2
  module Sisimai
3
- VERSION = '4.17.2'
3
+ VERSION = '4.18.0'
4
4
  end
@@ -11,12 +11,18 @@ Sisimai::ARF
11
11
  * [fbl-hotmail.txt](https://github.com/prasad83/node-bounce-handler/blob/master/eml/fbl-hotmail.txt)
12
12
  * Copyright (c) 2014 prasad83 | The MIT License
13
13
 
14
- Sisimai::MTA::Exchange
15
- ----------------------
14
+ Sisimai::MTA::Exchange2003
15
+ --------------------------
16
16
  * exchange-06.eml
17
17
  * mailman-2.1.15/tests/bounces/groupwise_01.txt
18
18
  * Copyright (C) 1989, 1991 Free Software Foundation, Inc. | GPLv2
19
19
 
20
+ Sisimai::MTA::Exchange2007
21
+ --------------------------
22
+ * exchange2007-02.eml
23
+ * [message-too-large.msg](https://github.com/rjbs/Mail-DeliveryStatus-BounceParser/blob/master/t/corpus/message-too-large.msg)
24
+ * Copyright (C) 2003-2006 IC Group, Inc. | GPLv2
25
+
20
26
  Sisimai::MTA::Exim
21
27
  ------------------
22
28
  * exim-09.eml
@@ -0,0 +1,151 @@
1
+ Return-Path: <>
2
+ X-Original-To: kijitora@example.jp
3
+ Delivered-To: kijitora@example.jp
4
+ Received: from localhost (localhost [127.0.0.1])
5
+ by example.jp.localdomain (Postfix) with ESMTP id FFFF0000FFFF
6
+ for <kijitora@example.jp>; Thu, 22 Feb 2011 23:34:45 +0900 (JST)
7
+ Received: from example.jp.localdomain ([127.0.0.1])
8
+ by localhost (example.jp [127.0.0.1]) (amavisd-new, port 10024)
9
+ with ESMTP id ffff00ee for <kijitora@example.jp>;
10
+ Thu, 22 Feb 2011 23:34:45 +0900 (JST)
11
+ MIME-Version: 1.0
12
+ From: mailer-daemon@example.com
13
+ To: kijitora@example.jp
14
+ Date: Thu, 22 Feb 2011 23:34:45 +0900
15
+ Content-Type: multipart/report; report-type=delivery-status;
16
+ boundary="0000ffff-0000-0000-0000-0000"
17
+ Content-Language: en-US
18
+ Message-ID: <000000000000000000000000000000000000000000000000@example.com>
19
+ Subject: Undeliverable: Nyaan
20
+
21
+ --0000ffff-0000-0000-0000-0000
22
+ Content-Type: multipart/alternative; differences=Content-Type;
23
+ boundary="eeee0000-0022-2200-2220"
24
+
25
+ --eeee0000-0022-2200-2220
26
+ Content-Type: text/plain; charset="us-ascii"
27
+ Content-Transfer-Encoding: quoted-printable
28
+
29
+ Delivery has failed to these recipients or distribution lists:
30
+
31
+ Neko<mailto:mikeneko@example.co.jp>
32
+ The recipient's e-mail address was not found in the recipient's e-mail syst=
33
+ em. Microsoft Exchange will not try to redeliver this message for you. Plea=
34
+ se check the e-mail address and try resending this message, or provide the =
35
+ following diagnostic text to your system administrator.
36
+
37
+ ________________________________
38
+ Sent by Microsoft Exchange Server 2007
39
+
40
+
41
+
42
+
43
+
44
+
45
+ Diagnostic information for administrators:
46
+
47
+ Generating server: mta4.example.org
48
+
49
+ mikeneko@example.co.jp
50
+ #550 5.1.1 RESOLVER.ADR.RecipNotFound; not found ##
51
+
52
+ Original message headers:
53
+
54
+ Received: from mx9.example.net (172.21.25.141) by SMTP2.TCAABUDHABI.AE
55
+ (172.21.24.13) with Microsoft SMTP Server id 8.2.234.1; Thu, 22 Feb 2011
56
+ 23:34:45 +0900
57
+ Date: Thu, 22 Feb 2011 23:34:45 +0900
58
+ Subject: Nyaan
59
+ From: Kijitora <kijitora@example.jp>
60
+ To: Neko <mikeneko@example.co.jp>
61
+ MIME-Version: 1.0
62
+ Content-Type: text/plain;
63
+
64
+ --eeee0000-0022-2200-2220
65
+ Content-Type: text/html; charset="us-ascii"
66
+ Content-Transfer-Encoding: quoted-printable
67
+
68
+ <html>
69
+ <Head></head><body>
70
+ <p><b><font color=3D"#000066" size=3D"3" face=3D"Arial">Delivery has failed=
71
+ to these recipients or distribution lists:</font></b></p>
72
+ <font color=3D"#000000" size=3D"2" face=3D"Tahoma"><p><a href=3D"mailto:mik=
73
+ eneko@example.co.jp">Neko</a><br>
74
+ The recipient's e-mail address was not found in the recipient's e-mail syst=
75
+ em. Microsoft Exchange will not try to redeliver this message for you. Plea=
76
+ se check the e-mail address and try resending this message, or provide the =
77
+ following diagnostic text to your system administrator.</p>
78
+ </font>
79
+ <HR/><font color=3D"#808080" size=3D"1" face=3D"Arial">Sent by Microsoft Ex=
80
+ change Server 2007</font>
81
+ <br><br><br><br><br><br>
82
+ <font color=3D"#808080" size=3D"2" face=3D"Tahoma"><p><b>Diagnostic informa=
83
+ tion for administrators:</b></p>
84
+ <p>Generating server: mx4.example.org</p>
85
+ <p>mikeneko@example.co.jp<br>
86
+ #550 5.1.1 RESOLVER.ADR.RecipNotFound; not found ##</p>
87
+ <p>Original message headers:</p>
88
+ <pre>Received: from mx9.example.net (192.0.2.229) by mx5.example.net
89
+ (192.0.2.225) with Microsoft SMTP Server id 8.2.222.2; Thu, 22 Feb 2011
90
+ 23:34:45 +0900
91
+ Date: Thu, 22 Feb 2011 23:34:45 +0900
92
+ Subject: Nyaan
93
+ From: Kijitora &lt;kijitora@example.jp&gt;
94
+ To: Neko &lt;mikeneko@example.co.jp&gt;
95
+ MIME-Version: 1.0
96
+ Content-Type: multipart/alternative;
97
+ boundary=3D&quot;_=3Dneko00022222002202020=3D_&quot;
98
+ </pre>
99
+ </font>
100
+ </body>
101
+ </html>=
102
+
103
+ --eeee0000-0022-2200-2220--
104
+
105
+ --0000ffff-0000-0000-0000-0000
106
+ Content-Type: message/delivery-status
107
+
108
+ Reporting-MTA: dns;mx4.example.org
109
+ Received-From-MTA: dns;mx9.example.net
110
+ Arrival-Date: Thu, 22 Feb 2011 23:34:45 +0900
111
+
112
+ Final-Recipient: rfc822;mikeneko@example.co.jp
113
+ Action: failed
114
+ Status: 5.1.1
115
+ Diagnostic-Code: smtp;550 5.1.1 RESOLVER.ADR.RecipNotFound; not found
116
+ X-Display-Name: Neko
117
+
118
+
119
+ --0000ffff-0000-0000-0000-0000
120
+ Content-Type: message/rfc822
121
+
122
+ Received: from mx9.example.net (192.0.2.229) by mx8.example.net
123
+ (192.0.2.228) with Microsoft SMTP Server id 8.2.222.2; Thu, 22 Feb 2011
124
+ 23:34:45 +0900
125
+ Date: Thu, 22 Feb 2011 23:34:45 +0900
126
+ Subject: Nyaan
127
+ From: Kijitora <kijitora@example.jp>
128
+ To: Neko <mikeneko@example.co.jp>
129
+ MIME-Version: 1.0
130
+ Content-Type: multipart/alternative;
131
+ boundary="_=neko00022222002202020=_"
132
+
133
+ --_=neko00022222002202020=_
134
+ Content-Type: text/plain; charset="utf-8"
135
+ Content-Transfer-Encoding: quoted-printable
136
+
137
+ Nyaan
138
+
139
+ --_=neko00022222002202020=_
140
+ Content-Type: text/html; charset="utf-8"
141
+ Content-Transfer-Encoding: quoted-printable
142
+
143
+ <html><body><head></head>
144
+ Nyaan
145
+ </body>
146
+ </html>
147
+
148
+ --_=neko00022222002202020=_--
149
+
150
+ --0000ffff-0000-0000-0000-0000--
151
+