sisimai 4.22.3-java → 4.22.4-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 (130) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/Benchmarks.mk +54 -0
  4. data/ChangeLog.md +23 -2
  5. data/Developers.mk +42 -35
  6. data/Makefile +10 -0
  7. data/README-JA.md +13 -13
  8. data/README.md +14 -14
  9. data/lib/sisimai.rb +12 -18
  10. data/lib/sisimai/address.rb +64 -82
  11. data/lib/sisimai/arf.rb +27 -42
  12. data/lib/sisimai/bite/email.rb +2 -4
  13. data/lib/sisimai/bite/email/activehunter.rb +12 -17
  14. data/lib/sisimai/bite/email/amazonses.rb +30 -48
  15. data/lib/sisimai/bite/email/amazonworkmail.rb +20 -27
  16. data/lib/sisimai/bite/email/aol.rb +27 -35
  17. data/lib/sisimai/bite/email/apachejames.rb +17 -28
  18. data/lib/sisimai/bite/email/bigfoot.rb +20 -33
  19. data/lib/sisimai/bite/email/biglobe.rb +15 -24
  20. data/lib/sisimai/bite/email/courier.rb +37 -61
  21. data/lib/sisimai/bite/email/domino.rb +19 -28
  22. data/lib/sisimai/bite/email/einsundeins.rb +20 -34
  23. data/lib/sisimai/bite/email/exchange2003.rb +25 -43
  24. data/lib/sisimai/bite/email/exchange2007.rb +15 -23
  25. data/lib/sisimai/bite/email/exim.rb +101 -120
  26. data/lib/sisimai/bite/email/ezweb.rb +28 -44
  27. data/lib/sisimai/bite/email/facebook.rb +26 -37
  28. data/lib/sisimai/bite/email/fml.rb +11 -20
  29. data/lib/sisimai/bite/email/gmx.rb +17 -27
  30. data/lib/sisimai/bite/email/google.rb +19 -29
  31. data/lib/sisimai/bite/email/gsuite.rb +39 -48
  32. data/lib/sisimai/bite/email/imailserver.rb +25 -39
  33. data/lib/sisimai/bite/email/interscanmss.rb +19 -26
  34. data/lib/sisimai/bite/email/kddi.rb +20 -33
  35. data/lib/sisimai/bite/email/mailfoundry.rb +14 -24
  36. data/lib/sisimai/bite/email/mailmarshalsmtp.rb +15 -24
  37. data/lib/sisimai/bite/email/mailru.rb +40 -59
  38. data/lib/sisimai/bite/email/mcafee.rb +21 -35
  39. data/lib/sisimai/bite/email/messagelabs.rb +23 -38
  40. data/lib/sisimai/bite/email/messagingserver.rb +15 -27
  41. data/lib/sisimai/bite/email/mfilter.rb +19 -28
  42. data/lib/sisimai/bite/email/mxlogic.rb +31 -49
  43. data/lib/sisimai/bite/email/notes.rb +16 -24
  44. data/lib/sisimai/bite/email/office365.rb +29 -38
  45. data/lib/sisimai/bite/email/opensmtpd.rb +50 -67
  46. data/lib/sisimai/bite/email/outlook.rb +24 -36
  47. data/lib/sisimai/bite/email/postfix.rb +33 -42
  48. data/lib/sisimai/bite/email/qmail.rb +44 -59
  49. data/lib/sisimai/bite/email/receivingses.rb +28 -36
  50. data/lib/sisimai/bite/email/sendgrid.rb +28 -37
  51. data/lib/sisimai/bite/email/sendmail.rb +35 -51
  52. data/lib/sisimai/bite/email/surfcontrol.rb +17 -25
  53. data/lib/sisimai/bite/email/userdefined.rb +17 -28
  54. data/lib/sisimai/bite/email/v5sendmail.rb +32 -41
  55. data/lib/sisimai/bite/email/verizon.rb +31 -56
  56. data/lib/sisimai/bite/email/x1.rb +11 -18
  57. data/lib/sisimai/bite/email/x2.rb +11 -23
  58. data/lib/sisimai/bite/email/x3.rb +10 -19
  59. data/lib/sisimai/bite/email/x4.rb +46 -65
  60. data/lib/sisimai/bite/email/x5.rb +26 -37
  61. data/lib/sisimai/bite/email/yahoo.rb +11 -19
  62. data/lib/sisimai/bite/email/yandex.rb +19 -30
  63. data/lib/sisimai/bite/email/zoho.rb +21 -30
  64. data/lib/sisimai/bite/json.rb +1 -2
  65. data/lib/sisimai/bite/json/amazonses.rb +20 -25
  66. data/lib/sisimai/bite/json/sendgrid.rb +1 -1
  67. data/lib/sisimai/data.rb +36 -55
  68. data/lib/sisimai/data/json.rb +3 -3
  69. data/lib/sisimai/data/yaml.rb +1 -1
  70. data/lib/sisimai/datetime.rb +5 -21
  71. data/lib/sisimai/mail.rb +4 -6
  72. data/lib/sisimai/mail/maildir.rb +1 -1
  73. data/lib/sisimai/mda.rb +41 -44
  74. data/lib/sisimai/message.rb +2 -3
  75. data/lib/sisimai/message/email.rb +42 -52
  76. data/lib/sisimai/message/json.rb +7 -7
  77. data/lib/sisimai/mime.rb +25 -23
  78. data/lib/sisimai/order/email.rb +2 -2
  79. data/lib/sisimai/order/json.rb +2 -7
  80. data/lib/sisimai/reason.rb +41 -46
  81. data/lib/sisimai/reason/blocked.rb +60 -71
  82. data/lib/sisimai/reason/contenterror.rb +4 -8
  83. data/lib/sisimai/reason/delivered.rb +1 -3
  84. data/lib/sisimai/reason/exceedlimit.rb +10 -20
  85. data/lib/sisimai/reason/expired.rb +5 -9
  86. data/lib/sisimai/reason/feedback.rb +1 -3
  87. data/lib/sisimai/reason/filtered.rb +19 -38
  88. data/lib/sisimai/reason/hasmoved.rb +5 -8
  89. data/lib/sisimai/reason/hostunknown.rb +11 -18
  90. data/lib/sisimai/reason/mailboxfull.rb +14 -24
  91. data/lib/sisimai/reason/mailererror.rb +3 -5
  92. data/lib/sisimai/reason/mesgtoobig.rb +15 -25
  93. data/lib/sisimai/reason/networkerror.rb +8 -10
  94. data/lib/sisimai/reason/norelaying.rb +9 -14
  95. data/lib/sisimai/reason/notaccept.rb +9 -21
  96. data/lib/sisimai/reason/onhold.rb +3 -8
  97. data/lib/sisimai/reason/policyviolation.rb +8 -10
  98. data/lib/sisimai/reason/rejected.rb +36 -49
  99. data/lib/sisimai/reason/securityerror.rb +11 -13
  100. data/lib/sisimai/reason/spamdetected.rb +23 -37
  101. data/lib/sisimai/reason/suspend.rb +9 -10
  102. data/lib/sisimai/reason/syntaxerror.rb +3 -4
  103. data/lib/sisimai/reason/systemerror.rb +7 -9
  104. data/lib/sisimai/reason/systemfull.rb +2 -4
  105. data/lib/sisimai/reason/toomanyconn.rb +17 -30
  106. data/lib/sisimai/reason/undefined.rb +1 -3
  107. data/lib/sisimai/reason/userunknown.rb +28 -38
  108. data/lib/sisimai/reason/vacation.rb +4 -6
  109. data/lib/sisimai/reason/virusdetected.rb +4 -6
  110. data/lib/sisimai/rfc2606.rb +1 -2
  111. data/lib/sisimai/rfc3464.rb +87 -101
  112. data/lib/sisimai/rfc3834.rb +29 -39
  113. data/lib/sisimai/rfc5322.rb +17 -24
  114. data/lib/sisimai/rhost.rb +10 -7
  115. data/lib/sisimai/rhost/exchangeonline.rb +124 -255
  116. data/lib/sisimai/rhost/franceptt.rb +2 -2
  117. data/lib/sisimai/rhost/godaddy.rb +12 -25
  118. data/lib/sisimai/rhost/googleapps.rb +82 -183
  119. data/lib/sisimai/smtp.rb +4 -4
  120. data/lib/sisimai/smtp/error.rb +8 -8
  121. data/lib/sisimai/smtp/reply.rb +1 -1
  122. data/lib/sisimai/smtp/status.rb +1 -0
  123. data/lib/sisimai/string.rb +5 -7
  124. data/lib/sisimai/version.rb +1 -1
  125. data/set-of-emails/README.md +1 -1
  126. data/set-of-emails/maildir/bsd/README.md +50 -50
  127. data/sisimai-java.gemspec +1 -1
  128. data/sisimai.gemspec +1 -1
  129. metadata +4 -4
  130. data/lib/sisimai/skeleton.rb +0 -43
