sisimai 5.2.1-java → 5.4.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.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake-test.yml +1 -1
  3. data/ChangeLog.md +24 -0
  4. data/Makefile +3 -2
  5. data/README-JA.md +4 -4
  6. data/README.md +8 -8
  7. data/lib/sisimai/address.rb +45 -56
  8. data/lib/sisimai/arf.rb +11 -16
  9. data/lib/sisimai/datetime.rb +16 -50
  10. data/lib/sisimai/fact/json.rb +5 -5
  11. data/lib/sisimai/fact/yaml.rb +3 -3
  12. data/lib/sisimai/fact.rb +21 -12
  13. data/lib/sisimai/lda.rb +3 -3
  14. data/lib/sisimai/lhost/activehunter.rb +4 -6
  15. data/lib/sisimai/lhost/amazonses.rb +5 -6
  16. data/lib/sisimai/lhost/apachejames.rb +7 -9
  17. data/lib/sisimai/lhost/biglobe.rb +3 -5
  18. data/lib/sisimai/lhost/courier.rb +4 -6
  19. data/lib/sisimai/lhost/domino.rb +4 -5
  20. data/lib/sisimai/lhost/dragonfly.rb +3 -5
  21. data/lib/sisimai/lhost/einsundeins.rb +6 -8
  22. data/lib/sisimai/lhost/exchange2003.rb +10 -12
  23. data/lib/sisimai/lhost/exchange2007.rb +4 -5
  24. data/lib/sisimai/lhost/exim.rb +6 -8
  25. data/lib/sisimai/lhost/ezweb.rb +10 -12
  26. data/lib/sisimai/lhost/fml.rb +2 -3
  27. data/lib/sisimai/lhost/gmail.rb +4 -6
  28. data/lib/sisimai/lhost/gmx.rb +6 -8
  29. data/lib/sisimai/lhost/googlegroups.rb +1 -2
  30. data/lib/sisimai/lhost/googleworkspace.rb +3 -4
  31. data/lib/sisimai/lhost/imailserver.rb +6 -7
  32. data/lib/sisimai/lhost/interscanmss.rb +1 -2
  33. data/lib/sisimai/lhost/kddi.rb +5 -8
  34. data/lib/sisimai/lhost/mailfoundry.rb +4 -7
  35. data/lib/sisimai/lhost/mailmarshalsmtp.rb +4 -6
  36. data/lib/sisimai/lhost/messagingserver.rb +5 -7
  37. data/lib/sisimai/lhost/mfilter.rb +4 -6
  38. data/lib/sisimai/lhost/notes.rb +7 -9
  39. data/lib/sisimai/lhost/opensmtpd.rb +2 -4
  40. data/lib/sisimai/lhost/postfix.rb +8 -11
  41. data/lib/sisimai/lhost/qmail.rb +5 -8
  42. data/lib/sisimai/lhost/sendmail.rb +7 -10
  43. data/lib/sisimai/lhost/v5sendmail.rb +15 -17
  44. data/lib/sisimai/lhost/verizon.rb +9 -14
  45. data/lib/sisimai/lhost/x1.rb +4 -6
  46. data/lib/sisimai/lhost/x2.rb +5 -7
  47. data/lib/sisimai/lhost/x3.rb +3 -4
  48. data/lib/sisimai/lhost/x6.rb +4 -6
  49. data/lib/sisimai/lhost/zoho.rb +6 -8
  50. data/lib/sisimai/lhost.rb +1 -1
  51. data/lib/sisimai/mail/mbox.rb +1 -1
  52. data/lib/sisimai/mail/memory.rb +1 -1
  53. data/lib/sisimai/mail.rb +8 -8
  54. data/lib/sisimai/message.rb +11 -13
  55. data/lib/sisimai/order.rb +12 -11
  56. data/lib/sisimai/reason/authfailure.rb +10 -10
  57. data/lib/sisimai/reason/badreputation.rb +4 -6
  58. data/lib/sisimai/reason/blocked.rb +6 -8
  59. data/lib/sisimai/reason/contenterror.rb +5 -6
  60. data/lib/sisimai/reason/delivered.rb +2 -2
  61. data/lib/sisimai/reason/exceedlimit.rb +7 -8
  62. data/lib/sisimai/reason/expired.rb +6 -7
  63. data/lib/sisimai/reason/failedstarttls.rb +5 -7
  64. data/lib/sisimai/reason/feedback.rb +2 -2
  65. data/lib/sisimai/reason/filtered.rb +7 -10
  66. data/lib/sisimai/reason/hasmoved.rb +4 -5
  67. data/lib/sisimai/reason/hostunknown.rb +6 -7
  68. data/lib/sisimai/reason/mailboxfull.rb +7 -8
  69. data/lib/sisimai/reason/mailererror.rb +5 -8
  70. data/lib/sisimai/reason/mesgtoobig.rb +5 -6
  71. data/lib/sisimai/reason/networkerror.rb +5 -8
  72. data/lib/sisimai/reason/norelaying.rb +4 -5
  73. data/lib/sisimai/reason/notaccept.rb +5 -8
  74. data/lib/sisimai/reason/notcompliantrfc.rb +5 -6
  75. data/lib/sisimai/reason/onhold.rb +6 -9
  76. data/lib/sisimai/reason/policyviolation.rb +6 -9
  77. data/lib/sisimai/reason/rejected.rb +5 -6
  78. data/lib/sisimai/reason/requireptr.rb +6 -7
  79. data/lib/sisimai/reason/securityerror.rb +6 -9
  80. data/lib/sisimai/reason/spamdetected.rb +8 -9
  81. data/lib/sisimai/reason/speeding.rb +6 -7
  82. data/lib/sisimai/reason/suppressed.rb +3 -7
  83. data/lib/sisimai/reason/suspend.rb +5 -7
  84. data/lib/sisimai/reason/syntaxerror.rb +3 -5
  85. data/lib/sisimai/reason/systemerror.rb +6 -9
  86. data/lib/sisimai/reason/systemfull.rb +5 -8
  87. data/lib/sisimai/reason/toomanyconn.rb +5 -6
  88. data/lib/sisimai/reason/undefined.rb +2 -2
  89. data/lib/sisimai/reason/userunknown.rb +8 -9
  90. data/lib/sisimai/reason/vacation.rb +4 -5
  91. data/lib/sisimai/reason/virusdetected.rb +4 -5
  92. data/lib/sisimai/reason.rb +13 -13
  93. data/lib/sisimai/rfc1123.rb +4 -8
  94. data/lib/sisimai/rfc1894.rb +5 -6
  95. data/lib/sisimai/rfc2045.rb +27 -31
  96. data/lib/sisimai/rfc3464/thirdparty.rb +1 -1
  97. data/lib/sisimai/rfc3464.rb +7 -9
  98. data/lib/sisimai/rfc3834.rb +5 -9
  99. data/lib/sisimai/rfc5322.rb +8 -26
  100. data/lib/sisimai/rfc791.rb +6 -4
  101. data/lib/sisimai/rhost/google.rb +8 -0
  102. data/lib/sisimai/rhost/microsoft.rb +17 -5
  103. data/lib/sisimai/rhost.rb +2 -2
  104. data/lib/sisimai/smtp/command.rb +1 -1
  105. data/lib/sisimai/smtp/failure.rb +5 -12
  106. data/lib/sisimai/smtp/reply.rb +33 -12
  107. data/lib/sisimai/smtp/status.rb +21 -22
  108. data/lib/sisimai/smtp/transcript.rb +1 -10
  109. data/lib/sisimai/string.rb +20 -30
  110. data/lib/sisimai/version.rb +1 -1
  111. data/lib/sisimai.rb +11 -11
  112. data/set-of-emails/maildir/bsd/rhost-microsoft-06.eml +45 -0
  113. metadata +8 -10
