sisimai 4.25.16-java → 5.0.2-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 (180) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/rake-test.yml +55 -0
  3. data/.travis.yml +3 -3
  4. data/ANALYTICAL-PRECISION +2 -2
  5. data/Benchmarks.mk +3 -3
  6. data/CONTRIBUTING +1 -1
  7. data/ChangeLog.md +451 -393
  8. data/Developers.mk +5 -6
  9. data/Gemfile +1 -1
  10. data/Makefile +15 -15
  11. data/README-JA.md +323 -149
  12. data/README.md +319 -149
  13. data/Rakefile +9 -3
  14. data/Repository.mk +2 -3
  15. data/lib/sisimai/address.rb +118 -74
  16. data/lib/sisimai/arf.rb +84 -82
  17. data/lib/sisimai/datetime.rb +5 -52
  18. data/lib/sisimai/{data → fact}/json.rb +7 -9
  19. data/lib/sisimai/fact/yaml.rb +31 -0
  20. data/lib/sisimai/fact.rb +506 -0
  21. data/lib/sisimai/lhost/activehunter.rb +12 -14
  22. data/lib/sisimai/lhost/amavis.rb +11 -14
  23. data/lib/sisimai/lhost/amazonses.rb +37 -42
  24. data/lib/sisimai/lhost/amazonworkmail.rb +15 -19
  25. data/lib/sisimai/lhost/aol.rb +12 -15
  26. data/lib/sisimai/lhost/apachejames.rb +19 -21
  27. data/lib/sisimai/lhost/barracuda.rb +10 -12
  28. data/lib/sisimai/lhost/bigfoot.rb +21 -22
  29. data/lib/sisimai/lhost/biglobe.rb +15 -16
  30. data/lib/sisimai/lhost/courier.rb +20 -20
  31. data/lib/sisimai/lhost/domino.rb +23 -20
  32. data/lib/sisimai/lhost/einsundeins.rb +23 -18
  33. data/lib/sisimai/lhost/exchange2003.rb +30 -29
  34. data/lib/sisimai/lhost/exchange2007.rb +70 -58
  35. data/lib/sisimai/lhost/exim.rb +179 -174
  36. data/lib/sisimai/lhost/ezweb.rb +31 -56
  37. data/lib/sisimai/lhost/facebook.rb +21 -34
  38. data/lib/sisimai/lhost/fml.rb +43 -48
  39. data/lib/sisimai/lhost/gmail.rb +29 -29
  40. data/lib/sisimai/lhost/gmx.rb +18 -17
  41. data/lib/sisimai/lhost/googlegroups.rb +11 -11
  42. data/lib/sisimai/lhost/gsuite.rb +21 -28
  43. data/lib/sisimai/lhost/imailserver.rb +25 -39
  44. data/lib/sisimai/lhost/interscanmss.rb +28 -31
  45. data/lib/sisimai/lhost/kddi.rb +22 -28
  46. data/lib/sisimai/lhost/mailfoundry.rb +11 -12
  47. data/lib/sisimai/lhost/mailmarshalsmtp.rb +25 -29
  48. data/lib/sisimai/lhost/mailru.rb +37 -40
  49. data/lib/sisimai/lhost/mcafee.rb +21 -31
  50. data/lib/sisimai/lhost/messagelabs.rb +17 -21
  51. data/lib/sisimai/lhost/messagingserver.rb +40 -37
  52. data/lib/sisimai/lhost/mfilter.rb +16 -17
  53. data/lib/sisimai/lhost/mxlogic.rb +24 -33
  54. data/lib/sisimai/lhost/notes.rb +17 -17
  55. data/lib/sisimai/lhost/office365.rb +64 -28
  56. data/lib/sisimai/lhost/opensmtpd.rb +12 -13
  57. data/lib/sisimai/lhost/outlook.rb +12 -16
  58. data/lib/sisimai/lhost/postfix.rb +179 -130
  59. data/lib/sisimai/lhost/powermta.rb +12 -14
  60. data/lib/sisimai/lhost/qmail.rb +44 -47
  61. data/lib/sisimai/lhost/receivingses.rb +15 -21
  62. data/lib/sisimai/lhost/sendgrid.rb +34 -34
  63. data/lib/sisimai/lhost/sendmail.rb +65 -53
  64. data/lib/sisimai/lhost/surfcontrol.rb +19 -19
  65. data/lib/sisimai/lhost/v5sendmail.rb +45 -39
  66. data/lib/sisimai/lhost/verizon.rb +35 -39
  67. data/lib/sisimai/lhost/x1.rb +18 -17
  68. data/lib/sisimai/lhost/x2.rb +17 -14
  69. data/lib/sisimai/lhost/x3.rb +19 -19
  70. data/lib/sisimai/lhost/x4.rb +72 -57
  71. data/lib/sisimai/lhost/x5.rb +17 -19
  72. data/lib/sisimai/lhost/x6.rb +41 -17
  73. data/lib/sisimai/lhost/yahoo.rb +17 -16
  74. data/lib/sisimai/lhost/yandex.rb +16 -21
  75. data/lib/sisimai/lhost/zoho.rb +16 -15
  76. data/lib/sisimai/lhost.rb +8 -10
  77. data/lib/sisimai/mail/maildir.rb +1 -3
  78. data/lib/sisimai/mail/mbox.rb +3 -4
  79. data/lib/sisimai/mail/memory.rb +0 -1
  80. data/lib/sisimai/mail/stdin.rb +1 -3
  81. data/lib/sisimai/mail.rb +3 -7
  82. data/lib/sisimai/mda.rb +28 -42
  83. data/lib/sisimai/message.rb +444 -326
  84. data/lib/sisimai/order.rb +5 -5
  85. data/lib/sisimai/reason/authfailure.rb +65 -0
  86. data/lib/sisimai/reason/badreputation.rb +53 -0
  87. data/lib/sisimai/reason/blocked.rb +96 -160
  88. data/lib/sisimai/reason/contenterror.rb +8 -9
  89. data/lib/sisimai/reason/delivered.rb +4 -6
  90. data/lib/sisimai/reason/exceedlimit.rb +10 -12
  91. data/lib/sisimai/reason/expired.rb +7 -8
  92. data/lib/sisimai/reason/feedback.rb +2 -3
  93. data/lib/sisimai/reason/filtered.rb +17 -19
  94. data/lib/sisimai/reason/hasmoved.rb +9 -10
  95. data/lib/sisimai/reason/hostunknown.rb +15 -15
  96. data/lib/sisimai/reason/mailboxfull.rb +11 -12
  97. data/lib/sisimai/reason/mailererror.rb +18 -20
  98. data/lib/sisimai/reason/mesgtoobig.rb +9 -11
  99. data/lib/sisimai/reason/networkerror.rb +5 -8
  100. data/lib/sisimai/reason/norelaying.rb +8 -11
  101. data/lib/sisimai/reason/notaccept.rb +13 -14
  102. data/lib/sisimai/reason/notcompliantrfc.rb +43 -0
  103. data/lib/sisimai/reason/onhold.rb +6 -9
  104. data/lib/sisimai/reason/policyviolation.rb +14 -12
  105. data/lib/sisimai/reason/rejected.rb +26 -24
  106. data/lib/sisimai/reason/requireptr.rb +69 -0
  107. data/lib/sisimai/reason/securityerror.rb +34 -36
  108. data/lib/sisimai/reason/spamdetected.rb +115 -147
  109. data/lib/sisimai/reason/speeding.rb +49 -0
  110. data/lib/sisimai/reason/suspend.rb +12 -11
  111. data/lib/sisimai/reason/syntaxerror.rb +11 -10
  112. data/lib/sisimai/reason/systemerror.rb +7 -9
  113. data/lib/sisimai/reason/systemfull.rb +7 -8
  114. data/lib/sisimai/reason/toomanyconn.rb +9 -11
  115. data/lib/sisimai/reason/undefined.rb +2 -3
  116. data/lib/sisimai/reason/userunknown.rb +129 -146
  117. data/lib/sisimai/reason/vacation.rb +3 -4
  118. data/lib/sisimai/reason/virusdetected.rb +10 -11
  119. data/lib/sisimai/reason.rb +59 -64
  120. data/lib/sisimai/rfc1894.rb +55 -28
  121. data/lib/sisimai/rfc2045.rb +373 -0
  122. data/lib/sisimai/rfc3464.rb +250 -308
  123. data/lib/sisimai/rfc3834.rb +42 -45
  124. data/lib/sisimai/rfc5322.rb +177 -146
  125. data/lib/sisimai/rfc5965.rb +31 -0
  126. data/lib/sisimai/rhost/cox.rb +5 -6
  127. data/lib/sisimai/rhost/franceptt.rb +6 -8
  128. data/lib/sisimai/rhost/godaddy.rb +12 -12
  129. data/lib/sisimai/rhost/google.rb +530 -0
  130. data/lib/sisimai/rhost/iua.rb +9 -10
  131. data/lib/sisimai/rhost/kddi.rb +6 -8
  132. data/lib/sisimai/rhost/{exchangeonline.rb → microsoft.rb} +115 -114
  133. data/lib/sisimai/rhost/mimecast.rb +51 -42
  134. data/lib/sisimai/rhost/nttdocomo.rb +12 -12
  135. data/lib/sisimai/rhost/spectrum.rb +10 -12
  136. data/lib/sisimai/rhost/{tencentqq.rb → tencent.rb} +7 -8
  137. data/lib/sisimai/rhost.rb +23 -31
  138. data/lib/sisimai/smtp/command.rb +59 -0
  139. data/lib/sisimai/smtp/error.rb +4 -7
  140. data/lib/sisimai/smtp/reply.rb +161 -74
  141. data/lib/sisimai/smtp/status.rb +507 -393
  142. data/lib/sisimai/smtp/transcript.rb +124 -0
  143. data/lib/sisimai/smtp.rb +0 -1
  144. data/lib/sisimai/string.rb +74 -5
  145. data/lib/sisimai/time.rb +1 -2
  146. data/lib/sisimai/version.rb +1 -1
  147. data/lib/sisimai.rb +46 -31
  148. data/set-of-emails/maildir/bsd/lhost-domino-02.eml +6 -3
  149. data/set-of-emails/maildir/bsd/lhost-googlegroups-15.eml +174 -0
  150. data/set-of-emails/maildir/bsd/lhost-gsuite-15.eml +229 -0
  151. data/set-of-emails/maildir/bsd/lhost-postfix-75.eml +51 -0
  152. data/set-of-emails/maildir/bsd/lhost-postfix-76.eml +101 -0
  153. data/set-of-emails/maildir/bsd/lhost-postfix-77.eml +74 -0
  154. data/set-of-emails/maildir/bsd/lhost-postfix-78.eml +91 -0
  155. data/set-of-emails/maildir/bsd/lhost-receivingses-08.eml +88 -0
  156. data/set-of-emails/maildir/bsd/lhost-sendmail-60.eml +85 -0
  157. data/set-of-emails/maildir/bsd/rfc3464-43.eml +88 -0
  158. data/set-of-emails/maildir/bsd/rhost-google-03.eml +101 -0
  159. data/set-of-emails/maildir/bsd/rhost-google-04.eml +102 -0
  160. data/set-of-emails/maildir/bsd/rhost-google-05.eml +82 -0
  161. data/set-of-emails/maildir/bsd/rhost-google-06.eml +102 -0
  162. data/set-of-emails/maildir/bsd/rhost-google-07.eml +69 -0
  163. data/set-of-emails/maildir/bsd/rhost-google-08.eml +99 -0
  164. data/sisimai-java.gemspec +1 -1
  165. data/sisimai.gemspec +1 -1
  166. metadata +48 -26
  167. data/.rspec +0 -2
  168. data/lib/sisimai/data/yaml.rb +0 -33
  169. data/lib/sisimai/data.rb +0 -411
  170. data/lib/sisimai/mime.rb +0 -456
  171. data/lib/sisimai/rhost/googleapps.rb +0 -261
  172. /data/set-of-emails/maildir/bsd/{rfc3464-41.eml → rfc3834-05.eml} +0 -0
  173. /data/set-of-emails/maildir/bsd/{rhost-googleapps-01.eml → rhost-google-01.eml} +0 -0
  174. /data/set-of-emails/maildir/bsd/{rhost-googleapps-02.eml → rhost-google-02.eml} +0 -0
  175. /data/set-of-emails/maildir/bsd/{rhost-exchangeonline-01.eml → rhost-microsoft-01.eml} +0 -0
  176. /data/set-of-emails/maildir/bsd/{rhost-exchangeonline-02.eml → rhost-microsoft-02.eml} +0 -0
  177. /data/set-of-emails/maildir/bsd/{rhost-exchangeonline-03.eml → rhost-microsoft-03.eml} +0 -0
  178. /data/set-of-emails/maildir/bsd/{rhost-tencentqq-01.eml → rhost-tencent-01.eml} +0 -0
  179. /data/set-of-emails/maildir/bsd/{rhost-tencentqq-02.eml → rhost-tencent-02.eml} +0 -0
  180. /data/set-of-emails/maildir/bsd/{rhost-tencentqq-03.eml → rhost-tencent-03.eml} +0 -0