@@ -12,9 +12,7 @@ module Sisimai
12
12
  # Imported from p5-Sisimail/lib/Sisimai/Reason/MailerError.pm
13
13
  class << self
14
14
  def text; return 'mailererror'; end
15
- def description
16
- return 'Email returned due to a mailer program has not exited successfully'
17
- end
15
+ def description; return 'Email returned due to a mailer program has not exited successfully'; end
18
16
 
19
17
  # Try to match that the given text and regular expressions
20
18
  # @param [String] argv1 String to be matched with regular expressions
@@ -33,9 +31,9 @@ module Sisimai
33
31
  |exit[ ]\d+
34
32
  |mailer[ ]error
35
33
  |pipe[ ]to[ ][|][/].+
36
- |X[-]UNIX[;][ ]\d+ # X-UNIX; 127
34
+ |x[-]unix[;][ ]\d+ # X-UNIX; 127
37
35
  )
38
- }ix
36
+ }x
39
37
 
40
38
  return true if argv1 =~ regex
41
39
  return false
@@ -9,9 +9,7 @@ module Sisimai
9
9
  # Imported from p5-Sisimail/lib/Sisimai/Reason/MesgTooBig.pm
10
10
  class << self
11
11
  def text; return 'mesgtoobig'; end
12
- def description
13
- return 'Email rejected due to an email size is too big for a destination mail server'
14
- end
12
+ def description; return 'Email rejected due to an email size is too big for a destination mail server'; end
15
13
 