@@ -7,8 +7,8 @@ module Sisimai::Lhost
7
7
 
8
8
  Indicators = Sisimai::Lhost.INDICATORS
9
9
  Boundaries = ['Received: from mail.zoho.com by mx.zohomail.com'].freeze
10
- StartingOf = { message: ['This message was created automatically by mail delivery'] }.freeze
11
- MessagesOf = { 'expired' => ['Host not reachable'] }.freeze
10
+ StartingOf = {message: ['This message was created automatically by mail delivery']}.freeze
11
+ MessagesOf = {'expired' => ['Host not reachable']}.freeze
12
12
 
13
13
  # @abstract Decodes the bounce message from Zoho Mail
14
14
  # @param [Hash] mhead Message headers of a bounce email
@@ -21,13 +21,12 @@ module Sisimai::Lhost
21
21
  # X-Mailer: Zoho Mail
22
22
  return nil unless mhead['x-zohomail']
23
23
 
24
- dscontents = [Sisimai::Lhost.DELIVERYSTATUS]
24
+ dscontents = [Sisimai::Lhost.DELIVERYSTATUS]; v = nil
25
25
  emailparts = Sisimai::RFC5322.part(mbody, Boundaries)
26
26
  bodyslices = emailparts[0].split("\n")
27
27
  readcursor = 0 # (Integer) Points the current cursor position
28
28
  recipients = 0 # (Integer) The number of 'Final-Recipient' header
29
29
  qprintable = false
30
- v = nil
31
30
 
32
31
  while e = bodyslices.shift do
33
32
  # Read error messages and delivery status lines from the head of the email to the previous
@@ -37,8 +36,7 @@ module Sisimai::Lhost
37
36
  readcursor |= Indicators[:deliverystatus] if e.start_with?(StartingOf[:message][0])
38
37
  next
39
38
  end
40
- next if (readcursor & Indicators[:deliverystatus]) == 0
41
- next if e.empty?
39
+ next if (readcursor & Indicators[:deliverystatus]) == 0 || e.empty?
42
40
 
