sisimai 4.24.1-java → 4.25.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 (155) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -2
  3. data/ANALYTICAL-PRECISION +16 -25
  4. data/ChangeLog.md +41 -0
  5. data/Developers.mk +2 -2
  6. data/README-JA.md +13 -13
  7. data/README.md +13 -13
  8. data/lib/sisimai.rb +3 -7
  9. data/lib/sisimai/address.rb +25 -41
  10. data/lib/sisimai/arf.rb +58 -59
  11. data/lib/sisimai/bite.rb +0 -1
  12. data/lib/sisimai/bite/email.rb +7 -7
  13. data/lib/sisimai/bite/email/activehunter.rb +4 -3
  14. data/lib/sisimai/bite/email/amavis.rb +133 -0
  15. data/lib/sisimai/bite/email/amazonses.rb +53 -87
  16. data/lib/sisimai/bite/email/amazonworkmail.rb +51 -57
  17. data/lib/sisimai/bite/email/aol.rb +50 -76
  18. data/lib/sisimai/bite/email/apachejames.rb +2 -2
  19. data/lib/sisimai/bite/email/bigfoot.rb +47 -74
  20. data/lib/sisimai/bite/email/biglobe.rb +8 -9
  21. data/lib/sisimai/bite/email/courier.rb +56 -101
  22. data/lib/sisimai/bite/email/domino.rb +7 -8
  23. data/lib/sisimai/bite/email/einsundeins.rb +4 -5
  24. data/lib/sisimai/bite/email/exchange2003.rb +21 -22
  25. data/lib/sisimai/bite/email/exchange2007.rb +26 -28
  26. data/lib/sisimai/bite/email/exim.rb +48 -47
  27. data/lib/sisimai/bite/email/ezweb.rb +24 -36
  28. data/lib/sisimai/bite/email/facebook.rb +54 -79
  29. data/lib/sisimai/bite/email/fml.rb +10 -10
  30. data/lib/sisimai/bite/email/gmx.rb +6 -6
  31. data/lib/sisimai/bite/email/google.rb +12 -13
  32. data/lib/sisimai/bite/email/gsuite.rb +80 -108
  33. data/lib/sisimai/bite/email/imailserver.rb +16 -16
  34. data/lib/sisimai/bite/email/interscanmss.rb +4 -6
  35. data/lib/sisimai/bite/email/kddi.rb +9 -11
  36. data/lib/sisimai/bite/email/mailfoundry.rb +2 -2
  37. data/lib/sisimai/bite/email/mailmarshalsmtp.rb +2 -2
  38. data/lib/sisimai/bite/email/mailru.rb +12 -13
  39. data/lib/sisimai/bite/email/mcafee.rb +31 -25
  40. data/lib/sisimai/bite/email/messagelabs.rb +48 -87
  41. data/lib/sisimai/bite/email/messagingserver.rb +9 -10
  42. data/lib/sisimai/bite/email/mfilter.rb +16 -16
  43. data/lib/sisimai/bite/email/mxlogic.rb +11 -11
  44. data/lib/sisimai/bite/email/notes.rb +5 -6
  45. data/lib/sisimai/bite/email/office365.rb +25 -42
  46. data/lib/sisimai/bite/email/opensmtpd.rb +8 -8
  47. data/lib/sisimai/bite/email/outlook.rb +49 -67
  48. data/lib/sisimai/bite/email/postfix.rb +78 -112
  49. data/lib/sisimai/bite/email/qmail.rb +23 -23
  50. data/lib/sisimai/bite/email/receivingses.rb +53 -86
  51. data/lib/sisimai/bite/email/sendgrid.rb +65 -84
  52. data/lib/sisimai/bite/email/sendmail.rb +89 -117
  53. data/lib/sisimai/bite/email/surfcontrol.rb +15 -18
  54. data/lib/sisimai/bite/email/userdefined.rb +1 -1
  55. data/lib/sisimai/bite/email/v5sendmail.rb +3 -4
  56. data/lib/sisimai/bite/email/verizon.rb +7 -8
  57. data/lib/sisimai/bite/email/x1.rb +2 -2
  58. data/lib/sisimai/bite/email/x2.rb +2 -2
  59. data/lib/sisimai/bite/email/x3.rb +3 -3
  60. data/lib/sisimai/bite/email/x4.rb +22 -22
  61. data/lib/sisimai/bite/email/x5.rb +40 -49
  62. data/lib/sisimai/bite/email/yahoo.rb +3 -3
  63. data/lib/sisimai/bite/email/yandex.rb +54 -82
  64. data/lib/sisimai/bite/email/zoho.rb +6 -6
  65. data/lib/sisimai/bite/json/amazonses.rb +20 -20
  66. data/lib/sisimai/bite/json/sendgrid.rb +2 -2
  67. data/lib/sisimai/data.rb +27 -40
  68. data/lib/sisimai/datetime.rb +146 -162
  69. data/lib/sisimai/mda.rb +30 -31
  70. data/lib/sisimai/message/email.rb +83 -123
  71. data/lib/sisimai/message/json.rb +2 -4
  72. data/lib/sisimai/mime.rb +31 -34
  73. data/lib/sisimai/order/email.rb +23 -22
  74. data/lib/sisimai/reason.rb +61 -61
  75. data/lib/sisimai/reason/blocked.rb +139 -135
  76. data/lib/sisimai/reason/contenterror.rb +11 -10
  77. data/lib/sisimai/reason/exceedlimit.rb +4 -4
  78. data/lib/sisimai/reason/expired.rb +20 -20
  79. data/lib/sisimai/reason/filtered.rb +19 -18
  80. data/lib/sisimai/reason/hasmoved.rb +3 -3
  81. data/lib/sisimai/reason/hostunknown.rb +19 -19
  82. data/lib/sisimai/reason/mailboxfull.rb +49 -49
  83. data/lib/sisimai/reason/mailererror.rb +16 -16
  84. data/lib/sisimai/reason/mesgtoobig.rb +17 -17
  85. data/lib/sisimai/reason/networkerror.rb +19 -19
  86. data/lib/sisimai/reason/norelaying.rb +16 -16
  87. data/lib/sisimai/reason/notaccept.rb +9 -10
  88. data/lib/sisimai/reason/onhold.rb +1 -1
  89. data/lib/sisimai/reason/policyviolation.rb +21 -20
  90. data/lib/sisimai/reason/rejected.rb +53 -53
  91. data/lib/sisimai/reason/securityerror.rb +29 -29
  92. data/lib/sisimai/reason/spamdetected.rb +127 -127
  93. data/lib/sisimai/reason/suspend.rb +17 -17
  94. data/lib/sisimai/reason/systemerror.rb +22 -21
  95. data/lib/sisimai/reason/systemfull.rb +6 -6
  96. data/lib/sisimai/reason/toomanyconn.rb +19 -18
  97. data/lib/sisimai/reason/userunknown.rb +122 -121
  98. data/lib/sisimai/reason/vacation.rb +8 -8
  99. data/lib/sisimai/reason/virusdetected.rb +8 -8
  100. data/lib/sisimai/rfc1894.rb +142 -0
  101. data/lib/sisimai/rfc3464.rb +70 -70
  102. data/lib/sisimai/rfc3834.rb +15 -15
  103. data/lib/sisimai/rfc5322.rb +20 -36
  104. data/lib/sisimai/rhost.rb +1 -0
  105. data/lib/sisimai/rhost/exchangeonline.rb +31 -33
  106. data/lib/sisimai/rhost/franceptt.rb +23 -23
  107. data/lib/sisimai/rhost/godaddy.rb +28 -28
  108. data/lib/sisimai/rhost/googleapps.rb +39 -41
  109. data/lib/sisimai/rhost/kddi.rb +3 -3
  110. data/lib/sisimai/rhost/tencentqq.rb +51 -0
  111. data/lib/sisimai/smtp/error.rb +14 -21
  112. data/lib/sisimai/smtp/reply.rb +14 -13
  113. data/lib/sisimai/smtp/status.rb +178 -179
  114. data/lib/sisimai/string.rb +13 -12
  115. data/lib/sisimai/version.rb +1 -1
  116. data/set-of-emails/README.md +1 -5
  117. data/set-of-emails/maildir/bsd/arf-23.eml +49 -0
  118. data/set-of-emails/maildir/bsd/email-amavis-01.eml +78 -0
  119. data/set-of-emails/maildir/bsd/email-amavis-02.eml +78 -0
  120. data/set-of-emails/maildir/bsd/email-exchange2007-04.eml +146 -0
  121. data/set-of-emails/maildir/bsd/email-exim-60.eml +94 -0
  122. data/set-of-emails/maildir/bsd/email-ezweb-08.eml +49 -0
  123. data/set-of-emails/maildir/bsd/email-google-19.eml +67 -0
  124. data/set-of-emails/maildir/bsd/email-mcafee-05.eml +74 -0
  125. data/set-of-emails/maildir/bsd/email-messagingserver-12.eml +99 -0
  126. data/set-of-emails/maildir/bsd/email-postfix-46.eml +81 -0
  127. data/set-of-emails/maildir/bsd/email-postfix-47.eml +79 -0
  128. data/set-of-emails/maildir/bsd/email-postfix-48.eml +79 -0
  129. data/set-of-emails/maildir/bsd/email-postfix-49.eml +141 -0
  130. data/set-of-emails/maildir/bsd/email-postfix-50.eml +143 -0
  131. data/set-of-emails/maildir/bsd/email-postfix-51.eml +73 -0
  132. data/set-of-emails/maildir/bsd/email-postfix-52.eml +79 -0
  133. data/set-of-emails/maildir/bsd/email-postfix-53.eml +76 -0
  134. data/set-of-emails/maildir/bsd/email-postfix-54.eml +73 -0
  135. data/set-of-emails/maildir/bsd/email-postfix-55.eml +74 -0
  136. data/set-of-emails/maildir/bsd/email-postfix-56.eml +78 -0
  137. data/set-of-emails/maildir/bsd/email-qmail-10.eml +50 -0
  138. data/set-of-emails/maildir/bsd/email-x2-05.eml +38 -0
  139. data/set-of-emails/maildir/bsd/rhost-google-apps-02.eml +88 -0
  140. data/set-of-emails/maildir/bsd/rhost-tencentqq-01.eml +84 -0
  141. data/set-of-emails/maildir/bsd/rhost-tencentqq-02.eml +84 -0
  142. data/set-of-emails/maildir/bsd/rhost-tencentqq-03.eml +81 -0
  143. data/set-of-emails/maildir/dos/email-amavis-01.eml +78 -0
  144. data/set-of-emails/maildir/dos/email-apachejames-01.eml +1 -2
  145. data/set-of-emails/maildir/dos/email-messagelabs-01.eml +67 -50
  146. data/set-of-emails/maildir/dos/email-x4-01.eml +31 -76
  147. data/set-of-emails/maildir/dos/rhost-tencentqq-01.eml +84 -0
  148. data/set-of-emails/maildir/mac/email-amavis-01.eml +1 -4
  149. data/set-of-emails/maildir/mac/email-apachejames-01.eml +1 -9
  150. data/set-of-emails/maildir/mac/email-messagelabs-01.eml +1 -9
  151. data/set-of-emails/maildir/mac/email-x4-01.eml +1 -5
  152. data/set-of-emails/maildir/mac/rhost-tencentqq-01.eml +1 -4
  153. metadata +35 -4
  154. data/set-of-emails/logo/horizontalversions.png +0 -0
  155. data/set-of-emails/logo/icon.png +0 -0