16
14
  # Try to match that the given text and regular expressions
17
15
  # @param [String] argv1 String to be matched with regular expressions
@@ -21,7 +19,7 @@ module Sisimai
21
19
  return nil unless argv1
22
20
  regex = %r{(?>
23
21
  exceeded[ ]maximum[ ]inbound[ ]message[ ]size
24
- |Line[ ]limit[ ]exceeded
22
+ |line[ ]limit[ ]exceeded
25
23
  |max[ ]message[ ]size[ ]exceeded
26
24
  |message[ ](?:
27
25
  file[ ]too[ ]big
@@ -35,9 +33,9 @@ module Sisimai
35
33
  |too[ ]large[ ]for[ ]this[ ].+
36
34
  )
37
35
  |size[ ]limit
38
- |Taille[ ]limite[ ]du[ ]message[ ]atteinte.+[A-Z]{3}.+514
36
+ |taille[ ]limite[ ]du[ ]message[ ]atteinte.+[a-z]{3}.+514
39
37
  )
40
- }ix
38
+ }x
41
39
 
42
40
  return true if argv1 =~ regex
43
41
  return false
@@ -51,31 +49,23 @@ module Sisimai
51
49
  def true(argvs)
52
50
  return nil unless argvs
53
51
  return nil unless argvs.is_a? Sisimai::Data
54
- return true if argvs.reason == Sisimai::Reason::MesgTooBig.text
52
+ return true if argvs.reason == 'mesgtoobig'
55
53
 
56
54
  require 'sisimai/smtp/status'
57
55
  statuscode = argvs.deliverystatus || ''
58
- diagnostic = argvs.diagnosticcode || ''
59
- reasontext = Sisimai::Reason::MesgTooBig.text
60
56
  tempreason = Sisimai::SMTP::Status.name(statuscode)
61
- v = false
62
57
 