43
41
  # This message was created automatically by mail delivery software.
44
42
  # A message that you sent could not be delivered to one or more of its recip=
@@ -86,7 +84,7 @@ module Sisimai::Lhost
86
84
  else
87
85
  # Continued line
88
86
  next unless qprintable
89
- v['diagnosis'] << e
87
+ v['diagnosis'] += e
90
88
  end
91
89
  end
92
90
  return nil unless recipients > 0
@@ -101,7 +99,7 @@ module Sisimai::Lhost
101
99
  end
102
100
  end
103
101
 
104
- return { 'ds' => dscontents, 'rfc822' => emailparts[1] }
102
+ return {"ds" => dscontents, "rfc822" => emailparts[1]}
105
103
  end
106
104
  def description; return 'Zoho Mail: https://www.zoho.com'; end
107
105
  end
data/lib/sisimai/lhost.rb CHANGED
@@ -57,7 +57,7 @@ module Sisimai
57
57
  'Sisimai::RFC3464' => 'sisimai/rfc3464',
58
58
  'Sisimai::RFC3834' => 'sisimai/rfc3834',
59
59
  }
60
- index.each { |e| table['Sisimai::Lhost::' << e] = 'sisimai/lhost/' << e.downcase }
60
+ index.each { |e| table["Sisimai::Lhost::#{e}"] = "sisimai/lhost/#{e.downcase}" }
61
61
  return table
62
62
  end
63
63
 
@@ -47,7 +47,7 @@ module Sisimai
47
47
  frombuffer = r
48
48
  break
49
49
  end
50
- readbuffer << r
50
+ readbuffer += r
51
51
  end
52
52
 
53
53
  seekoffset = filehandle.pos - frombuffer.bytesize
@@ -24,7 +24,7 @@ module Sisimai
24
24
 
25
25
  if argv1.start_with?('From ')
26
26
  # UNIX mbox
27
- @payload = argv1.split(/^From /).map! { |e| e = 'From ' + e }
27
+ @payload = argv1.scrub().split(/^From /).map! { |e| e = 'From ' + e }
28
28
  @payload.shift
29
29
  else
30
30
  @payload = [argv1]
data/lib/sisimai/mail.rb CHANGED
@@ -13,13 +13,13 @@ module Sisimai
13
13
  # @return [Sisimai::Mail, Nil] Object or nil if the argument was wrong
14
14
  def initialize(argv1)
15
15
  classname = nil
16
- parameter = { 'path' => argv1, 'kind' => nil, 'data' => nil }
16
+ parameter = {'path' => argv1, 'kind' => nil, 'data' => nil}
17
17
 
18
18
  if argv1.is_a?(::String)
19
19
  # Path to mail or '<STDIN>' ?
20
20
  if argv1 == '<STDIN>'
21
21
  # Sisimai::Mail.new('<STDIN>')
22
- classname = self.class.to_s << '::STDIN'
22
+ classname = "#{self.class.to_s}::STDIN"
23
23
  parameter['kind'] = 'stdin'
24
24
  parameter['path'] = '<STDIN>'
25
25
  else
@@ -28,24 +28,24 @@ module Sisimai
28
28
 
29
29
  if mediatype == 'file'
30
30
  # The argument is a file, it is an mbox or email file in Maildir/
31
- classname = self.class.to_s << '::Mbox'
31
+ classname = "#{self.class.to_s}::Mbox"
32
32
  parameter['kind'] = 'mailbox'
33
33
 
34
34
  elsif mediatype == 'directory'
35
- # The agument is not a file, it is a Maildir/
36
- classname = self.class.to_s << '::Maildir'
35
+ # The agument is not a file, it is a Maildij/
36
+ classname = "#{self.class.to_s}::Maildir"
37
37
  parameter['kind'] = 'maildir'
38
38
 
39
39
  elsif mediatype == 'memory'
40
40
  # The argument is an email string
41
- classname = self.class.to_s << '::Memory'
41
+ classname = "#{self.class.to_s}::Memory"
42
42
  parameter['kind'] = 'memory'
43
43
  parameter['path'] = 'MEMORY'
44
44
  end
45
45
  end
46
46
  elsif argv1.is_a?(IO)
47
47
  # Read from STDIN, The argument neither a mailbox nor a Maildir/.
48
- classname = self.class.to_s << '::STDIN'
48
+ classname = "#{self.class.to_s}::STDIN"
49
49
  parameter['kind'] = 'stdin'
50
50
  parameter['path'] = '<STDIN>'
51
51
  end
@@ -63,7 +63,7 @@ module Sisimai
63
63
  # Alias method of Sisimai::Mail.data.read()
64
64
  # @return [String] Contents of mbox/Maildir
65
65
  def read
66
- return nil unless data
66
+ return "" if data.nil?
67
67
  return data.read
68
68
  end
69
69
 