@@ -1,12 +1,11 @@
1
1
  module Sisimai
2
2
  module Reason
3
- # Sisimai::Reason::PolicyViolation checks the bounce reason is "policyviolation"
4
- # or not. This class is called only Sisimai::Reason class.
3
+ # Sisimai::Reason::PolicyViolation checks the bounce reason is "policyviolation" or not. This class
4
+ # is called only Sisimai::Reason class.
5
5
  #
6
- # This is the error that a policy violation was detected on a destination mail
7
- # host. When a header content or a format of the original message violates
8
- # security policies, or multiple addresses exist in the From: header, Sisimai
9
- # will set "policyviolation".
6
+ # This is the error that a policy violation was detected on a destination mail host. When a header
7
+ # content or a format of the original message violates security policies, or multiple addresses
8
+ # exist in the From: header, Sisimai will set "policyviolation".
10
9
  #
11
10
  # Status: 5.7.0
12
11
  # Remote-MTA: DNS; gmail-smtp-in.l.google.com
@@ -14,15 +13,15 @@ module Sisimai
14
13
  # Last-Attempt-Date: Tue, 28 Apr 2009 11:02:45 +0900 (JST)
15
14
  #
16
15
  module PolicyViolation
17
- # Imported from p5-Sisimail/lib/Sisimai/Reason/PolicyViolation.pm
18
16
  class << self