63
- if tempreason == reasontext
64
- # Delivery status code points "mesgtoobig".
65
- # Status: 5.3.4
66
- # Diagnostic-Code: SMTP; 552 5.3.4 Error: message file too big
67
- v = true
68
- else
69
- if tempreason == 'exceedlimit' || statuscode == '5.2.3'
70
- # 5.2.3 Message length exceeds administrative limit
71
- v = false
72
- else
73
- # Check the value of Diagnosic-Code: header with patterns
74
- v = true if Sisimai::Reason::MesgTooBig.match(diagnostic)
75
- end
76
- end
58
+ # Delivery status code points "mesgtoobig".
59
+ # Status: 5.3.4
60
+ # Diagnostic-Code: SMTP; 552 5.3.4 Error: message file too big
61
+ return true if tempreason == 'mesgtoobig'
62
+
63
+ # 5.2.3 Message length exceeds administrative limit
64
+ return false if( tempreason == 'exceedlimit' || statuscode == '5.2.3' )
77
65
 
78
- return v
66
+ # Check the value of Diagnosic-Code: header with patterns
67
+ return true if match(argvs.diagnosticcode.downcase)
68
+ return false
79
69
  end
80
70
 
81
71
  end
@@ -14,9 +14,7 @@ module Sisimai
14
14
  # Imported from p5-Sisimail/lib/Sisimai/Reason/NetworkError.pm
15
15
  class << self
16
16
  def text; return 'networkerror'; end
17
- def description
18
- return 'SMTP connection failed due to DNS look up failure or other network problems'
19
- end
17
+ def description; return 'SMTP connection failed due to DNS look up failure or other network problems'; end
20
18
 
21
19
  # Try to match that the given text and regular expressions
22
20
  # @param [String] argv1 String to be matched with regular expressions
@@ -26,8 +24,8 @@ module Sisimai
26
24
  return nil unless argv1
27
25
  regex = %r{(?>
28
26
  could[ ]not[ ]connect[ ]and[ ]send[ ]the[ ]mail[ ]to
29
- |DNS[ ]records[ ]for[ ]the[ ]destination[ ]computer[ ]could[ ]not[ ]be[ ]found
30
- |Hop[ ]count[ ]exceeded[ ]-[ ]possible[ ]mail[ ]loop
27
+ |dns[ ]records[ ]for[ ]the[ ]destination[ ]computer[ ]could[ ]not[ ]be[ ]found
28
+ |hop[ ]count[ ]exceeded[ ]-[ ]possible[ ]mail[ ]loop
31
29
  |host[ ]is[ ]unreachable
32
30
  |mail[ ]forwarding[ ]loop[ ]for[ ]
33
31
  |malformed[ ]name[ ]server[ ]reply
@@ -37,15 +35,15 @@ module Sisimai
37
35
  |probably[ ]in[ ]a[ ]routing[ ]loop
38
36
  )
39
37
  |name[ ]service[ ]error[ ]for[ ].+[ ](?:
40
- Malformed[ ]or[ ]unexpected[ ]name[ ]server[ ]reply
41
- |Host[ ]not[ ]found,[ ]try[ ]again
38
+ malformed[ ]or[ ]unexpected[ ]name[ ]server[ ]reply
39
+ |host[ ]not[ ]found,[ ]try[ ]again
42
40
  )
43
- |No[ ]route[ ]to[ ]host
41
+ |no[ ]route[ ]to[ ]host
44
42
  |too[ ]many[ ]hops
45
- |Unable[ ]to[ ]resolve[ ]route[ ].+[ ]
43
+ |unable[ ]to[ ]resolve[ ]route[ ].+[ ]
46
44
  |unrouteable[ ]mail[ ]domain
47
45
  )
48
- }ix
46
+ }x
49
47
 
50
48
  return true if argv1 =~ regex
51
49
  return false
@@ -14,9 +14,7 @@ module Sisimai
14
14
  # Imported from p5-Sisimail/lib/Sisimai/Reason/NoRelaying.pm
15
15
  class << self
16
16
  def text; return 'norelaying'; end
17
- def description
18
- return 'Email rejected with error message "Relaying Denied"'
19
- end
17
+ def description; return 'Email rejected with error message "Relaying Denied"'; end
20
18
 
21
19
  # Try to match that the given text and regular expressions
22
20
  # @param [String] argv1 String to be matched with regular expressions
@@ -26,7 +24,7 @@ module Sisimai
26
24
  return nil unless argv1