@@ -37,7 +37,7 @@ module Sisimai
37
37
  def rise(**argvs)
38
38
  return nil unless argvs
39
39
  email = argvs[:data].scrub('?').gsub("\r\n", "\n")
40
- thing = { 'from' => '','header' => {}, 'rfc822' => '', 'ds' => [], 'catch' => nil }
40
+ thing = {'from' => '','header' => {}, 'rfc822' => '', 'ds' => [], 'catch' => nil}
41
41
  param = {}
42
42
 
43
43
  aftersplit = nil
@@ -98,8 +98,6 @@ module Sisimai
98
98
  return thing
99
99
  end
100
100
 
101
- def load(argvs); ' ***warning: Sisimai::Message.load will be removed at v5.3.0'; return []; end
102
-
103
101
  # Divide email data up headers and a body part.
104
102
  # @param [String] email Email data
105
103
  # @return [Array] Email data after split
@@ -121,7 +119,7 @@ module Sisimai
121
119
  # Set pseudo UNIX From line
122
120
  parts[0] = 'MAILER-DAEMON Tue Feb 11 00:00:00 2014'
123
121
  end
124
- parts[1] << "\n" unless parts[1].end_with?("\n")
122
+ parts[1] += "\n" unless parts[1].end_with?("\n")
125
123
 
126
124
  %w[image/ application/ text/html].each do |e|
127
125
  # https://github.com/sisimai/p5-sisimai/issues/492, Reduce email size
@@ -130,12 +128,12 @@ module Sisimai
130
128
  ep = e == 'text/html' ? '</html>' : "--\n"
131
129
  while true
132
130
  # Remove each part from "Content-Type: image/..." to "--\n" (the end of each boundary)
133
- p0 = parts[2].index('Content-Type: ' + e, p0); break unless p0
131
+ p0 = parts[2].index("Content-Type: #{e}", p0); break unless p0
134
132
  p1 = parts[2].index(ep, p0 + 32); break unless p1
135
133
  parts[2][p0, p1 - p0] = ''
136
134
  end
137
135
  end
138
- parts[2] << "\n"
136
+ parts[2] += "\n"
139
137
  return parts
140
138
  end
141
139
 
@@ -150,11 +148,11 @@ module Sisimai
150
148
 
151
149
  # Select and convert all the headers in $argv0. The following regular expression is based on
152
150
  # https://gist.github.com/xtetsuji/b080e1f5551d17242f6415aba8a00239
153
- headermaps = { 'subject' => '' }
151
+ headermaps = {'subject' => ''}
154
152
  receivedby = []
155
153
  argv0.scan(/^([\w-]+):[ ]*(.*?)\n(?!\s)/m) { |e| headermaps[e[0].downcase] = e[1] }
156
154
  headermaps.delete('received')
157
- headermaps.each_key { |e| headermaps[e].gsub!(/\n\s+/, ' ') }
155
+ headermaps.each_key { |e| headermaps[e] = headermaps[e].gsub(/\n\s+/, ' ') }
158
156
 
159
157
  if argv0.include?('Received:')
160
158
  # Capture values of each Received: header
@@ -217,7 +215,7 @@ module Sisimai
217
215
  index += 1
218
216
  if fn == ''
219
217
  # There is neither ":" character nor the field listed in $FieldTable
220
- email << e + "\n"
218
+ email += "#{e}\n"
221
219
  next
222
220
  end
223
221
 
@@ -295,10 +293,10 @@ module Sisimai
295
293
 
296
294
  # 4. Remove redundant space characters
297
295
  bf = bf.squeeze(' ').strip
298
- email << sprintf("%s: %s\n", fn, bf)
296
+ email += sprintf("%s: %s\n", fn, bf)
299
297
  end
300
298
 
301
- email << "\n" unless email.end_with?("\n\n")
299
+ email += "\n" unless email.end_with?("\n\n")
302
300
  return email
303
301
  end
304
302
 
@@ -363,10 +361,10 @@ module Sisimai
363
361
  if hookmethod.is_a? Proc
364
362
  # Call the hook method
365
363
  begin
366
- p = { 'headers' => mailheader, 'message' => bodystring }
364
+ p = {'headers' => mailheader, 'message' => bodystring}
367
365
  havecaught = hookmethod.call(p)
368
366
  rescue StandardError => ce
369
- warn ' ***warning: Something is wrong in hook method ":hook":' << ce.to_s
367
+ warn ' ***warning: Something is wrong in hook method ":hook":' + ce.to_s
370
368
  end
371
369
  end
372
370
 
data/lib/sisimai/order.rb CHANGED
@@ -11,38 +11,39 @@ module Sisimai
11
11
  'Sisimai::Lhost::Sendmail',
12
12
  'Sisimai::Lhost::Exchange2007',
13
13
  'Sisimai::Lhost::Exchange2003',
14
- 'Sisimai::Lhost::AmazonSES',
15
14
  'Sisimai::Lhost::InterScanMSS',