17
+ require 'sisimai/string'
18
+
19
19
  Index = [
20
20
  'an illegal attachment on your message',
21
21
  'because the recipient is not accepting mail with ', # AOL Phoenix
22
22
  'by non-member to a members-only list',
23
23
  'closed mailing list',
24
24
  'denied by policy',
25
- 'dmarc policy',
26
25
  'email not accepted for policy reasons',
27
26
  # http://kb.mimecast.com/Mimecast_Knowledge_Base/Administration_Console/Monitoring/Mimecast_SMTP_Error_Codes#554
28
27
  'email rejected due to security policies',
@@ -40,9 +39,11 @@ module Sisimai
40
39
  'the message was rejected by organization policy',
41
40
  'this message was blocked because its content presents a potential',
42
41
  'we do not accept messages containing images or other attachments',
43
- 'you have exceeded the allowable number of posts without solving a captcha',
44
- 'you have exceeded the the allowable number of posts without solving a captcha',
45
- ]
42
+ "you're using a mass mailer",
43
+ ].freeze
44
+ Pairs = [
45
+ ['you have exceeded the', 'allowable number of posts without solving a captcha'],
46
+ ].freeze
46
47
 
47
48
  def text; return 'policyviolation'; end
48
49
  def description; return 'Email rejected due to policy violation on a destination host'; end