27
25
  regex = %r{(?>
28
26
  as[ ]a[ ]relay
29
- |Insecure[ ]Mail[ ]Relay
27
+ |insecure[ ]mail[ ]relay
30
28
  |mail[ ]server[ ]requires[ ]authentication[ ]when[ ]attempting[ ]to[ ]
31
29
  send[ ]to[ ]a[ ]non-local[ ]e-mail[ ]address # MailEnable
32
30
  |not[ ](?:
@@ -40,10 +38,10 @@ module Sisimai
40
38
  )
41
39
  |relaying[ ]denied # Sendmail
42
40
  |that[ ]domain[ ]isn[']t[ ]in[ ]my[ ]list[ ]of[ ]allowed[ ]rcpthost
43
- |This[ ]system[ ]is[ ]not[ ]configured[ ]to[ ]relay[ ]mail
44
- |Unable[ ]to[ ]relay[ ]for
41
+ |this[ ]system[ ]is[ ]not[ ]configured[ ]to[ ]relay[ ]mail
42
+ |unable[ ]to[ ]relay[ ]for
45
43
  )
46
- }ix
44
+ }x
47
45
 
48
46
  return true if argv1 =~ regex
49
47
  return false
@@ -58,17 +56,14 @@ module Sisimai
58
56
  return nil unless argvs
59
57
  return nil unless argvs.is_a? Sisimai::Data
60
58
 
61
- currreason = argvs.reason || ''
62
- reexcludes = %r/\A(?:securityerror|systemerror|undefined)\z/
63
-
64
- if currreason.size > 0
59
+ r = argvs.reason || ''
60
+ if r.size > 0
65
61
  # Do not overwrite the reason
66
- return false if currreason =~ reexcludes
62
+ return false if r.start_with?('securityerror', 'systemerror', 'undefined')
67
63
  else
68
64
  # Check the value of Diagnosic-Code: header with patterns
69
- return true if Sisimai::Reason::NoRelaying.match(argvs.diagnosticcode)
65
+ return true if match(argvs.diagnosticcode.downcase)
70
66
  end
71
-
72
67
  return false
73
68
  end
74
69
 
@@ -12,9 +12,7 @@ module Sisimai
12
12
  # Imported from p5-Sisimail/lib/Sisimai/Reason/NotAccept.pm
13
13
  class << self
14
14
  def text; return 'notaccept'; end
15
- def description
16
- return 'Delivery failed due to a destination mail server does not accept any email'
17
- end
15
+ def description; return 'Delivery failed due to a destination mail server does not accept any email'; end
18
16
 
19
17
  # Try to match that the given text and regular expressions
20
18
  # @param [String] argv1 String to be matched with regular expressions
@@ -25,10 +23,10 @@ module Sisimai
25
23
 
26
24
  # Destination mail server does not accept any message
27
25
  regex = %r{(?:
28
- Name[ ]server:[ ][.]:[ ]host[ ]not[ ]found # Sendmail
26
+ name[ ]server:[ ][.]:[ ]host[ ]not[ ]found # Sendmail
29
27
  |55[46][ ]smtp[ ]protocol[ ]returned[ ]a[ ]permanent[ ]error
30
28
  )
31
- }ix
29
+ }x
32
30
 
33
31
  return true if argv1 =~ regex
34
32
  return false
@@ -42,23 +40,13 @@ module Sisimai
42
40
  def true(argvs)
43
41
  return nil unless argvs
44
42
  return nil unless argvs.is_a? Sisimai::Data
45
- return true if argvs.reason == Sisimai::Reason::NotAccept.text
46
-
47
- diagnostic = argvs.diagnosticcode || ''
48
- v = false
43
+ return true if argvs.reason == 'notaccept'
49
44
 
50
- if argvs.replycode =~ /\A(?:521|554|556)\z/
51
- # SMTP Reply Code is 554 or 556
52
- v = false
53
- else
54
- # Check the value of Diagnosic-Code: header with patterns
55
- if argvs.smtpcommand == 'MAIL'
56
- # Matched with a pattern in this class
57
- v = true if Sisimai::Reason::NotAccept.match(diagnostic)
58
- end
59
- end
60
-
61
- return v
45
+ # SMTP Reply Code is 554 or 556
46
+ return true if [521, 554, 556].index(argvs.replycode.to_i)
47
+ return false if argvs.smtpcommand == 'MAIL'
48
+ return true if match(argvs.diagnosticcode.downcase)
49
+ return false
62
50
  end