16
15
  'Sisimai::Lhost::KDDI',
16
+ 'Sisimai::Lhost::FML',
17
17
  'Sisimai::Lhost::Verizon',
18
+ 'Sisimai::Lhost::AmazonSES',
18
19
  'Sisimai::Lhost::ApacheJames',
19
20
  'Sisimai::Lhost::X2',
20
- 'Sisimai::Lhost::FML',
21
21
  ].freeze
22
22
 
23
23
  # Fallback list: The following MTA/ESP modules is not listed OrderE0
24
24
  OrderE1 = [
25
25
  'Sisimai::Lhost::Postfix',
26
26
  'Sisimai::Lhost::OpenSMTPD',
27
- 'Sisimai::Lhost::Courier',
28
27
  'Sisimai::Lhost::Qmail',
28
+ 'Sisimai::Lhost::Courier',
29
29
  'Sisimai::Lhost::MessagingServer',
30
- 'Sisimai::Lhost::MailMarshalSMTP',
31
30
  'Sisimai::Lhost::GoogleWorkspace',
32
- 'Sisimai::Lhost::Domino',
33
- 'Sisimai::Lhost::Notes',
34
31
  'Sisimai::Lhost::Gmail',
35
- 'Sisimai::Lhost::Zoho',
36
32
  'Sisimai::Lhost::GMX',
37
- 'Sisimai::Lhost::GoogleGroups',
38
- 'Sisimai::Lhost::MailFoundry',
39
- 'Sisimai::Lhost::V5sendmail',
33
+ 'Sisimai::Lhost::Zoho',
34
+ 'Sisimai::Lhost::Domino',
35
+ 'Sisimai::Lhost::Notes',
40
36
  'Sisimai::Lhost::IMailServer',
41
- 'Sisimai::Lhost::MFILTER',
42
37
  'Sisimai::Lhost::Activehunter',
38
+ 'Sisimai::Lhost::MFILTER',
39
+ 'Sisimai::Lhost::MailFoundry',
40
+ 'Sisimai::Lhost::GoogleGroups',
41
+ 'Sisimai::Lhost::MailMarshalSMTP',
42
+ 'Sisimai::Lhost::V5sendmail',
43
43
  'Sisimai::Lhost::EZweb',
44
44
  'Sisimai::Lhost::Biglobe',
45
45
  'Sisimai::Lhost::EinsUndEins',
46
+ 'Sisimai::Lhost::DragonFly',
46
47
  'Sisimai::Lhost::X1',
47
48
  'Sisimai::Lhost::X3',
48
49
  'Sisimai::Lhost::X6',
@@ -18,11 +18,13 @@ module Sisimai
18
18
  '//spf.pobox.com',
19
19
  'bad spf records for',
20
20
  'dmarc policy',
21
+ "doesn't meet the required authentication level",
21
22
  'please inspect your spf settings',
22
23
  'sender policy framework (spf) fail',
23
24
  'sender policy framework violation',
24
25
  'spf (sender policy framework) domain authentication fail',
25
26
  'spf check: fail',
27
+ "the 5322.From address doesn't meet the authentication requirements defined for the sender",
26
28
  ].freeze