@@ -55,11 +56,12 @@ module Sisimai
55
56
  def match(argv1)
56
57
  return nil unless argv1
57
58
  return true if Index.any? { |a| argv1.include?(a) }
59
+ return true if Pairs.any? { |a| Sisimai::String.aligned(argv1, a) }
58
60
  return false
59
61
  end
60
62
 
61
63
  # The bounce reason is "policyviolation" or not
62
- # @param [Sisimai::Data] argvs Object to be detected the reason
64
+ # @param [Sisimai::Fact] argvs Object to be detected the reason
63
65
  # @return [True,False] true: is policy violation
64
66
  # false: is not policy violation
65
67
  # @since 4.22.0
@@ -1,25 +1,23 @@
1
1
  module Sisimai
2
2
  module Reason
3
- # Sisimai::Reason::Rejected checks the bounce reason is "rejected" or not.
4
- # This class is called only Sisimai::Reason class.
3
+ # Sisimai::Reason::Rejected checks the bounce reason is "rejected" or not. This class is called
4
+ # only Sisimai::Reason class.
5
5
  #
6
- # This is the error that a connection to destination server was rejected by
7
- # a sender's email address (envelope from). Sisimai set "rejected" to the
8
- # reason of email bounce if the value of Status: field in a bounce email is
9
- # "5.1.8" or the connection has been rejected due to the argument of SMTP
10
- # MAIL command.
6
+ # This is the error that a connection to destination server was rejected by a sender's email
7
+ # address (envelope from). Sisimai set "rejected" to the reason of email bounce if the value of
8
+ # Status: field in a bounce email is "5.1.8" or the connection has been rejected due to the
9
+ # argument of SMTP MAIL command.
11
10
  #