63
51
 
64
52
  end
@@ -9,9 +9,7 @@ module Sisimai
9
9
  # Imported from p5-Sisimail/lib/Sisimai/Reason/OnHold.pm
10
10
  class << self
11
11
  def text; return 'onhold'; end
12
- def description
13
- return 'Sisimai could not decided the reason due to there is no (or less) detailed information for judging the reason'
14
- end
12
+ def description; return 'Sisimai could not decided the reason due to there is no (or less) detailed information for judging the reason'; end
15
13
 
16
14
  # Try to match that the given text and regular expressions
17
15
  # @param [String] argv1 String to be matched with regular expressions
@@ -30,13 +28,10 @@ module Sisimai
30
28
  return nil unless argvs
31
29
  return nil unless argvs.is_a? Sisimai::Data
32
30
  return nil unless argvs.deliverystatus.size > 0
33
- return true if argvs.reason == Sisimai::Reason::OnHold.text
34
-
35
- statuscode = argvs.deliverystatus || ''
36
- reasontext = Sisimai::Reason::OnHold.text
31
+ return true if argvs.reason == 'onhold'
37
32
 
38
33
  require 'sisimai/smtp/status'
39
- return true if Sisimai::SMTP::Status.name(statuscode) == reasontext
34
+ return true if Sisimai::SMTP::Status.name(argvs.deliverystatus) == 'onhold'
40
35
  return false
41
36
  end
42
37
  end
@@ -17,9 +17,7 @@ module Sisimai
17
17
  # Imported from p5-Sisimail/lib/Sisimai/Reason/PolicyViolation.pm
18
18
  class << self
19
19
  def text; return 'policyviolation'; end
20
- def description
21
- return 'Email rejected due to policy violation on a destination host'
22
- end
20
+ def description; return 'Email rejected due to policy violation on a destination host'; end
23
21
 
24
22
  # Try to match that the given text and regular expressions
25
23
  # @param [String] argv1 String to be matched with regular expressions
@@ -31,24 +29,24 @@ module Sisimai
31
29
  regex = %r{(?>
32
30
  because[ ]the[ ]recipient[ ]is[ ]not[ ]accepting[ ]mail[ ]with[ ](?:attachments|embedded[ ]images) # AOL Phoenix
33
31
  |closed[ ]mailing[ ]list
34
- |Denied[ ]by[ ]policy
32
+ |denied[ ]by[ ]policy
35
33
  |email[ ](?:
36
34
  not[ ]accepted[ ]for[ ]policy[ ]reasons
37
35
  # http://kb.mimecast.com/Mimecast_Knowledge_Base/Administration_Console/Monitoring/Mimecast_SMTP_Error_Codes#554
38
36
  |rejected[ ]due[ ]to[ ]security[ ]policies
39
37
  )
40
38
  |header[ ](?:are[ ]not[ ]accepted|error)
41
- |Mail[ ]from[ ].+[ ]rejected[ ]for[ ]policy[ ]reasons
39
+ |mail[ ]from[ ].+[ ]rejected[ ]for[ ]policy[ ]reasons
42
40
  |message[ ](?:
43
41
  given[ ]low[ ]priority
44
42
  |not[ ]accepted[ ]for[ ]policy[ ]reasons
45
43
  )
46
- |Messages[ ]with[ ]multiple[ ]addresses
47
- |You[ ]have[ ]exceeded[ ]the[ ]the[ ]allowable[ ]number[ ]of[ ]posts[ ]without[ ]solving[ ]a[ ]captcha
48
- |Protocol[ ]violation
49
- |The[ ]email[ ]address[ ]used[ ]to[ ]send[ ]your[ ]message[ ]is[ ]not[ ]subscribed[ ]to[ ]this[ ]group
44
+ |messages[ ]with[ ]multiple[ ]addresses
45
+ |you[ ]have[ ]exceeded[ ]the[ ]the[ ]allowable[ ]number[ ]of[ ]posts[ ]without[ ]solving[ ]a[ ]captcha
46
+ |protocol[ ]violation
47
+ |the[ ]email[ ]address[ ]used[ ]to[ ]send[ ]your[ ]message[ ]is[ ]not[ ]subscribed[ ]to[ ]this[ ]group
50
48
  )
51
- }ix
49
+ }x
52
50
 