@@ -8,8 +8,8 @@ module Sisimai
8
8
  class << self
9
9
  # Imported from p5-Sisimail/lib/Sisimai/Rhost/KDDI.pm
10
10
  MessagesOf = {
11
- filtered: '550 : User unknown', # The response was: 550 : User unknown
12
- userunknown: '>: User unknown', # The response was: 550 <...>: User unknown
11
+ 'filtered' => '550 : User unknown', # The response was: 550 : User unknown
12
+ 'userunknown' => '>: User unknown', # The response was: 550 <...>: User unknown
13
13
  }.freeze
14
14
 
15
15
  # Detect bounce reason from au (KDDI)
@@ -22,7 +22,7 @@ module Sisimai
22
22
  MessagesOf.each_key do |e|
23
23
  # Try to match the error message with message patterns defined in $MessagesOf
24
24
  next unless statusmesg.end_with?(MessagesOf[e])
25
- reasontext = e.to_s
25
+ reasontext = e
26
26
  break
27
27
  end
28
28
 
@@ -0,0 +1,51 @@
1
+ module Sisimai
2
+ module Rhost
3
+ # Sisimai::Rhost detects the bounce reason from the content of Sisimai::Data
4
+ # object as an argument of get() method when the value of "rhost" of the object
5
+ # is "mx*.qq.com". This class is called only Sisimai::Data class.
6
+ module TencentQQ
7
+ class << self
8
+ # Imported from p5-Sisimail/lib/Sisimai/Rhost/TencentQQ.pm
9
+ MessagesOf = {
10
+ # https://service.mail.qq.com/cgi-bin/help?id=20022
11
+ 'dmarc check failed' => 'blocked',
12
+ 'spf check failed' => 'blocked',
13
+ 'suspected spam ip' => 'blocked',
14
+ 'mail is rejected by recipients' => 'filtered',
15
+ 'message too large' => 'mesgtoobig',
16
+ 'mail content denied' => 'spamdetected',
17
+ 'spam is embedded in the email' => 'spamdetected',
18
+ 'suspected spam' => 'spamdetected',
19
+ 'bad address syntax' => 'syntaxerror',
20
+ 'connection denied' => 'toomanyconn',
21
+ 'connection frequency limited' => 'toomanyconn',
22
+ 'domain frequency limited' => 'toomanyconn',
23
+ 'ip frequency limited' => 'toomanyconn',
24
+ 'sender frequency limited' => 'toomanyconn',
25
+ 'mailbox unavailable or access denied' => 'toomanyconn',
26
+ 'mailbox not found' => 'userunknown',
27
+ }.freeze
28
+
29
+ # Detect bounce reason from Tencent QQ
30
+ # @param [Sisimai::Data] argvs Parsed email object
31
+ # @return [String] The bounce reason at Tencent QQ
32
+ def get(argvs)
33
+ return argvs.reason unless argvs.reason.empty?
34
+
35
+ statusmesg = argvs.diagnosticcode.downcase
36
+ reasontext = ''
37
+
38
+ MessagesOf.each_key do |e|
39
+ # Try to match the error message with message patterns defined in $MessagesOf
40
+ next unless statusmesg.include?(e)
41
+ reasontext = MessagesOf[e]
42
+ break
43
+ end
44
+ return reasontext
45
+ end
46
+
47
+ end
48
+ end
49
+ end
50
+ end
51
+
@@ -9,12 +9,12 @@ module Sisimai
9
9
  require 'sisimai/smtp/status'