27
29
  Pairs = [
28
30
  [' is not allowed to send mail.', '_401'],
@@ -34,24 +36,22 @@ module Sisimai
34
36
 
35
37
  # Try to match that the given text and regular expressions
36
38
  # @param [String] argv1 String to be matched with regular expressions
37
- # @return [True,False] false: Did not match
38
- # true: Matched
39
+ # @return [Boolean] false: Did not match, true: Matched
39
40
  def match(argv1)
40
- return nil unless argv1
41
- return true if Index.any? { |a| argv1.include?(a) }
42
- return true if Pairs.any? { |a| Sisimai::String.aligned(argv1, a) }
41
+ return false unless argv1
42
+ return true if Index.any? { |a| argv1.include?(a) }
43
+ return true if Pairs.any? { |a| Sisimai::String.aligned(argv1, a) }
43
44
  return false
44
45
  end
45
46
 
46
47
  # The bounce reason is "authfailure" or not
47
48
  # @param [Sisimai::Fact] argvs Object to be detected the reason
48
- # @return [True,False] true: is AuthFailure
49
- # false: is not AuthFailure
49
+ # @return [Boolean] true: is AuthFailure, false: is not AuthFailure
50
50
  # @see http://www.ietf.org/rfc/rfc2822.txt
51
51
  def true(argvs)
52
- return nil if argvs['deliverystatus'].empty?
53
- return true if argvs['reason'] == 'authfailure'
54
- return true if Sisimai::SMTP::Status.name(argvs['deliverystatus']).to_s == 'authfailure'
52
+ return false if argvs['deliverystatus'].empty?
53
+ return true if argvs['reason'] == 'authfailure'
54
+ return true if Sisimai::SMTP::Status.name(argvs['deliverystatus']) == 'authfailure'
55
55
  return match(argvs['diagnosticcode'].downcase)
56
56
  end
57
57
 
@@ -28,18 +28,16 @@ module Sisimai
28
28
 
29
29
  # Try to match that the given text and regular expressions
30
30
  # @param [String] argv1 String to be matched with regular expressions
31
- # @return [True,False] false: Did not match
32
- # true: Matched
31
+ # @return [Boolean] false: Did not match, true: Matched
33
32
  def match(argv1)
34
- return nil unless argv1
35
- return true if Index.any? { |a| argv1.include?(a) }
33
+ return false unless argv1
34
+ return true if Index.any? { |a| argv1.include?(a) }
36
35
  return false
37
36
  end
38
37
 
39
38
  # The bounce reason is "badreputation" or not
40
39
  # @param [Sisimai::Fact] argvs Object to be detected the reason
41
- # @return [True,False] true: is BadReputation
42
- # false: is not BadReputation
40
+ # @return [Boolean] true: is BadReputation, false: is not BadReputation
43
41
  # @see http://www.ietf.org/rfc/rfc2822.txt
44
42
  def true(argvs)
45
43
  return true if argvs['reason'] == 'badreputation'
@@ -100,23 +100,21 @@ module Sisimai
100
100
 
101
101
  # Try to match that the given text and regular expressions
102
102
  # @param [String] argv1 String to be matched with regular expressions
103
- # @return [True,False] false: Did not match
104
- # true: Matched
103
+ # @return [Boolean] false: Did not match, true: Matched
105
104
  def match(argv1)
106
- return nil unless argv1
107
- return true if Index.any? { |a| argv1.include?(a) }
108
- return true if Pairs.any? { |a| Sisimai::String.aligned(argv1, a) }
105
+ return false unless argv1
106
+ return true if Index.any? { |a| argv1.include?(a) }
107
+ return true if Pairs.any? { |a| Sisimai::String.aligned(argv1, a) }
109
108
  return false
110
109
  end
111
110
 
112
111
  # Blocked due to client IP address or hostname
113
112
  # @param [Hash] argvs Hash to be detected the value of reason
114
- # @return [true,false] true: is blocked
115
- # false: is not blocked by the client
113
+ # @return [Boolean] true: is blocked, false: is not blocked by the client
116
114
  # @see http://www.ietf.org/rfc/rfc2822.txt
117
115
  def true(argvs)
118
116
  return true if argvs['reason'] == 'blocked'
119
- return true if Sisimai::SMTP::Status.name(argvs['deliverystatus']).to_s == 'blocked'
117
+ return true if Sisimai::SMTP::Status.name(argvs['deliverystatus']) == 'blocked'
120
118
  return match(argvs['diagnosticcode'].downcase)
121
119
  end
122
120
 
@@ -25,24 +25,23 @@ module Sisimai
25
25
 
26
26
  # Try to match that the given text and regular expressions
27
27
  # @param [String] argv1 String to be matched with regular expressions
28
- # @return [True,False] false: Did not match
29
- # true: Matched
28
+ # @return [Boolean] false: Did not match, true: Matched
30
29
  def match(argv1)
31
- return nil unless argv1
32
- return true if Index.any? { |a| argv1.include?(a) }
30
+ return false unless argv1
31
+ return true if Index.any? { |a| argv1.include?(a) }
33
32
  return false
34
33
  end
35
34
 
36
35
  # Rejected email due to header format of the email
37
36
  # @param [Sisimai::Fact] argvs Object to be detected the reason
38
- # @return [True,False] true: rejected due to content error
37
+ # @return [Boolean] true: rejected due to content error
39
38
  # false: is not content error
40
39
  # @see http://www.ietf.org/rfc/rfc2822.txt
41
40
  def true(argvs)
42
41
  require 'sisimai/reason/spamdetected'
43
42
  return true if argvs["reason"] == "blocked"
44
43
  return false if Sisimai::Reason::SpamDetected.true(argvs)
45
- return true if Sisimai::SMTP::Status.name(argvs["deliverystatus"]).to_s == "contenterror"
44
+ return true if Sisimai::SMTP::Status.name(argvs["deliverystatus"]) == "contenterror"
46
45
  return match(argvs["diagnosticcode"].downcase)
47
46
  end
48
47
 
@@ -14,8 +14,8 @@ module Sisimai
14
14
  class << self
15
15
  def text; return 'delivered'; end
16
16
  def description; return 'Email delivered successfully'; end
17
- def match; return nil; end
18
- def true(*); return nil; end
17
+ def match; return false; end
18
+ def true(*); return false; end
19
19
  end
20
20
  end
21
21
  end
@@ -17,27 +17,26 @@ module Sisimai
17
17
 
18
18
  # Try to match that the given text and regular expressions
19
19
  # @param [String] argv1 String to be matched with regular expressions
20
- # @return [True,False] false: Did not match
21
- # true: Matched
20
+ # @return [Boolean] false: Did not match, true: Matched
22
21
  def match(argv1)
23
- return nil unless argv1
24
- return true if Index.any? { |a| argv1.include?(a) }
22
+ return false unless argv1
23
+ return true if Index.any? { |a| argv1.include?(a) }
25
24
  return false
26
25
  end
27
26
 
28
27
  # Exceed limit or not
29
28
  # @param [Sisimai::Fact] argvs Object to be detected the reason
30
- # @return [True,False] true: Exceeds the limit
29
+ # @return [Boolean] true: Exceeds the limit
31
30
  # false: Did not exceed the limit
32
31
  # @see http://www.ietf.org/rfc/rfc2822.txt
33
32
  def true(argvs)
34
- return nil if argvs['deliverystatus'].empty?
35
- return true if argvs['reason'] == 'exceedlimit'
33
+ return false if argvs['deliverystatus'].empty?
34
+ return true if argvs['reason'] == 'exceedlimit'
36
35
 
37
36
  # Delivery status code points exceedlimit.
38
37
  # Status: 5.2.3
39
38
  # Diagnostic-Code: SMTP; 552 5.2.3 Message size exceeds fixed maximum message size
40
- return true if Sisimai::SMTP::Status.name(argvs['deliverystatus']).to_s == 'exceedlimit'
39
+ return true if Sisimai::SMTP::Status.name(argvs['deliverystatus']) == 'exceedlimit'
41
40
  return match(argvs['diagnosticcode'].downcase)
42
41
  end
43
42
 
@@ -40,21 +40,20 @@ module Sisimai
40
40
 
41
41
  # Try to match that the given text and regular expressions
42
42
  # @param [String] argv1 String to be matched with regular expressions
43
- # @return [True,False] false: Did not match
44
- # true: Matched
43
+ # @return [Boolean] false: Did not match, true: Matched
45
44
  def match(argv1)
46
- return nil unless argv1
47
- return true if Index.any? { |a| argv1.include?(a) }
48
- return true if Pairs.any? { |a| Sisimai::String.aligned(argv1, a) }
45
+ return false unless argv1
46
+ return true if Index.any? { |a| argv1.include?(a) }
47
+ return true if Pairs.any? { |a| Sisimai::String.aligned(argv1, a) }
49
48
  return false
50
49
  end
51
50
 
52
51
  # Delivery expired due to connection failure or network error
53
52
  # @param [Sisimai::Fact] argvs Object to be detected the reason
54
- # @return [True,False] true: is expired
53
+ # @return [Boolean] true: is expired
55
54
  # false: is not expired
56
55
  # @see http://www.ietf.org/rfc/rfc2822.txt
57
- def true(_argvs); return nil; end
56
+ def true(_argvs); return false; end
58
57
 
59
58
  end
60
59
  end
@@ -15,22 +15,20 @@ module Sisimai
15
15
 
16
16
  # Try to match that the given text and regular expressions
17
17
  # @param [String] argv1 String to be matched with regular expressions
18
- # @return [True,False] false: Did not match
19
- # true: Matched
18
+ # @return [Boolean] false: Did not match, true: Matched
20
19
  def match(argv1)
21
- return nil unless argv1
22
- return true if Index.any? { |a| argv1.include?(a) }
20
+ return false unless argv1
21
+ return true if Index.any? { |a| argv1.include?(a) }
23
22
  return false
24
23
  end
25
24
 
26
25
  # Email delivery failed due to STARTTLS related problem
27
26
  # @param [Sisimai::Fact] argvs Object to be detected the reason
28
- # @return [True,False] true: FailedSTARTTLS
27
+ # @return [Boolean] true: FailedSTARTTLS
29
28
  # false: Not FailedSTARTTLS
30
29
  # @see http://www.ietf.org/rfc/rfc2822.txt
31
30
  def true(argvs)
32
- return true if argvs["reason"] == "failedstarttls"
33
- return true if argvs["command"] == "STARTTLS"
31
+ return true if argvs["reason"] == "failedstarttls" || argvs["command"] == "STARTTLS"
34
32
  return true if [523, 524, 538].index(argvs["replycode"].to_i)
35
33
  return match(argvs["diagnosticcode"].downcase)
36
34
  end
@@ -6,8 +6,8 @@ module Sisimai
6
6
  class << self
7
7
  def text; return 'feedback'; end
8
8
  def description; return 'Email forwarded to the sender as a complaint message from your mailbox provider'; end
9
- def match; return nil; end
10
- def true(*); return nil; end
9
+ def match; return false; end
10
+ def true(*); return false; end
11
11
  end
12
12
  end
13
13
  end
@@ -33,39 +33,36 @@ module Sisimai
33
33
 
34
34
  # Try to match that the given text and regular expressions
35
35
  # @param [String] argv1 String to be matched with regular expressions
36
- # @return [True,False] false: Did not match
37
- # true: Matched
36
+ # @return [Boolean] false: Did not match, true: Matched
38
37
  def match(argv1)
39
- return nil unless argv1
40
- return true if Index.any? { |a| argv1.include?(a) }
38
+ return false unless argv1
39
+ return true if Index.any? { |a| argv1.include?(a) }
41
40
  return false
42
41
  end
43
42
 
44
43
  # Rejected by a sender domain or a sender address by a filter ?
45
44
  # @param [Sisimai::Fact] argvs Object to be detected the reason
46
- # @return [True,False] true: is filtered
45
+ # @return [Boolean] true: is filtered
47
46
  # false: is not filtered
48
47
  # @see http://www.ietf.org/rfc/rfc2822.txt
49
48
  def true(argvs)
50
49
  return true if argvs['reason'] == 'filtered'
51
50
 
52
51
  require 'sisimai/reason/userunknown'
53
- tempreason = Sisimai::SMTP::Status.name(argvs['deliverystatus']) || ''
52
+ tempreason = Sisimai::SMTP::Status.name(argvs['deliverystatus'])
54
53
  return false if tempreason == 'suspend'
55
54
 
56
55
  issuedcode = argvs['diagnosticcode'].downcase || ''
57
56
  thecommand = argvs['command'] || ''
58
57
  if tempreason == 'filtered'
59
58
  # Delivery status code points "filtered".
60
- return true if Sisimai::Reason::UserUnknown.match(issuedcode)
61
- return true if match(issuedcode)
59
+ return true if Sisimai::Reason::UserUnknown.match(issuedcode) || match(issuedcode)
62
60
  else
63
61
  # The value of "reason" isn't "filtered" when the value of "command" is an SMTP command
64
62
  # to be sent before the SMTP DATA command because all the MTAs read the headers and the
65
63
  # entire message body after the DATA command.
66
64
  return false if %w[CONN EHLO HELO MAIL RCPT].include?(thecommand)
67
- return true if match(issuedcode)
68
- return true if Sisimai::Reason::UserUnknown.match(issuedcode)
65
+ return true if match(issuedcode) || Sisimai::Reason::UserUnknown.match(issuedcode)
69
66
  end
70
67
  return false
71
68
  end
@@ -15,17 +15,16 @@ module Sisimai
15
15
 
16
16
  # Try to match that the given text and regular expressions
17
17
  # @param [String] argv1 String to be matched with regular expressions
18
- # @return [True,False] false: Did not match
19
- # true: Matched
18
+ # @return [Boolean] false: Did not match, true: Matched
20
19
  def match(argv1)
21
- return nil unless argv1
22
- return true if Index.any? { |a| argv1.include?(a) }
20
+ return false unless argv1
21
+ return true if Index.any? { |a| argv1.include?(a) }
23
22
  return false
24
23
  end
25
24
 
26
25
  # Whether the address has moved or not
27
26
  # @param [Sisimai::Fact] argvs Object to be detected the reason
28
- # @return [True,False] true: The address has moved
27
+ # @return [Boolean] true: The address has moved
29
28
  # false: Has not moved
30
29
  # @see http://www.ietf.org/rfc/rfc2822.txt
31
30
  def true(argvs)
@@ -32,19 +32,18 @@ module Sisimai
32
32
 
33
33
  # Try to match that the given text and regular expressions
34
34
  # @param [String] argv1 String to be matched with regular expressions
35
- # @return [True,False] false: Did not match
36
- # true: Matched
35
+ # @return [Boolean] false: Did not match, true: Matched
37
36
  # @since v4.0.0
38
37
  def match(argv1)
39
- return nil unless argv1
40
- return true if Index.any? { |a| argv1.include?(a) }
41
- return true if Pairs.any? { |a| Sisimai::String.aligned(argv1, a) }
38
+ return false unless argv1
39
+ return true if Index.any? { |a| argv1.include?(a) }
40
+ return true if Pairs.any? { |a| Sisimai::String.aligned(argv1, a) }
42
41
  return false
43
42
  end
44
43
 
45
44
  # Whether the host is unknown or not
46
45
  # @param [Sisimai::Fact] argvs Object to be detected the reason
47
- # @return [True,False] true: is unknown host
46
+ # @return [Boolean] true: is unknown host
48
47
  # false: is not unknown host.
49
48
  # @see http://www.ietf.org/rfc/rfc2822.txt
50
49
  def true(argvs)
@@ -53,7 +52,7 @@ module Sisimai
53
52
  issuedcode = argvs['diagnosticcode'].downcase || ''
54
53
  statuscode = argvs['deliverystatus'] || ''
55
54
 
56
- if Sisimai::SMTP::Status.name(statuscode).to_s == 'hostunknown'
55
+ if Sisimai::SMTP::Status.name(statuscode) == 'hostunknown'
57
56
  # To prevent classifying DNS errors as "HostUnknown"
58
57
  require 'sisimai/reason/networkerror'
59
58
  return true unless Sisimai::Reason::NetworkError.match(issuedcode)