53
51
  return true if argv1 =~ regex
54
52
  return false
@@ -16,9 +16,7 @@ module Sisimai
16
16
  # Imported from p5-Sisimail/lib/Sisimai/Reason/Rejected.pm
17
17
  class << self
18
18
  def text; return 'rejected'; end
19
- def description
20
- return "Email rejected due to a sender's email address (envelope from)"
21
- end
19
+ def description; return "Email rejected due to a sender's email address (envelope from)"; end
22
20
 
23
21
  # Try to match that the given text and regular expressions
24
22
  # @param [String] argv1 String to be matched with regular expressions
@@ -26,43 +24,43 @@ module Sisimai
26
24
  # true: Matched
27
25
  def match(argv1)
28
26
  return nil unless argv1
29
- isnot = %r{(?:5[.]1[.]0[ ]Address
30
- |Recipient[ ]address
31
- |Sender[ ]IP[ ]address
27
+ isnot = %r{(?:5[.]1[.]0[ ]address
28
+ |recipient[ ]address
29
+ |sender[ ]ip[ ]address
32
30
  )[ ]rejected
33
- }xi
31
+ }x
34
32
  regex = %r{(?>
35
33
  [<][>][ ]invalid[ ]sender
36
34
  |address[ ]rejected
37
- |Administrative[ ]prohibition
35
+ |administrative[ ]prohibition
38
36
  |batv[ ](?:
39
37
  failed[ ]to[ ]verify # SoniWall
40
38
  |validation[ ]failure # SoniWall
41
39
  )
42
40
  |backscatter[ ]protection[ ]detected[ ]an[ ]invalid[ ]or[ ]expired[ ]email[ ]address # MDaemon
43
41
  |bogus[ ]mail[ ]from # IMail - block empty sender
44
- |Connections[ ]not[ ]accepted[ ]from[ ]servers[ ]without[ ]a[ ]valid[ ]sender[ ]domain
42
+ |connections[ ]not[ ]accepted[ ]from[ ]servers[ ]without[ ]a[ ]valid[ ]sender[ ]domain
45
43
  |denied[ ]\[bouncedeny\] # McAfee
46
- |Delivery[ ]not[ ]authorized,[ ]message[ ]refused
47
- |does[ ]not[ ]exist[ ]E2110
44
+ |delivery[ ]not[ ]authorized,[ ]message[ ]refused
45
+ |does[ ]not[ ]exist[ ]e2110
48
46
  |domain[ ]of[ ]sender[ ]address[ ].+[ ]does[ ]not[ ]exist
49
- |Emetteur[ ]invalide.+[A-Z]{3}.+(?:403|405|415)
47
+ |emetteur[ ]invalide.+[a-z]{3}.+(?:403|405|415)
50
48
  |empty[ ]envelope[ ]senders[ ]not[ ]allowed
51
49
  |error:[ ]no[ ]third-party[ ]dsns # SpamWall - block empty sender
52
- |From:[ ]Domain[ ]is[ ]invalid[.][ ]Please[ ]provide[ ]a[ ]valid[ ]From:
50
+ |from:[ ]domain[ ]is[ ]invalid[.][ ]please[ ]provide[ ]a[ ]valid[ ]from:
53
51
  |fully[ ]qualified[ ]email[ ]address[ ]required # McAfee
54
52
  |invalid[ ]domain,[ ]see[ ][<]url:.+[>]
55
- |Mail[ ]from[ ]not[ ]owned[ ]by[ ]user.+[A-Z]{3}.+421
56
- |Message[ ]rejected:[ ]Email[ ]address[ ]is[ ]not[ ]verified
53
+ |mail[ ]from[ ]not[ ]owned[ ]by[ ]user.+[a-z]{3}.+421
54
+ |message[ ]rejected:[ ]email[ ]address[ ]is[ ]not[ ]verified
57
55
  |mx[ ]records[ ]for[ ].+[ ]violate[ ]section[ ].+
58
- |Null[ ]Sender[ ]is[ ]not[ ]allowed
56
+ |null[ ]sender[ ]is[ ]not[ ]allowed
59
57
  |recipient[ ]not[ ]accepted[.][ ][(]batv:[ ]no[ ]tag
60
58
  |returned[ ]mail[ ]not[ ]accepted[ ]here
61
59
  |rfc[ ]1035[ ]violation:[ ]recursive[ ]cname[ ]records[ ]for
62
60
  |rule[ ]imposed[ ]mailbox[ ]access[ ]for # MailMarshal
63
61
  |sender[ ](?:
64
62
  email[ ]address[ ]rejected
65
- |is[ ]Spammer
63
+ |is[ ]spammer
66
64
  |not[ ]pre[-]approved
67
65
  |rejected
68
66
  |domain[ ]is[ ]empty
@@ -71,10 +69,10 @@ module Sisimai
71
69
  |syntax[ ]error:[ ]empty[ ]email[ ]address
72
70
  |the[ ]message[ ]has[ ]been[ ]rejected[ ]by[ ]batv[ ]defense
73
71
  |transaction[ ]failed[ ]unsigned[ ]dsn[ ]for
74
- |Unroutable[ ]sender[ ]address
72
+ |unroutable[ ]sender[ ]address
75
73
  |you[ ]are[ ]sending[ ]to[/]from[ ]an[ ]address[ ]that[ ]has[ ]been[ ]blacklisted
76
74
  )
77
- }ix
75
+ }x
78
76
 
79
77
  return false if argv1 =~ isnot
80
78
  return true if argv1 =~ regex
@@ -91,41 +89,30 @@ module Sisimai
91
89
  return nil unless argvs.is_a? Sisimai::Data
92
90
 
93
91
  require 'sisimai/smtp/status'
94
- statuscode = argvs.deliverystatus || ''
95
- reasontext = Sisimai::Reason::Rejected.text
96
-
97
- return true if argvs.reason == reasontext
98
-
99
- tempreason = Sisimai::SMTP::Status.name(statuscode)
92
+ tempreason = Sisimai::SMTP::Status.name(argvs.deliverystatus)
100
93
  tempreason = 'undefined' if tempreason.empty?
101
- diagnostic = argvs.diagnosticcode || ''
102
- v = false
94
+ diagnostic = argvs.diagnosticcode.downcase
103
95
 
104
- if tempreason == reasontext
105
- # Delivery status code points "rejected".
106
- v = true
107
- else
108
- # Check the value of Diagnosic-Code: header with patterns
109
- if argvs.smtpcommand == 'MAIL'
110
- # The session was rejected at 'MAIL FROM' command
111
- v = true if Sisimai::Reason::Rejected.match(diagnostic)
96
+ return true if argvs.reason == 'rejected'
97
+ return true if tempreason == 'rejected' # Delivery status code points "rejected".
112
98
 
113
- elsif argvs.smtpcommand == 'DATA'
114
- # The session was rejected at 'DATA' command
115
- if tempreason != 'userunknown'
116
- # Except "userunknown"
117
- v = true if Sisimai::Reason::Rejected.match(diagnostic)
118
- end
119
- else
120
- if tempreason =~ /\A(?:onhold|undefined|securityerror|systemerror)\z/
121
- # Try to match with message patterns when the temporary reason
122
- # is "onhold", "undefined", "securityerror", or "systemerror"
123
- v = true if Sisimai::Reason::Rejected.match(diagnostic)
124
- end
99
+ # Check the value of Diagnosic-Code: header with patterns
100
+ if argvs.smtpcommand == 'MAIL'
101
+ # The session was rejected at 'MAIL FROM' command
102
+ return true if match(diagnostic)
103
+
104
+ elsif argvs.smtpcommand == 'DATA'
105
+ # The session was rejected at 'DATA' command
106
+ if tempreason != 'userunknown'
107
+ # Except "userunknown"
108
+ return true if match(diagnostic)
125
109
  end
110
+ elsif %w[onhold undefined securityerror systemerror].include?(tempreason)
111
+ # Try to match with message patterns when the temporary reason
112
+ # is "onhold", "undefined", "securityerror", or "systemerror"
113
+ return true if match(diagnostic)
126
114
  end
127
-
128
- return v
115
+ return false
129
116
  end
130
117
 
131
118
  end