12
11
  # <kijitora@example.org>:
13
12
  # Connected to 192.0.2.225 but sender was rejected.
14
13
  # Remote host said: 550 5.7.1 <root@nijo.example.jp>... Access denied
15
14
  module Rejected
16
- # Imported from p5-Sisimail/lib/Sisimai/Reason/Rejected.pm
17
15
  class << self
18
16
  IsNot = [
19
17
  '5.1.0 address rejected',
20
18
  'recipient address rejected',
21
19
  'sender ip address rejected',
22
- ]
20
+ ].freeze
23
21
  Index = [
24
22
  'access denied (in reply to mail from command)',
25
23
  'access denied (sender blacklisted)',
@@ -30,6 +28,7 @@ module Sisimai
30
28
  'backscatter protection detected an invalid or expired email address', # MDaemon
31
29
  "because the sender isn't on the recipient's list of senders to accept mail from",
32
30
  'bogus mail from', # IMail - block empty sender
31
+ "can't determine purported responsible address",
33
32
  'connections not accepted from servers without a valid sender domain',
34
33
  'denied [bouncedeny]', # McAfee
35
34
  'denied by secumail valid-address-filter',
@@ -55,6 +54,7 @@ module Sisimai
55
54
  'returned mail not accepted here',
56
55
  'rfc 1035 violation: recursive cname records for',
57
56
  'rule imposed mailbox access for', # MailMarshal
57
+ 'sending this from a different address or alias using the ',
58
58
  'sender address has been blacklisted',
59
59
  'sender email address rejected',
60
60
  'sender is in my black list',
@@ -62,7 +62,8 @@ module Sisimai
62
62
  'sender not pre-approved',
63
63
  'sender rejected',
64
64
  'sender domain is empty',
65
- 'sender verify failed', # Exim callout
65
+ 'sender verify failed', # Exim callout
66
+ 'spam reporting address', # SendGrid|a message to an address has previously been marked as Spam by the recipient.
66
67
  'syntax error: empty email address',
67
68
  'the message has been rejected by batv defense',
68
69
  'this server does not accept mail from',
@@ -70,8 +71,9 @@ module Sisimai
70
71
  'unroutable sender address',
71
72
  'you are not allowed to post to this mailing list',
72
73
  'you are sending to/from an address that has been blacklisted',
73
- 'your access to submit messages to this e-mail system has been rejected'
74
- ]
74
+ 'your access to submit messages to this e-mail system has been rejected',
75
+ 'your email address has been blacklisted', # MessageLabs
76
+ ].freeze
75
77
 