10
10
 
11
11
  SoftOrHard = {
12
- :soft => %w[
12
+ 'soft' => %w[
13
13
  blocked contenterror exceedlimit expired filtered mailboxfull
14
14
  mailererror mesgtoobig networkerror norelaying policyviolation
15
15
  rejected securityerror spamdetected suspend syntaxerror systemerror
16
16
  systemfull toomanyconn virusdetected],
17
- :hard => %w[hasmoved hostunknown userunknown]
17
+ 'hard' => %w[hasmoved hostunknown userunknown]
18
18
  }.freeze
19
19
 
20
20
  # Permanent error or not
@@ -25,11 +25,9 @@ module Sisimai
25
25
  # @since v4.17.3
26
26
  def is_permanent(argv1 = '')
27
27
  getchecked = nil
28
- statuscode = Sisimai::SMTP::Status.find(argv1)
29
- statuscode = Sisimai::SMTP::Reply.find(argv1) if statuscode.empty?
30
- classvalue = statuscode[0, 1].to_i
28
+ statuscode = Sisimai::SMTP::Status.find(argv1) || Sisimai::SMTP::Reply.find(argv1) || '0'
31
29
 
32
- if classvalue > 0
30
+ if (classvalue = statuscode[0, 1].to_i) > 0
33
31
  # 2, 4, or 5
34
32
  if classvalue == 5
35
33
  # Permanent error
@@ -66,28 +64,23 @@ module Sisimai
66
64
  # '': May not be bounce ?
67
65
  # @since v4.17.3
68
66
  def soft_or_hard(argv1 = '', argv2 = '')
69
- return '' if argv1.empty?
70
-
71
- getchecked = nil
72
- softorhard = nil
67
+ return nil if argv1.empty?
68
+ value = nil
73
69
 
74
70
  if %w[delivered feedback vacation].include?(argv1)
75
71
  # These are not dealt as a bounce reason
76
- softorhard = ''
72
+ value = ''
77
73
 
78
74
  elsif argv1 == 'onhold' || argv1 == 'undefined'
79
75
  # It should be "soft" when a reason is "onhold" or "undefined"
80
- softorhard = 'soft'
76
+ value = 'soft'
81
77
 
82
78
  elsif argv1 == 'notaccept'
83
79
  # NotAccept: 5xx => hard bounce, 4xx => soft bounce
84
80
  if argv2.size > 0
85
81
  # Get D.S.N. or SMTP reply code from The 2nd argument string
86
- statuscode = Sisimai::SMTP::Status.find(argv2)
87
- statuscode = Sisimai::SMTP::Reply.find(argv2) if statuscode.empty?
88
- classvalue = statuscode[0, 1].to_i
89
-
90
- softorhard = if classvalue == 4
82
+ statuscode = Sisimai::SMTP::Status.find(argv2) || Sisimai::SMTP::Reply.find(argv2) || '0'
83
+ value = if statuscode[0, 1].to_i == 4
91
84
  # Deal as a "soft bounce"
92
85
  'soft'
93
86
  else
@@ -96,19 +89,19 @@ module Sisimai
96
89
  end
97
90
  else
98
91
  # "notaccept" is a hard bounce
99
- softorhard = 'hard'
92
+ value = 'hard'
100
93
  end
101
94
 
102
95
  else
103
96
  # Check all the reasons defined at the above
104
97
  catch :SOFT_OR_HARD do
105
98
  while true
106
- [:hard, :soft].each do |e|
99
+ %w[hard soft].each do |e|
107
100
  # Soft or Hard?
108
101
  SoftOrHard[e].each do |f|
109
102
  # Hard bounce?
110
103
  next unless argv1 == f
111
- softorhard = e.to_s
104
+ value = e
112
105
  throw :SOFT_OR_HARD
113
106
  end
114
107
  end
@@ -118,7 +111,7 @@ module Sisimai
118
111
  end
119
112
  end
120
113
 
121
- return softorhard
114
+ return value
122
115
  end
123
116
 
124
117
  end
@@ -61,31 +61,32 @@ module Sisimai
61
61
  module Reply
62
62
  # Imported from p5-Sisimail/lib/Sisimai/SMTP/Reply.pm
63
63
  class << self
64
+ IP4Re = %r{\b
65
+ (?:\d|[01]?\d\d|2[0-4]\d|25[0-5])[.]
66
+ (?:\d|[01]?\d\d|2[0-4]\d|25[0-5])[.]
67
+ (?:\d|[01]?\d\d|2[0-4]\d|25[0-5])[.]
68
+ (?:\d|[01]?\d\d|2[0-4]\d|25[0-5])
69
+ \b}x
70
+
64
71
  # Get SMTP Reply Code from the given string
65
72
  # @param [String] argv1 String including SMTP Reply Code like 550
66
- # @return [String] SMTP Reply Code or empty if the first argument
73
+ # @return [String] SMTP Reply Code or Nil if the first argument
67
74
  # did not include SMTP Reply Code value
68
- def find(argv1 = '')
69
- return '' unless argv1
70
- return '' if argv1.empty?
71
- return '' if argv1.upcase.include?('X-UNIX')
75
+ def find(argv1 = nil)
76
+ return nil unless argv1
77
+ return nil if argv1.empty?
78
+ return nil if argv1.upcase.include?('X-UNIX')
72
79
 
73
80
  # Convert found IPv4 addresses to '***.***.***.***' to avoid that
74
81
  # the following code detects an octet of the IPv4 adress as an SMTP
75
82
  # reply code.
76
- ip4re = %r{\b
77
- (?:\d|[01]?\d\d|2[0-4]\d|25[0-5])[.]
78
- (?:\d|[01]?\d\d|2[0-4]\d|25[0-5])[.]
79
- (?:\d|[01]?\d\d|2[0-4]\d|25[0-5])[.]
80
- (?:\d|[01]?\d\d|2[0-4]\d|25[0-5])
81
- \b}x
82
- argv1 = argv1.gsub(/#{ip4re}/, '***.***.***.***') if argv1 =~ ip4re
83
+ argv1 = argv1.gsub(/#{IP4Re}/, '***.***.***.***') if argv1 =~ IP4Re
83
84
 
84
85
  if cv = argv1.match(/\b([45][0-5][0-9])\b/) || argv1.match(/\b(25[0-3])\b/)
85
86
  # 550, 447, or 250
86
87
  return cv[1]
87
88
  else
88
- return ''
89
+ return nil
89
90
  end
90
91
  end
91
92
 
@@ -540,167 +540,173 @@ module Sisimai
540
540
  module Status
541
541
  # Imported from p5-Sisimail/lib/Sisimai/SMTP/Status.pm
542
542
  class << self
543
+ CodePatterns = [
544
+ %r/[ ]?[(][#]([45][.]\d[.]\d+)[)]?[ ]?/, # #5.5.1
545
+ %r/\b\d{3}[- ][#]?([45][.]\d[.]\d+)\b/, # 550-5.1.1 OR 550 5.5.1
546
+ %r/\b([45][.]\d[.]\d+)\b/, # 5.5.1
547
+ %r/\b(2[.][0-7][.][0-7])\b/, # 2.1.5
548
+ ]
543
549
  StandardCode = {
544
- :'2.1.5' => 'delivered', # Successfully delivered
550
+ '2.1.5' => 'delivered', # Successfully delivered
545
551
  # ------------------------------------------------------------------------------
546
- :'4.1.6' => 'hasmoved', # Destination mailbox has moved, No forwarding address
547
- :'4.1.7' => 'rejected', # Bad sender's mailbox address syntax
548
- :'4.1.8' => 'rejected', # Bad sender's system address
549
- :'4.1.9' => 'systemerror', # Message relayed to non-compliant mailer
550
- :'4.2.1' => 'suspend', # Mailbox disabled, not accepting messages
551
- :'4.2.2' => 'mailboxfull', # Mailbox full
552
- :'4.2.3' => 'exceedlimit', # Message length exceeds administrative limit
553
- :'4.2.4' => 'filtered', # Mailing list expansion problem
554
- # :'4.3.0' => 'systemerror', # Other or undefined mail system status
555
- :'4.3.1' => 'systemfull', # Mail system full
556
- :'4.3.2' => 'notaccept', # System not accepting network messages
557
- :'4.3.3' => 'systemerror', # System not capable of selected features
558
- :'4.3.5' => 'systemerror', # System incorrectly configured
559
- # :'4.4.0' => 'networkerror', # Other or undefined network or routing status
560
- :'4.4.1' => 'expired', # No answer from host
561
- :'4.4.2' => 'networkerror', # Bad connection
562
- # :'4.4.3' => 'systemerror', # Directory server failure
563
- :'4.4.4' => 'networkerror', # Unable to route
564
- :'4.4.5' => 'systemfull', # Mail system congestion
565
- :'4.4.6' => 'networkerror', # Routing loop detected
566
- :'4.4.7' => 'expired', # Delivery time expired
567
- # :'4.5.0' => 'networkerror', # Other or undefined protocol status
568
- :'4.5.3' => 'systemerror', # Too many recipients
569
- :'4.5.5' => 'systemerror', # Wrong protocol version
570
- :'4.6.0' => 'contenterror', # Other or undefined media error
571
- :'4.6.2' => 'contenterror', # Conversion required and prohibited
572
- :'4.6.5' => 'contenterror', # Conversion Failed
552
+ '4.1.6' => 'hasmoved', # Destination mailbox has moved, No forwarding address
553
+ '4.1.7' => 'rejected', # Bad sender's mailbox address syntax
554
+ '4.1.8' => 'rejected', # Bad sender's system address
555
+ '4.1.9' => 'systemerror', # Message relayed to non-compliant mailer
556
+ '4.2.1' => 'suspend', # Mailbox disabled, not accepting messages
557
+ '4.2.2' => 'mailboxfull', # Mailbox full
558
+ '4.2.3' => 'exceedlimit', # Message length exceeds administrative limit
559
+ '4.2.4' => 'filtered', # Mailing list expansion problem
560
+ # '4.3.0' => 'systemerror', # Other or undefined mail system status
561
+ '4.3.1' => 'systemfull', # Mail system full
562
+ '4.3.2' => 'notaccept', # System not accepting network messages
563
+ '4.3.3' => 'systemerror', # System not capable of selected features
564
+ '4.3.5' => 'systemerror', # System incorrectly configured
565
+ # '4.4.0' => 'networkerror', # Other or undefined network or routing status
566
+ '4.4.1' => 'expired', # No answer from host
567
+ '4.4.2' => 'networkerror', # Bad connection
568
+ # '4.4.3' => 'systemerror', # Directory server failure
569
+ '4.4.4' => 'networkerror', # Unable to route
570
+ '4.4.5' => 'systemfull', # Mail system congestion
571
+ '4.4.6' => 'networkerror', # Routing loop detected
572
+ '4.4.7' => 'expired', # Delivery time expired
573
+ # '4.5.0' => 'networkerror', # Other or undefined protocol status
574
+ '4.5.3' => 'systemerror', # Too many recipients
575
+ '4.5.5' => 'systemerror', # Wrong protocol version
576
+ '4.6.0' => 'contenterror', # Other or undefined media error
577
+ '4.6.2' => 'contenterror', # Conversion required and prohibited
578
+ '4.6.5' => 'contenterror', # Conversion Failed
573
579
  # :'4.7.0' => 'securityerror', # Other or undefined security status
574
- :'4.7.1' => 'blocked', # Delivery not authorized, message refused
575
- :'4.7.2' => 'blocked', # Mailing list expansion prohibited
576
- :'4.7.5' => 'securityerror', # Cryptographic failure
577
- :'4.7.6' => 'securityerror', # Cryptographic algorithm not supported
578
- :'4.7.7' => 'securityerror', # Message integrity failure
579
- :'4.7.12' => 'securityerror', # A password transition is needed
580
- :'4.7.15' => 'securityerror', # Priority Level is too low
581
- :'4.7.16' => 'mesgtoobig', # Message is too big for the specified priority
582
- :'4.7.24' => 'securityerror', # SPF validation error
583
- :'4.7.25' => 'blocked', # Reverse DNS validation failed
580
+ '4.7.1' => 'blocked', # Delivery not authorized, message refused
581
+ '4.7.2' => 'blocked', # Mailing list expansion prohibited
582
+ '4.7.5' => 'securityerror', # Cryptographic failure
583
+ '4.7.6' => 'securityerror', # Cryptographic algorithm not supported
584
+ '4.7.7' => 'securityerror', # Message integrity failure
585
+ '4.7.12' => 'securityerror', # A password transition is needed
586
+ '4.7.15' => 'securityerror', # Priority Level is too low
587
+ '4.7.16' => 'mesgtoobig', # Message is too big for the specified priority
588
+ '4.7.24' => 'securityerror', # SPF validation error
589
+ '4.7.25' => 'blocked', # Reverse DNS validation failed
584
590
  # ------------------------------------------------------------------------------
585
- :'5.1.0' => 'userunknown', # Other address status
586
- :'5.1.1' => 'userunknown', # Bad destination mailbox address
587
- :'5.1.2' => 'hostunknown', # Bad destination system address
588
- :'5.1.3' => 'userunknown', # Bad destination mailbox address syntax
589
- :'5.1.4' => 'filtered', # Destination mailbox address ambiguous
590
- :'5.1.6' => 'hasmoved', # Destination mailbox has moved, No forwarding address
591
- :'5.1.7' => 'rejected', # Bad sender's mailbox address syntax
592
- :'5.1.8' => 'rejected', # Bad sender's system address
593
- :'5.1.9' => 'systemerror', # Message relayed to non-compliant mailer
594
- :'5.1.10' => 'notaccept', # Recipient address has null MX
595
- :'5.2.0' => 'filtered', # Other or undefined mailbox status
596
- :'5.2.1' => 'filtered', # Mailbox disabled, not accepting messages
597
- :'5.2.2' => 'mailboxfull', # Mailbox full
598
- :'5.2.3' => 'exceedlimit', # Message length exceeds administrative limit
599
- :'5.2.4' => 'filtered', # Mailing list expansion problem
600
- :'5.3.0' => 'systemerror', # Other or undefined mail system status
601
- :'5.3.1' => 'systemfull', # Mail system full
602
- :'5.3.2' => 'notaccept', # System not accepting network messages
603
- :'5.3.3' => 'systemerror', # System not capable of selected features
604
- :'5.3.4' => 'mesgtoobig', # Message too big for system
605
- :'5.3.5' => 'systemerror', # System incorrectly configured
606
- :'5.4.0' => 'networkerror', # Other or undefined network or routing status
607
- :'5.4.3' => 'systemerror', # Directory server failure
608
- :'5.4.4' => 'hostunknown', # Unable to route
609
- :'5.5.3' => 'toomanyconn', # Too many recipients
610
- :'5.5.4' => 'systemerror', # Invalid command arguments
611
- :'5.5.5' => 'systemerror', # Wrong protocol version
612
- :'5.5.6' => 'securityerror', # Authentication Exchange line is too long
613
- :'5.6.0' => 'contenterror', # Other or undefined media error
614
- :'5.6.1' => 'contenterror', # Media not supported
615
- :'5.6.2' => 'contenterror', # Conversion required and prohibited
616
- :'5.6.3' => 'contenterror', # Conversion required but not supported
617
- :'5.6.5' => 'contenterror', # Conversion Failed
618
- :'5.6.6' => 'contenterror', # Message content not available
619
- :'5.6.7' => 'contenterror', # Non-ASCII addresses not permitted for that sender/recipient
620
- :'5.6.8' => 'contenterror', # UTF-8 string reply is required, but not permitted by the SMTP client
621
- :'5.6.9' => 'contenterror', # UTF-8 header message cannot be transferred to one or more recipients
622
- :'5.7.0' => 'securityerror', # Other or undefined security status
623
- :'5.7.1' => 'securityerror', # Delivery not authorized, message refused
624
- :'5.7.2' => 'securityerror', # Mailing list expansion prohibited
625
- :'5.7.3' => 'securityerror', # Security conversion required but not possible
626
- :'5.7.4' => 'securityerror', # Security features not supported
627
- :'5.7.5' => 'securityerror', # Cryptographic failure
628
- :'5.7.6' => 'securityerror', # Cryptographic algorithm not supported
629
- :'5.7.7' => 'securityerror', # Message integrity failure
630
- :'5.7.8' => 'securityerror', # Authentication credentials invalid
631
- :'5.7.9' => 'securityerror', # Authentication mechanism is too weak
632
- :'5.7.10' => 'securityerror', # Encryption Needed
633
- :'5.7.11' => 'securityerror', # Encryption required for requested authentication mechanism
634
- :'5.7.13' => 'suspend', # User Account Disabled
635
- :'5.7.14' => 'securityerror', # Trust relationship required
636
- :'5.7.15' => 'securityerror', # Priority Level is too low
637
- :'5.7.16' => 'mesgtoobig', # Message is too big for the specified priority
638
- :'5.7.17' => 'hasmoved', # Mailbox owner has changed
639
- :'5.7.18' => 'hasmoved', # Domain owner has changed
640
- :'5.7.19' => 'securityerror', # RRVS test cannot be completed
641
- :'5.7.20' => 'securityerror', # No passing DKIM signature found
642
- :'5.7.21' => 'securityerror', # No acceptable DKIM signature found
643
- :'5.7.22' => 'securityerror', # No valid author-matched DKIM signature found
644
- :'5.7.23' => 'securityerror', # SPF validation failed
645
- :'5.7.24' => 'securityerror', # SPF validation error
646
- :'5.7.25' => 'blocked', # Reverse DNS validation failed
647
- :'5.7.26' => 'securityerror', # Multiple authentication checks failed
648
- :'5.7.27' => 'rejected', # Sender address has null MX
591
+ '5.1.0' => 'userunknown', # Other address status
592
+ '5.1.1' => 'userunknown', # Bad destination mailbox address
593
+ '5.1.2' => 'hostunknown', # Bad destination system address
594
+ '5.1.3' => 'userunknown', # Bad destination mailbox address syntax
595
+ '5.1.4' => 'filtered', # Destination mailbox address ambiguous
596
+ '5.1.6' => 'hasmoved', # Destination mailbox has moved, No forwarding address
597
+ '5.1.7' => 'rejected', # Bad sender's mailbox address syntax
598
+ '5.1.8' => 'rejected', # Bad sender's system address
599
+ '5.1.9' => 'systemerror', # Message relayed to non-compliant mailer
600
+ '5.1.10' => 'notaccept', # Recipient address has null MX
601
+ '5.2.0' => 'filtered', # Other or undefined mailbox status
602
+ '5.2.1' => 'filtered', # Mailbox disabled, not accepting messages
603
+ '5.2.2' => 'mailboxfull', # Mailbox full
604
+ '5.2.3' => 'exceedlimit', # Message length exceeds administrative limit
605
+ '5.2.4' => 'filtered', # Mailing list expansion problem
606
+ '5.3.0' => 'systemerror', # Other or undefined mail system status
607
+ '5.3.1' => 'systemfull', # Mail system full
608
+ '5.3.2' => 'notaccept', # System not accepting network messages
609
+ '5.3.3' => 'systemerror', # System not capable of selected features
610
+ '5.3.4' => 'mesgtoobig', # Message too big for system
611
+ '5.3.5' => 'systemerror', # System incorrectly configured
612
+ '5.4.0' => 'networkerror', # Other or undefined network or routing status
613
+ '5.4.3' => 'systemerror', # Directory server failure
614
+ '5.4.4' => 'hostunknown', # Unable to route
615
+ '5.5.3' => 'toomanyconn', # Too many recipients
616
+ '5.5.4' => 'systemerror', # Invalid command arguments
617
+ '5.5.5' => 'systemerror', # Wrong protocol version
618
+ '5.5.6' => 'securityerror', # Authentication Exchange line is too long
619
+ '5.6.0' => 'contenterror', # Other or undefined media error
620
+ '5.6.1' => 'contenterror', # Media not supported
621
+ '5.6.2' => 'contenterror', # Conversion required and prohibited
622
+ '5.6.3' => 'contenterror', # Conversion required but not supported
623
+ '5.6.5' => 'contenterror', # Conversion Failed
624
+ '5.6.6' => 'contenterror', # Message content not available
625
+ '5.6.7' => 'contenterror', # Non-ASCII addresses not permitted for that sender/recipient
626
+ '5.6.8' => 'contenterror', # UTF-8 string reply is required, but not permitted by the SMTP client
627
+ '5.6.9' => 'contenterror', # UTF-8 header message cannot be transferred to one or more recipients
628
+ '5.7.0' => 'securityerror', # Other or undefined security status
629
+ '5.7.1' => 'securityerror', # Delivery not authorized, message refused
630
+ '5.7.2' => 'securityerror', # Mailing list expansion prohibited
631
+ '5.7.3' => 'securityerror', # Security conversion required but not possible
632
+ '5.7.4' => 'securityerror', # Security features not supported
633
+ '5.7.5' => 'securityerror', # Cryptographic failure
634
+ '5.7.6' => 'securityerror', # Cryptographic algorithm not supported
635
+ '5.7.7' => 'securityerror', # Message integrity failure
636
+ '5.7.8' => 'securityerror', # Authentication credentials invalid
637
+ '5.7.9' => 'securityerror', # Authentication mechanism is too weak
638
+ '5.7.10' => 'securityerror', # Encryption Needed
639
+ '5.7.11' => 'securityerror', # Encryption required for requested authentication mechanism
640
+ '5.7.13' => 'suspend', # User Account Disabled
641
+ '5.7.14' => 'securityerror', # Trust relationship required
642
+ '5.7.15' => 'securityerror', # Priority Level is too low
643
+ '5.7.16' => 'mesgtoobig', # Message is too big for the specified priority
644
+ '5.7.17' => 'hasmoved', # Mailbox owner has changed
645
+ '5.7.18' => 'hasmoved', # Domain owner has changed
646
+ '5.7.19' => 'securityerror', # RRVS test cannot be completed
647
+ '5.7.20' => 'securityerror', # No passing DKIM signature found
648
+ '5.7.21' => 'securityerror', # No acceptable DKIM signature found
649
+ '5.7.22' => 'securityerror', # No valid author-matched DKIM signature found
650
+ '5.7.23' => 'securityerror', # SPF validation failed
651
+ '5.7.24' => 'securityerror', # SPF validation error
652
+ '5.7.25' => 'blocked', # Reverse DNS validation failed
653
+ '5.7.26' => 'securityerror', # Multiple authentication checks failed
654
+ '5.7.27' => 'rejected', # Sender address has null MX
649
655
  }.freeze
650
656
 
651
657
  InternalCode = {
652
658
  :temporary => {
653
- :blocked => '4.0.971',
654
- :contenterror => '4.0.960',
655
- # :exceedlimit => '4.0.923',
656
- :expired => '4.0.947',
657
- :filtered => '4.0.924',
658
- # :hasmoved => '4.0.916',
659
- # :hostunknown => '4.0.912',
660
- :mailboxfull => '4.0.922',
661
- # :mailererror => '4.0.939',
662
- # :mesgtoobig => '4.0.934',
663
- :networkerror => '4.0.944',
664
- # :norelaying => '4.0.909',
665
- :notaccept => '4.0.932',
666
- :onhold => '4.0.901',
667
- :rejected => '4.0.918',
668
- :securityerror => '4.0.970',
669
- :spamdetected => '4.0.980',
670
- # :suspend => '4.0.921',
671
- :systemerror => '4.0.930',
672
- :systemfull => '4.0.931',
673
- :toomanyconn => '4.0.945',
674
- # :userunknown => '4.0.911',
675
- :undefined => '4.0.900',
659
+ 'blocked' => '4.0.971',
660
+ 'contenterror' => '4.0.960',
661
+ # 'exceedlimit' => '4.0.923',
662
+ 'expired' => '4.0.947',
663
+ 'filtered' => '4.0.924',
664
+ # 'hasmoved' => '4.0.916',
665
+ # 'hostunknown' => '4.0.912',
666
+ 'mailboxfull' => '4.0.922',
667
+ # 'mailererror' => '4.0.939',
668
+ # 'mesgtoobig' => '4.0.934',
669
+ 'networkerror' => '4.0.944',
670
+ # 'norelaying' => '4.0.909',
671
+ 'notaccept' => '4.0.932',
672
+ 'onhold' => '4.0.901',
673
+ 'rejected' => '4.0.918',
674
+ 'securityerror' => '4.0.970',
675
+ 'spamdetected' => '4.0.980',
676
+ # 'suspend' => '4.0.921',
677
+ 'systemerror' => '4.0.930',
678
+ 'systemfull' => '4.0.931',
679
+ 'toomanyconn' => '4.0.945',
680
+ # 'userunknown' => '4.0.911',
681
+ 'undefined' => '4.0.900',
676
682
  },
677
683
  :permanent => {
678
- :blocked => '5.0.971',
679
- :contenterror => '5.0.960',
680
- :exceedlimit => '5.0.923',
681
- :expired => '5.0.947',
682
- :filtered => '5.0.910',
683
- :hasmoved => '5.0.916',
684
- :hostunknown => '5.0.912',
685
- :mailboxfull => '5.0.922',
686
- :mailererror => '5.0.939',
687
- :mesgtoobig => '5.0.934',
688
- :networkerror => '5.0.944',
689
- :norelaying => '5.0.909',
690
- :notaccept => '5.0.932',
691
- :onhold => '5.0.901',
692
- :policyviolation => '5.0.972',
693
- :rejected => '5.0.918',
694
- :securityerror => '5.0.970',
695
- :spamdetected => '5.0.980',
696
- :suspend => '5.0.921',
697
- :systemerror => '5.0.930',
698
- :systemfull => '5.0.931',
699
- :syntaxerror => '5.0.902',
700
- :toomanyconn => '5.0.945',
701
- :userunknown => '5.0.911',
702
- :undefined => '5.0.900',
703
- :virusdetected => '5.0.971',
684
+ 'blocked' => '5.0.971',
685
+ 'contenterror' => '5.0.960',
686
+ 'exceedlimit' => '5.0.923',
687
+ 'expired' => '5.0.947',
688
+ 'filtered' => '5.0.910',
689
+ 'hasmoved' => '5.0.916',
690
+ 'hostunknown' => '5.0.912',
691
+ 'mailboxfull' => '5.0.922',
692
+ 'mailererror' => '5.0.939',
693
+ 'mesgtoobig' => '5.0.934',
694
+ 'networkerror' => '5.0.944',
695
+ 'norelaying' => '5.0.909',
696
+ 'notaccept' => '5.0.932',
697
+ 'onhold' => '5.0.901',
698
+ 'policyviolation' => '5.0.972',
699
+ 'rejected' => '5.0.918',
700
+ 'securityerror' => '5.0.970',
701
+ 'spamdetected' => '5.0.980',
702
+ 'suspend' => '5.0.921',
703
+ 'systemerror' => '5.0.930',
704
+ 'systemfull' => '5.0.931',
705
+ 'syntaxerror' => '5.0.902',
706
+ 'toomanyconn' => '5.0.945',
707
+ 'userunknown' => '5.0.911',
708
+ 'undefined' => '5.0.900',
709
+ 'virusdetected' => '5.0.971',
704
710
  },
705
711
  }.freeze
706
712
 
@@ -708,58 +714,51 @@ module Sisimai
708
714
  # @param [String] argv1 Reason name
709
715
  # @param [True,False] argv2 false: Permanent error
710
716
  # true: Temporary error
711
- # @return [String] DSN or empty if the 1st argument is missing
717
+ # @return [String, Nil] DSN or Nil if the 1st argument is missing
712
718
  # @see name
713
- def code(argv1 = '', argv2 = false)
714
- return '' unless argv1
715
- return '' if argv1.empty?
719
+ def code(argv1 = nil, argv2 = false)
720
+ return nil unless argv1
721
+ return nil if argv1.empty?
716
722
 
717
723
  table = argv2 ? InternalCode[:temporary] : InternalCode[:permanent]
718
- code0 = table[argv1.to_sym] || InternalCode[:permanent][argv1.to_sym] || ''
724
+ code0 = table[argv1] || InternalCode[:permanent][argv1] || nil
719
725
  return code0
720
726
  end
721
727
 
722
728
  # Convert from the status code to the reason string
723
729
  # @param [String] argv1 Status code(DSN)
724
- # @return [String] Reason name or empty if the first argument did
730
+ # @return [String, Nil] Reason name or Nil if the first argument did
725
731
  # not match with values in Sisimai's reason list
726
732
  # @see code
727
- def name(argv1 = '')
728
- return '' unless argv1
729
- return '' unless argv1 =~ /\A[245][.]\d[.]\d+\z/
730
- return StandardCode[argv1.to_sym] || ''
733
+ def name(argv1 = nil)
734
+ return nil unless argv1
735
+ return nil unless argv1 =~ /\A[245][.]\d[.]\d+\z/
736
+ return StandardCode[argv1] || nil
731
737
  end
732
738
 
733
739
  # Get a DSN code value from given string including DSN
734
740
  # @param [String] argv1 String including DSN
735
- # @return [String] DSN or empty string if the first agument did
736
- # not include DSN
737
- def find(argv1 = '')
738
- return '' unless argv1
739
- return '' if argv1.empty?
741
+ # @return [String, Nil] DSN or Nil if the first agument did not
742
+ # include DSN
743
+ def find(argv1 = nil)
744
+ return nil unless argv1
745
+ return nil if argv1.empty?
740
746
 
741
- foundvalue = ''
742
- regularexp = [
743
- %r/[ ]?[(][#]([45][.]\d[.]\d+)[)]?[ ]?/, # #5.5.1
744
- %r/\b\d{3}[- ][#]?([45][.]\d[.]\d+)\b/, # 550-5.1.1 OR 550 5.5.1
745
- %r/\b([45][.]\d[.]\d+)\b/, # 5.5.1
746
- %r/\b(2[.][0-7][.][0-7])\b/, # 2.1.5
747
- ]
748
-
749
- while e = regularexp.shift do
747
+ found = nil
748
+ CodePatterns.each do |e|
750
749
  # Get the value of D.S.N. in the text
751
750
  next unless r = argv1.match(e)
752
- foundvalue = r[1]
751
+ found = r[1]
753
752
 
754
- if argv1 =~ /\b(?:#{foundvalue}[.]\d{1,3}|\d{1,3}[.]#{foundvalue})\b/
753
+ if argv1 =~ /\b(?:#{found}[.]\d{1,3}|\d{1,3}[.]#{found})\b/
755
754
  # Clear and skip if the value is an IPv4 address
756
- foundvalue = ''
755
+ found = nil
757
756
  next
758
757
  end
759
758
  break
760
759
  end
761
760
 
762
- return foundvalue
761
+ return found
763
762
  end
764
763
 
765
764
  end