76
78
  def text; return 'rejected'; end
77
79
  def description; return "Email rejected due to a sender's email address (envelope from)"; end
@@ -88,32 +90,32 @@ module Sisimai
88
90
  end
89
91
 
90
92
  # Rejected by the envelope sender address or not
91
- # @param [Sisimai::Data] argvs Object to be detected the reason
93
+ # @param [Sisimai::Fact] argvs Object to be detected the reason
92
94
  # @return [True,False] true: is rejected
93
95
  # false: is not rejected by the sender
94
96
  # @see http://www.ietf.org/rfc/rfc2822.txt
95
97
  def true(argvs)
96
- return true if argvs.reason == 'rejected'
97
- tempreason = Sisimai::SMTP::Status.name(argvs.deliverystatus) || 'undefined'
98
+ return true if argvs['reason'] == 'rejected'
99
+ tempreason = Sisimai::SMTP::Status.name(argvs['deliverystatus']) || 'undefined'
98
100
  return true if tempreason == 'rejected' # Delivery status code points "rejected".
99
101
 
100
102
  # Check the value of Diagnosic-Code: header with patterns
101
- diagnostic = argvs.diagnosticcode.downcase
102
- commandtxt = argvs.smtpcommand
103
- if commandtxt == 'MAIL'
103
+ issuedcode = argvs['diagnosticcode'].downcase
104
+ thecommand = argvs['smtpcommand'] || ''
105
+ if thecommand == 'MAIL'
104
106
  # The session was rejected at 'MAIL FROM' command
105
- return true if match(diagnostic)
107
+ return true if match(issuedcode)
106
108
 
107
- elsif commandtxt == 'DATA'
109
+ elsif thecommand == 'DATA'
108
110
  # The session was rejected at 'DATA' command
109
111
  if tempreason != 'userunknown'
110
112
  # Except "userunknown"
111
- return true if match(diagnostic)
113
+ return true if match(issuedcode)
112
114
  end
113
115
  elsif %w[onhold undefined securityerror systemerror].include?(tempreason)
114
- # Try to match with message patterns when the temporary reason
115
- # is "onhold", "undefined", "securityerror", or "systemerror"
116
- return true if match(diagnostic)
116
+ # Try to match with message patterns when the temporary reason is "onhold", "undefined",
117
+ # "securityerror", or "systemerror"
118
+ return true if match(issuedcode)
117
119
  end
118
120
  return false
119
121
  end
@@ -0,0 +1,69 @@
1
+ module Sisimai
2
+ module Reason
3
+ # Sisimai::Reason::RequirePTR checks the bounce reason is "requireptr" or not. This class is
4
+ # called only from Sisimai::Reason class. This is the error that SMTP connection was rejected
5
+ # due to missing PTR record or having invalid PTR record at the source IP address used for the
6
+ # SMTP connection.
7
+ module RequirePTR
8
+ class << self
9
+ require 'sisimai/string'
10
+
11
+ Index = [
12
+ 'access denied. ip name lookup failed',
13
+ 'all mail servers must have a ptr record with a valid reverse dns entry',
14
+ 'bad dns ptr resource record',
15
+ 'cannot find your hostname',
16
+ 'client host rejected: cannot find your hostname', # Yahoo!
17
+ 'fix reverse dns for ',
18
+ 'ips with missing ptr records',
19
+ 'no ptr record found.',
20
+ 'please get a custom reverse dns name from your isp for your host',
21
+ 'ptr record setup',
22
+ 'reverse dns failed',
23
+ 'reverse dns required',
24
+ 'sender ip reverse lookup rejected',
25
+ 'the ip address sending this message does not have a ptr record setup', # Google
26
+ 'the corresponding forward dns entry does not point to the sending ip', # Google
27
+ 'this system will not accept messages from servers/devices with no reverse dns',
28
+ 'unresolvable relay host name',
29
+ 'we do not accept mail from hosts with dynamic ip or generic dns ptr-records',
30
+ ].freeze
31
+ Pairs = [
32
+ ['domain ',' mismatches client ip'],
33
+ ['dns lookup failure: ', ' try again later'],
34
+ ['reverse dns lookup for host ', ' failed permanently'],
35
+ ['server access ', ' forbidden by invalid rdns record of your mail server'],
36
+ ['service permits ', ' unverifyable sending ips'],
37
+ ].freeze
38
+
39
+ def text; return 'requireptr'; end
40
+ def description; return 'Email rejected due to missing PTR record or having invalid PTR record'; end
41
+
42
+ # Try to match that the given text and regular expressions
43
+ # @param [String] argv1 String to be matched with regular expressions
44
+ # @return [True,False] false: Did not match
45
+ # true: Matched
46
+ def match(argv1)
47
+ return nil unless argv1
48
+ return true if Index.any? { |a| argv1.include?(a) }
49
+ return true if Pairs.any? { |a| Sisimai::String.aligned(argv1, a) }
50
+ return false
51
+ end
52
+
53
+ # Check the email rejected due to missing PTR record or having invalid PTR record OR not
54
+ # @param [Hash] argvs Hash to be detected the value of reason
55
+ # @return [true,false] true: is missing PTR or invalid PTR
56
+ # false: is not blocked due to missing PTR record
57
+ # @see http://www.ietf.org/rfc/rfc5322.txt
58
+ def true(argvs)
59
+ return true if argvs['reason'] == 'requireptr'
60
+ return true if Sisimai::SMTP::Status.name(argvs['deliverystatus']).to_s == 'requireptr'
61
+ return true if match(argvs['diagnosticcode'].downcase)
62
+ return false
63
+ end
64
+
65
+ end
66
+ end
67
+ end
68
+ end
69
+
@@ -1,14 +1,13 @@
1
1
  module Sisimai
2
2
  module Reason
3
- # Sisimai::Reason::SecurityError checks the bounce reason is "securityerror"
4
- # or not. This class is called only Sisimai::Reason class.
3
+ # Sisimai::Reason::SecurityError checks the bounce reason is "securityerror" or not. This class
4
+ # is called only Sisimai::Reason class.
5
5
  #
6
- # This is the error that a security violation was detected on a destination
7
- # mail server. Depends on the security policy on the server, a sender's email
8
- # address is camouflaged address.
6
+ # This is the error that a security violation was detected on a destination mail server. Depends
7
+ # on the security policy on the server, a sender's email address is camouflaged address.
9
8
  #
10
- # Sisimai will set "securityerror" to the reason
11
- # of email bounce if the value of Status: field in a bounce email is "5.7.*".
9
+ # Sisimai will set "securityerror" to the reason of email bounce if the value of Status: field
10
+ # in a bounce email is "5.7.*".
12
11
  #
13
12
  # Action: failed
14
13
  # Status: 5.7.1
@@ -17,34 +16,32 @@ module Sisimai
17
16
  # Last-Attempt-Date: Tue, 28 Apr 2009 11:02:45 +0900 (JST)
18
17
  #
19
18
  module SecurityError
20
- # Imported from p5-Sisimail/lib/Sisimai/Reason/SecurityError.pm
21
19
  class << self
22
- Regex = %r{(?>
23
- account[ ]not[ ]subscribed[ ]to[ ]ses
24
- |authentication[ ](?:
25
- credentials invalid
26
- |failure
27
- |failed;[ ]server[ ][^ ]+[ ]said: # Postfix
28
- |required
29
- |turned[ ]on[ ]in[ ]your[ ]email[ ]client
30
- )
31
- |\d+[ ]denied[ ]\[[a-z]+\][ ].+[(]mode:[ ].+[)]
32
- |authentification[ ]requise.+[0-9a-z_]+402
33
- |codes?[ ]d'?[ ]*authentification[ ]invalide.+[0-9a-z_]+305
34
- |domain[ ][^ ]+[ ]is[ ]a[ ]dead[ ]domain
35
- |executable[ ]files[ ]are[ ]not[ ]allowed[ ]in[ ]compressed[ ]files
36
- |insecure[ ]mail[ ]relay
37
- |recipient[ ]address[ ]rejected:[ ]access[ ]denied
38
- |sorry,[ ]you[ ]don'?t[ ]authenticate[ ]or[ ]the[ ]domain[ ]isn'?t[ ]in[ ]
39
- my[ ]list[ ]of[ ]allowed[ ]rcpthosts
40
- |tls[ ]required[ ]but[ ]not[ ]supported # SendGrid:the recipient mailserver does not support TLS or have a valid certificate
41
- |tls[ ]required[ ]but[ ]not[ ]supported # SendGrid:the recipient mailserver does not support TLS or have a valid certificate
42
- |unauthenticated[ ]senders[ ]not[ ]allowed
43
- |user[ ][^ ]+[ ]is[ ]not[ ]authorized[ ]to[ ]perform[ ]ses:sendrawemail[ ]on[ ]resource
44
- |you[ ]are[ ]not[ ]authorized[ ]to[ ]send[ ]mail,[ ]authentication[ ]is[ ]required
45
- |verification[ ]failure
46
- )
47
- }x
20
+ require 'sisimai/string'
21
+
22
+ Index = [
23
+ 'account not subscribed to ses',
24
+ 'authentication credentials invalid',
25
+ 'authentication failure',
26
+ 'authentication required',
27
+ 'authentication turned on in your email client',
28
+ 'executable files are not allowed in compressed files',
29
+ 'insecure mail relay',
30
+ 'recipient address rejected: access denied',
31
+ "sorry, you don't authenticate or the domain isn't in my list of allowed rcpthosts",
32
+ 'starttls is required to send mail',
33
+ 'tls required but not supported', # SendGrid:the recipient mailserver does not support TLS or have a valid certificate
34
+ 'unauthenticated senders not allowed',
35
+ 'verification failure',
36
+ 'you are not authorized to send mail, authentication is required',
37
+ ].freeze
38
+ Pairs = [
39
+ ['authentication failed; server ', ' said: '], # Postfix
40
+ ['authentification invalide', '305'],
41
+ ['authentification requise', '402'],
42
+ ['domain ', ' is a dead domain'],
43
+ ['user ', ' is not authorized to perform ses:sendrawemail on resource'],
44
+ ].freeze
48
45
 
49
46
  def text; return 'securityerror'; end
50
47
  def description; return 'Email rejected due to security violation was detected on a destination host'; end
@@ -55,12 +52,13 @@ module Sisimai
55
52
  # true: Matched
56
53
  def match(argv1)
57
54
  return nil unless argv1
58
- return true if argv1 =~ Regex
55
+ return true if Index.any? { |a| argv1.include?(a) }
56
+ return true if Pairs.any? { |a| Sisimai::String.aligned(argv1, a) }
59
57
  return false
60
58
  end
61
59
 
62
60
  # The bounce reason is security error or not
63
- # @param [Sisimai::Data] argvs Object to be detected the reason
61
+ # @param [Sisimai::Fact] argvs Object to be detected the reason
64
62
  # @return [True,False] true: is security error
65
63
  # false: is not security error
66
64
  # @see http://www.ietf.org/rfc/rfc2822.txt