sisimai 4.22.3 → 4.22.4

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 +5 -5
  130. data/lib/sisimai/skeleton.rb +0 -43
@@ -20,9 +20,7 @@ module Sisimai
20
20
  # Imported from p5-Sisimail/lib/Sisimai/Reason/SecurityError.pm
21
21
  class << self
22
22
  def text; return 'securityerror'; end
23
- def description
24
- return 'Email rejected due to security violation was detected on a destination host'
25
- end
23
+ def description; return 'Email rejected due to security violation was detected on a destination host'; end
26
24
 
27
25
  # Try to match that the given text and regular expressions
28
26
  # @param [String] argv1 String to be matched with regular expressions
@@ -31,29 +29,29 @@ module Sisimai
31
29
  def match(argv1)
32
30
  return nil unless argv1
33
31
  regex = %r{(?>
34
- Account[ ]not[ ]subscribed[ ]to[ ]SES
35
- |Authentification[ ]requise.+[A-Z]{3}.+402
32
+ account[ ]not[ ]subscribed[ ]to[ ]ses
33
+ |authentification[ ]requise.+[a-z]{3}.+402
36
34
  |authentication[ ](?:
37
- Credentials Invalid
35
+ credentials invalid
38
36
  |failure
39
37
  |failed;[ ]server[ ].+[ ]said: # Postfix
40
38
  |required
41
39
  |turned[ ]on[ ]in[ ]your[ ]email[ ]client
42
40
  )
43
- |\d+[ ]denied[ ]\[[a-z]+\][ ].+[(]Mode:[ ].+[)]
44
- |Codes?[ ]d'?[ ]*authentification[ ]invalide.+[A-Z]{3}.+305
41
+ |\d+[ ]denied[ ]\[[a-z]+\][ ].+[(]mode:[ ].+[)]
42
+ |codes?[ ]d'?[ ]*authentification[ ]invalide.+[a-z]{3}.+305
45
43
  |domain[ ].+[ ]is[ ]a[ ]dead[ ]domain
46
- |Executable[ ]files[ ]are[ ]not[ ]allowed[ ]in[ ]compressed[ ]files
44
+ |executable[ ]files[ ]are[ ]not[ ]allowed[ ]in[ ]compressed[ ]files
47
45
  |insecure[ ]mail[ ]relay
48
- |Recipient[ ]address[ ]rejected:[ ]Access[ ]denied
46
+ |recipient[ ]address[ ]rejected:[ ]access[ ]denied
49
47
  |sorry,[ ]you[ ]don'?t[ ]authenticate[ ]or[ ]the[ ]domain[ ]isn'?t[ ]in[ ]
50
48
  my[ ]list[ ]of[ ]allowed[ ]rcpthosts
51
- |TLS[ ]required[ ]but[ ]not[ ]supported # SendGrid:the recipient mailserver does not support TLS or have a valid certificate
52
- |User[ ].+[ ]is[ ]not[ ]authorized[ ]to[ ]perform[ ]ses:SendRawEmail[ ]on[ ]resource
49
+ |tls[ ]required[ ]but[ ]not[ ]supported # SendGrid:the recipient mailserver does not support TLS or have a valid certificate
50
+ |user[ ].+[ ]is[ ]not[ ]authorized[ ]to[ ]perform[ ]ses:sendrawemail[ ]on[ ]resource
53
51
  |you[ ]are[ ]not[ ]authorized[ ]to[ ]send[ ]mail,[ ]authentication[ ]is[ ]required
54
52
  |verification[ ]failure
55
53
  )
56
- }ix
54
+ }x
57
55
 
58
56
  return true if argv1 =~ regex
59
57
  return false
@@ -17,9 +17,7 @@ module Sisimai
17
17
  # Imported from p5-Sisimail/lib/Sisimai/Reason/SpamDetected.pm
18
18
  class << self
19
19
  def text; return 'spamdetected'; end
20
- def description
21
- return 'Email rejected by spam filter running on the remote host'
22
- end
20
+ def description; return 'Email rejected by spam filter running on the remote 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
@@ -28,15 +26,15 @@ module Sisimai
28
26
  def match(argv1)
29
27
  return nil unless argv1
30
28
  regex = %r{(?>
31
- ["]The[ ]mail[ ]server[ ]detected[ ]your[ ]message[ ]as[ ]spam[ ]and[ ]
29
+ ["]the[ ]mail[ ]server[ ]detected[ ]your[ ]message[ ]as[ ]spam[ ]and[ ]
32
30
  has[ ]prevented[ ]delivery[.]["] # CPanel/Exim with SA rejections on
33
31
  |(?:\d[.]\d[.]\d|\d{3})[ ]spam\z
34
32
  |appears[ ]to[ ]be[ ]unsolicited
35
- |Blacklisted[ ]URL[ ]in[ ]message
33
+ |blacklisted[ ]url[ ]in[ ]message
36
34
  |block[ ]for[ ]spam
37
35
  |blocked[ ]by[ ](?:
38
36
  policy:[ ]no[ ]spam[ ]please
39
- |spamAssassin # rejected by SpamAssassin
37
+ |spamassassin # rejected by SpamAssassin
40
38
  )
41
39
  |blocked[ ]for[ ]abuse[.][ ]see[ ]http://att[.]net/blocks # AT&T
42
40
  |bulk[ ]email
@@ -50,7 +48,7 @@ module Sisimai
50
48
  |mail[ ](?:
51
49
  appears[ ]to[ ]be[ ]unsolicited # rejected due to spam
52
50
  |content[ ]denied # http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=20022&&no=1000726
53
- |rejete.+[A-Z]{3}.+506
51
+ |rejete.+[a-z]{3}.+506
54
52
  )
55
53
  |may[ ]consider[ ]spam
56
54
  |message[ ](?:
@@ -59,10 +57,10 @@ module Sisimai
59
57
  |filtered
60
58
  |filtered[.][ ](?:
61
59
  please[ ]see[ ]the[ ]faqs[ ]section[ ]on[ ]spam
62
- |Refer[ ]to[ ]the[ ]Troubleshooting[ ]page[ ]at[ ]
60
+ |refer[ ]to[ ]the[ ]troubleshooting[ ]page[ ]at[ ]
63
61
  )
64
62
  |looks[ ]like[ ]spam
65
- |not[ ]accepted[ ]for[ ]policy[ ]reasons[.][ ]See[ ]http: # Yahoo!
63
+ |not[ ]accepted[ ]for[ ]policy[ ]reasons[.][ ]see[ ]http: # Yahoo!
66
64
  |refused[ ]by[ ]mailmarshal[ ]spamprofiler
67
65
  |rejected[ ](?:
68
66
  as[ ]spam
@@ -77,8 +75,8 @@ module Sisimai
77
75
  |system[ ]has[ ]detected[ ]that[ ]this[ ]message[ ]is
78
76
  )
79
77
  |probable[ ]spam
80
- |REJECT[ ]bulk[.]advertising
81
- |Reject,.+[ ][-][ ]SPAM[.][ ]
78
+ |reject[ ]bulk[.]advertising
79
+ |reject,.+[ ][-][ ]spam[.][ ]
82
80
  |rejected(?:
83
81
  :[ ]spamassassin[ ]score[ ]
84
82
  |[ ]by[ ].+[ ][(]spam[)]
@@ -87,7 +85,7 @@ module Sisimai
87
85
  |rejecting[ ]banned[ ]content
88
86
  |related[ ]to[ ]content[ ]with[ ]spam[-]like[ ]characteristics
89
87
  |rule[ ]imposed[ ]as[ ].+is[ ]blacklisted[ ]on # Mailmarshal RBLs
90
- |Sender[ ]domain[ ]listed[ ]at[ ].+
88
+ |sender[ ]domain[ ]listed[ ]at[ ].+
91
89
  |sending[ ]address[ ]not[ ]accepted[ ]due[ ]to[ ]spam[ ]filter
92
90
  |spam[ ](?:
93
91
  .+[ ]exceeded
@@ -101,18 +99,18 @@ module Sisimai
101
99
  |not[ ]accepted
102
100
  |refused
103
101
  |rejection
104
- |Reporting[ ]Address # SendGrid: a message to an address has previously been marked as Spam by the recipient.
102
+ |reporting[ ]address # SendGrid: a message to an address has previously been marked as Spam by the recipient.
105
103
  |score[ ]
106
104
  )
107
105
  |spambouncer[ ]identified[ ]spam # SpamBouncer identified SPAM
108
106
  |spamming[ ]not[ ]allowed
109
- |Too[ ]much[ ]spam[.] # Earthlink
107
+ |too[ ]much[ ]spam[.] # Earthlink
110
108
  |the[ ]message[ ](?:
111
109
  has[ ]been[ ]rejected[ ]by[ ]spam[ ]filtering[ ]engine
112
110
  |was[ ]rejected[ ]due[ ]to[ ]classification[ ]as[ ]bulk[ ]mail
113
111
  )
114
- |The[ ]content[ ]of[ ]this[ ]message[ ]looked[ ]like[ ]spam # SendGrid
115
- |This[ ](?:e-mail|mail)[ ](?:
112
+ |the[ ]content[ ]of[ ]this[ ]message[ ]looked[ ]like[ ]spam # SendGrid
113
+ |this[ ](?:e-mail|mail)[ ](?:
116
114
  cannot[ ]be[ ]forwarded[ ]because[ ]it[ ]was[ ]detected[ ]as[ ]spam
117
115
  |is[ ]classified[ ]as[ ]spam[ ]and[ ]is[ ]rejected
118
116
  )
@@ -124,7 +122,7 @@ module Sisimai
124
122
  )
125
123
  |scored[ ].+[ ]spam[ ]points
126
124
  |was[ ]classified[ ]as[ ]spam
127
- |was[ ]rejected[ ]by[ ]Recurrent[ ]Pattern[ ]Detection[ ]System
125
+ |was[ ]rejected[ ]by[ ]recurrent[ ]pattern[ ]detection[ ]system
128
126
  )
129
127
  |transaction[ ]failed[ ]spam[ ]message[ ]not[ ]queued # SendGrid
130
128
  |we[ ]dont[ ]accept[ ]spam
@@ -132,7 +130,7 @@ module Sisimai
132
130
  |your[ ](?:
133
131
  email[ ](?:
134
132
  appears[ ]similar[ ]to[ ]spam[ ]we[ ]have[ ]received[ ]before
135
- |breaches[ ]local[ ]URIBL[ ]policy
133
+ |breaches[ ]local[ ]uribl[ ]policy
136
134
  |had[ ]spam[-]like[ ]
137
135
  |is[ ](?:considered|probably)[ ]spam
138
136
  |was[ ]detected[ ]as[ ]spam
@@ -141,15 +139,15 @@ module Sisimai
141
139
  as[ ]spam[ ]and[ ]has[ ]prevented[ ]delivery
142
140
  |has[ ]been[ ](?:
143
141
  temporarily[ ]blocked[ ]by[ ]our[ ]filter
144
- |rejected[ ]because[ ]it[ ]appears[ ]to[ ]be[ ]SPAM
142
+ |rejected[ ]because[ ]it[ ]appears[ ]to[ ]be[ ]spam
145
143
  )
146
- |has[ ]triggered[ ]a[ ]SPAM[ ]block
144
+ |has[ ]triggered[ ]a[ ]spam[ ]block
147
145
  |may[ ]contain[ ]the[ ]spam[ ]contents
148
146
  |failed[ ]several[ ]antispam[ ]checks
149
147
  )
150
148
  )
151
149
  )
152
- }ix
150
+ }x
153
151
 
154
152
  return true if argv1 =~ regex
155
153
  return false
@@ -164,24 +162,12 @@ module Sisimai
164
162
  return nil unless argvs
165
163
  return nil unless argvs.is_a? Sisimai::Data
166
164
  return nil unless argvs.deliverystatus.size > 0
167
- return true if argvs.reason == Sisimai::Reason::SpamDetected.text
165
+ return true if argvs.reason == 'spamdetected'
168
166
 
169
167
  require 'sisimai/smtp/status'
170
- statuscode = argvs.deliverystatus || ''
171
- diagnostic = argvs.diagnosticcode || ''
172
- reasontext = Sisimai::Reason::SpamDetected.text
173
- v = false
174
-
175
- if Sisimai::SMTP::Status.name(statuscode) == reasontext
176
- # Delivery status code points "spamdetected".
177
- v = false
178
-
179
- else
180
- # Matched with a pattern in this class
181
- v = true if Sisimai::Reason::SpamDetected.match(diagnostic)
182
- end
183
-
184
- return v
168
+ return true if Sisimai::SMTP::Status.name(argvs.deliverystatus) == 'spamdetected'
169
+ return true if match(argvs.diagnosticcode.downcase)
170
+ return false
185
171
  end
186
172
 
187
173
  end
@@ -9,9 +9,7 @@ module Sisimai
9
9
  # Imported from p5-Sisimail/lib/Sisimai/Reason/Suspend.pm
10
10
  class << self
11
11
  def text; return 'suspend'; end
12
- def description
13
- return 'Email rejected due to a recipient account is being suspended'
14
- end
12
+ def description; return 'Email rejected due to a recipient account is being suspended'; 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
@@ -20,7 +18,7 @@ module Sisimai
20
18
  def match(argv1)
21
19
  return nil unless argv1
22
20
  regex = %r{(?>
23
- Boite[ ]du[ ]destinataire[ ]archivee.+[A-Z]{3}.+420
21
+ boite[ ]du[ ]destinataire[ ]archivee.+[a-z]{3}.+420
24
22
  |email[ ]account[ ]that[ ]you[ ]tried[ ]to[ ]reach[ ]is[ ]disabled
25
23
  |invalid/inactive[ ]user
26
24
  # http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=20022&&no=1000742
@@ -30,17 +28,17 @@ module Sisimai
30
28
  |unavailable[ ]or[ ]access[ ]denied
31
29
  )
32
30
  |recipient[ ](?:
33
- rejected:[ ]Temporarily[ ]inactive
31
+ rejected:[ ]temporarily[ ]inactive
34
32
  |suspend[ ]the[ ]service
35
33
  )
36
34
  |sorry[ ]your[ ]message[ ]to[ ].+[ ]cannot[ ]be[ ]delivered[.][ ]this[ ]
37
35
  account[ ]has[ ]been[ ]disabled[ ]or[ ]discontinued
38
- |The[ ]domain[ ].+[ ]is[ ]currently[ ]suspended
39
- |User[ ].+[ ]temporary[ ]locked
36
+ |the[ ]domain[ ].+[ ]is[ ]currently[ ]suspended
37
+ |user[ ].+[ ]temporary[ ]locked
40
38
  |user[ ]suspended # http://mail.163.com/help/help_spam_16.htm
41
39
  |vdelivermail:[ ]account[ ]is[ ]locked[ ]email[ ]bounced
42
40
  )
43
- }ix
41
+ }x
44
42
 
45
43
  return true if argv1 =~ regex
46
44
  return false
@@ -55,8 +53,9 @@ module Sisimai
55
53
  return nil unless argvs
56
54
  return nil unless argvs.is_a? Sisimai::Data
57
55
  return nil unless argvs.deliverystatus.size > 0
58
- return true if argvs.reason == Sisimai::Reason::Suspend.text
59
- return true if Sisimai::Reason::Suspend.match(argvs.diagnosticcode)
56
+
57
+ return true if argvs.reason == 'suspend'
58
+ return true if match(argvs.diagnosticcode.downcase)
60
59
  return false
61
60
  end
62
61
 
@@ -15,9 +15,7 @@ module Sisimai
15
15
  # Imported from p5-Sisimail/lib/Sisimai/Reason/SyntaxError.pm
16
16
  class << self
17
17
  def text; return 'syntaxerror'; end
18
- def description
19
- return 'Email rejected due to syntax error at sent commands in SMTP session'
20
- end
18
+ def description; return 'Email rejected due to syntax error at sent commands in SMTP session'; end
21
19
  def match(*); return nil; end
22
20
 
23
21
  # Connection rejected due to syntax error or not
@@ -30,7 +28,8 @@ module Sisimai
30
28
  def true(argvs)
31
29
  return nil unless argvs
32
30
  return nil unless argvs.is_a? Sisimai::Data
33
- return true if argvs.reason == Sisimai::Reason::SyntaxError.text
31
+
32
+ return true if argvs.reason == 'syntaxerror'
34
33
  return true if argvs.replycode =~ /\A[45]0[0-7]\z/
35
34
  return false
36
35
  end
@@ -13,9 +13,7 @@ module Sisimai
13
13
  # Imported from p5-Sisimail/lib/Sisimai/Reason/SystemError.pm
14
14
  class << self
15
15
  def text; return 'systemerror'; end
16
- def description
17
- return 'Email returned due to system error on the remote host'
18
- end
16
+ def description; return 'Email returned due to system error on the remote host'; end
19
17
 
20
18
  # Try to match that the given text and regular expressions
21
19
  # @param [String] argv1 String to be matched with regular expressions
@@ -25,10 +23,10 @@ module Sisimai
25
23
  return nil unless argv1
26
24
  regex = %r{(?>
27
25
  can[']t[ ]create[ ]user[ ]output[ ]file
28
- |Could[ ]not[ ]load[ ]DRD[ ]for[ ]domain
29
- |Internal[ ](?:
26
+ |could[ ]not[ ]load[ ]drd[ ]for[ ]domain
27
+ |internal[ ](?:
30
28
  error[ ]reading[ ]data # Microsoft
31
- |server[ ]error:[ ]Operation[ ]now[ ]in[ ]progress # Microsoft
29
+ |server[ ]error:[ ]operation[ ]now[ ]in[ ]progress # Microsoft
32
30
  )
33
31
  |interrupted[ ]system[ ]call
34
32
  |it[ ](?:
@@ -39,7 +37,7 @@ module Sisimai
39
37
  configuration[ ]error
40
38
  |error[ ]in[ ]processing
41
39
  )
42
- |loop[ ]was[ ]found[ ]in[ ]the[ ]Mail[ ]eXchanger
40
+ |loop[ ]was[ ]found[ ]in[ ]the[ ]mail[ ]exchanger
43
41
  |mail[ ](?:
44
42
  for[ ].+[ ]loops[ ]back[ ]to[ ]myself
45
43
  |system[ ]configuration[ ]error
@@ -47,10 +45,10 @@ module Sisimai
47
45
  |server[ ]configuration[ ]error
48
46
  |service[ ]currently[ ]unavailable
49
47
  |system[ ]config[ ]error
50
- |Temporary[ ]local[ ]problem
48
+ |temporary[ ]local[ ]problem
51
49
  |timeout[ ]waiting[ ]for[ ]input
52
50
  )
53
- }ix
51
+ }x
54
52
 
55
53
  return true if argv1 =~ regex
56
54
  return false
@@ -10,9 +10,7 @@ module Sisimai
10
10
  # Imported from p5-Sisimail/lib/Sisimai/Reason/SystemFull.pm
11
11
  class << self
12
12
  def text; return 'systemfull'; end
13
- def description
14
- return "Email rejected due to a destination mail server's disk is full"
15
- end
13
+ def description; return "Email rejected due to a destination mail server's disk is full"; end
16
14
 
17
15
  # Try to match that the given text and regular expressions
18
16
  # @param [String] argv1 String to be matched with regular expressions
@@ -24,7 +22,7 @@ module Sisimai
24
22
  mail[ ]system[ ]full
25
23
  |requested[ ]mail[ ]action[ ]aborted:[ ]exceeded[ ]storage[ ]allocation # MS Exchange
26
24
  )
27
- }ix
25
+ }x
28
26
 
29
27
  return true if argv1 =~ regex
30
28
  return false
@@ -13,9 +13,7 @@ module Sisimai
13
13
  # Imported from p5-Sisimail/lib/Sisimai/Reason/TooManyConn.pm
14
14
  class << self
15
15
  def text; return 'toomanyconn'; end
16
- def description
17
- return 'SMTP connection rejected temporarily due to too many concurrency connections to the remote host'
18
- end
16
+ def description; return 'SMTP connection rejected temporarily due to too many concurrency connections to the remote host'; end
19
17
 
20
18
  # Try to match that the given text and regular expressions
21
19
  # @param [String] argv1 String to be matched with regular expressions
@@ -24,25 +22,25 @@ module Sisimai
24
22
  def match(argv1)
25
23
  return nil unless argv1
26
24
  regex = %r{(?>
27
- All[ ]available[ ]IPs[ ]are[ ]at[ ]maximum[ ]connection[ ]limit # SendGrid
25
+ all[ ]available[ ]ips[ ]are[ ]at[ ]maximum[ ]connection[ ]limit # SendGrid
28
26
  |connection[ ]rate[ ]limit[ ]exceeded
29
27
  |domain[ ].+[ ]has[ ]exceeded[ ]the[ ]max[ ]emails[ ]per[ ]hour[ ].+[ ]allowed
30
- |no[ ]IPs[ ]available[ ][-][ ].+[ ]exceeds[ ]per[-]domain[ ]connection[ ]limit[ ]for
31
- |Throttling[ ]failure:[ ](?:
32
- Daily[ ]message[ ]quota[ ]exceeded
33
- |Maximum[ ]sending[ ]rate[ ]exceeded
28
+ |no[ ]ips[ ]available[ ][-][ ].+[ ]exceeds[ ]per[-]domain[ ]connection[ ]limit[ ]for
29
+ |throttling[ ]failure:[ ](?:
30
+ daily[ ]message[ ]quota[ ]exceeded
31
+ |maximum[ ]sending[ ]rate[ ]exceeded
34
32
  )
35
- |Too[ ]many[ ](?:
33
+ |too[ ]many[ ](?:
36
34
  connections
37
35
  |connections[ ]from[ ]your[ ]host[.] # Microsoft
38
- |concurrent[ ]SMTP[ ]connections # Microsoft
39
- |errors[ ]from[ ]your[ ]IP # Free.fr
40
- |SMTP[ ]sessions[ ]for[ ]this[ ]host # Sendmail(daemon.c)
36
+ |concurrent[ ]smtp[ ]connections # Microsoft
37
+ |errors[ ]from[ ]your[ ]ip # Free.fr
38
+ |smtp[ ]sessions[ ]for[ ]this[ ]host # Sendmail(daemon.c)
41
39
  )
42
- |Trop[ ]de[ ]connexions,[ ].+[A-Z]{3}.+104
43
- |We[ ]have[ ]already[ ]made[ ]numerous[ ]attempts[ ]to[ ]deliver[ ]this[ ]message
40
+ |trop[ ]de[ ]connexions,[ ].+[a-z]{3}.+104
41
+ |we[ ]have[ ]already[ ]made[ ]numerous[ ]attempts[ ]to[ ]deliver[ ]this[ ]message
44
42
  )
45
- }ix
43
+ }x
46
44
 
47
45
  return true if argv1 =~ regex
48
46
  return false
@@ -56,23 +54,12 @@ module Sisimai
56
54
  def true(argvs)
57
55
  return nil unless argvs
58
56
  return nil unless argvs.is_a? Sisimai::Data
59
- return true if argvs.reason == Sisimai::Reason::TooManyConn.text
57
+ return true if argvs.reason == 'toomanyconn'
60
58
 
61
59
  require 'sisimai/smtp/status'
62
- statuscode = argvs.deliverystatus || ''
63
- diagnostic = argvs.diagnosticcode || ''
64
- reasontext = Sisimai::Reason::TooManyConn.text
65
- tempreason = Sisimai::SMTP::Status.name(statuscode)
66
- v = false
67
-
68
- if tempreason == reasontext
69
- # Delivery status code points "toomanyconn".
70
- v = true
71
- else
72
- # Matched with a pattern in this class
73
- v = true if Sisimai::Reason::TooManyConn.match(diagnostic)
74
- end
75
- return v
60
+ return true if Sisimai::SMTP::Status.name(argvs.deliverystatus) == 'toomanyconn'
61
+ return true if match(argvs.diagnosticcode.downcase)
62
+ return false
76
63
  end
77
64
 
78
65
  end
@@ -6,9 +6,7 @@ module Sisimai
6
6
  # Imported from p5-Sisimail/lib/Sisimai/Reason/Undefined.pm
7
7
  class << self
8
8
  def text; return 'undefined'; end
9
- def description
10
- return 'Sisimai could not detect an error reason'
11
- end
9
+ def description; return 'Sisimai could not detect an error reason'; end
12
10
  def match; return nil; end
13
11
  def true(*); return nil; end
14
12
  end
@@ -17,9 +17,7 @@ module Sisimai
17
17
  # Imported from p5-Sisimail/lib/Sisimai/Reason/UserUnknown.pm
18
18
  class << self
19
19
  def text; return 'userunknown'; end
20
- def description
21
- return "Email rejected due to a local part of a recipient's email address does not exist"
22
- end
20
+ def description; return "Email rejected due to a local part of a recipient's email address does not exist"; 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,13 +29,13 @@ module Sisimai
31
29
  .+[ ]user[ ]unknown
32
30
  |[#]5[.]1[.]1[ ]bad[ ]address
33
31
  |[<].+[>][ ]not[ ]found
34
- |[<].+[@].+[>][.][.][.][ ]Blocked[ ]by[ ]
35
- |5[.]0[.]0[.][ ]Mail[ ]rejected[.]
36
- |5[.]1[.]0[ ]Address[ ]rejected[.]
37
- |Adresse[ ]d[ ]au[ ]moins[ ]un[ ]destinataire[ ]invalide.+[A-Z]{3}.+(?:416|418)
32
+ |[<].+[@].+[>][.][.][.][ ]blocked[ ]by[ ]
33
+ |5[.]0[.]0[.][ ]mail[ ]rejected[.]
34
+ |5[.]1[.]0[ ]address[ ]rejected[.]
35
+ |adresse[ ]d[ ]au[ ]moins[ ]un[ ]destinataire[ ]invalide.+[a-z]{3}.+(?:416|418)
38
36
  |address[ ](?:does[ ]not[ ]exist|unknown)
39
37
  |archived[ ]recipient
40
- |BAD[-_ ]RECIPIENT
38
+ |bad[-_ ]recipient
41
39
  |can[']t[ ]accept[ ]user
42
40
  |destination[ ](?:
43
41
  addresses[ ]were[ ]unknown
@@ -80,7 +78,7 @@ module Sisimai
80
78
  |recipient
81
79
  |user(?:[ ]here)?
82
80
  )
83
- |thank[ ]you[ ]rejected:[ ]Account[ ]Unavailable:
81
+ |thank[ ]you[ ]rejected:[ ]account[ ]unavailable:
84
82
  |valid[ ]recipients[,][ ]bye # Microsoft
85
83
  )
86
84
  |non[- ]?existent[ ]user
@@ -93,7 +91,7 @@ module Sisimai
93
91
  |rece?ipient[ ](?:
94
92
  .+[ ]was[ ]not[ ]found[ ]in
95
93
  |address[ ]rejected:[ ](?:
96
- Access[ ]denied
94
+ access[ ]denied
97
95
  |invalid[ ]user
98
96
  |user[ ].+[ ]does[ ]not[ ]exist
99
97
  |user[ ]unknown[ ]in[ ].+[ ]table
@@ -101,13 +99,13 @@ module Sisimai
101
99
  )
102
100
  |does[ ]not[ ]exist(?:[ ]on[ ]this[ ]system)?
103
101
  |is[ ]not[ ]local
104
- |not[ ](?:exist|found|OK)
102
+ |not[ ](?:exist|found|ok)
105
103
  |unknown
106
104
  )
107
105
  |requested[ ]action[ ]not[ ]taken:[ ]mailbox[ ]unavailable
108
- |RESOLVER[.]ADR[.]Recip(?:ient)NotFound
106
+ |resolver[.]adr[.]recip(?:ient)notfound
109
107
  |said:[ ]550[-[ ]]5[.]1[.]1[ ].+[ ]user[ ]unknown[ ]
110
- |SMTP[ ]error[ ]from[ ]remote[ ]mail[ ]server[ ]after[ ]end[ ]of[ ]data:[ ]553.+does[ ]not[ ]exist
108
+ |smtp[ ]error[ ]from[ ]remote[ ]mail[ ]server[ ]after[ ]end[ ]of[ ]data:[ ]553.+does[ ]not[ ]exist
111
109
  |sorry,[ ](?:
112
110
  user[ ]unknown
113
111
  |badrcptto
@@ -118,7 +116,7 @@ module Sisimai
118
116
  |following[ ]recipients[ ]was[ ]undeliverable
119
117
  |user[']s[ ]email[ ]name[ ]is[ ]not[ ]found
120
118
  )
121
- |There[ ]is[ ]no[ ]one[ ]at[ ]this[ ]address
119
+ |there[ ]is[ ]no[ ]one[ ]at[ ]this[ ]address
122
120
  |this[ ](?:
123
121
  address[ ]no[ ]longer[ ]accepts[ ]mail
124
122
  |email[ ]address[ ]is[ ]wrong[ ]or[ ]no[ ]longer[ ]valid
@@ -143,7 +141,7 @@ module Sisimai
143
141
  |vdeliver:[ ]invalid[ ]or[ ]unknown[ ]virtual[ ]user
144
142
  |your[ ]envelope[ ]recipient[ ]is[ ]in[ ]my[ ]badrcptto[ ]list
145
143
  )
146
- }ix
144
+ }x
147
145
 
148
146
  return true if argv1 =~ regex
149
147
  return false
@@ -157,33 +155,30 @@ module Sisimai
157
155
  def true(argvs)
158
156
  return nil unless argvs
159
157
  return nil unless argvs.is_a? Sisimai::Data
160
- return true if argvs.reason == Sisimai::Reason::UserUnknown.text
158
+ return true if argvs.reason == 'userunknown'
161
159
 
162
160
  require 'sisimai/smtp/status'
163
- prematches = %w|NoRelaying Blocked MailboxFull HasMoved Blocked Rejected|
164
- matchother = false
165
- statuscode = argvs.deliverystatus || ''
166
- diagnostic = argvs.diagnosticcode || ''
167
- reasontext = Sisimai::Reason::UserUnknown.text
168
- tempreason = Sisimai::SMTP::Status.name(statuscode)
169
- v = false
170
-
161
+ diagnostic = argvs.diagnosticcode.downcase;
162
+ tempreason = Sisimai::SMTP::Status.name(argvs.deliverystatus)
171
163
  return false if tempreason == 'suspend'
172
164
 
173
- if tempreason == reasontext
165
+ if tempreason == 'userunknown'
174
166
  # *.1.1 = 'Bad destination mailbox address'
175
167
  # Status: 5.1.1
176
168
  # Diagnostic-Code: SMTP; 550 5.1.1 <***@example.jp>:
177
169
  # Recipient address rejected: User unknown in local recipient table
170
+ prematches = %w[NoRelaying Blocked MailboxFull HasMoved Blocked Rejected]
171
+ matchother = false
172
+
178
173
  prematches.each do |e|
179
174
  # Check the value of "Diagnostic-Code" with other error patterns.
180
- p = 'Sisimai::Reason::' + e
175
+ p = 'Sisimai::Reason::' << e
181
176
  r = nil
182
177
  begin
183
178
  require p.downcase.gsub('::', '/')
184
179
  r = Module.const_get(p)
185
180
  rescue
186
- warn '***warning: Failed to load ' + p
181
+ warn '***warning: Failed to load ' << p
187
182
  next
188
183
  end
189
184
 
@@ -192,20 +187,15 @@ module Sisimai
192
187
  matchother = true
193
188
  break
194
189
  end
190
+ return true unless matchother # Did not match with other message patterns
195
191
 
196
- # Did not match with other message patterns
197
- v = true unless matchother
198
-
199
- else
200
- # Check the last SMTP command of the session.
201
- if argvs.smtpcommand == 'RCPT'
202
- # When the SMTP command is not "RCPT", the session rejected by other
203
- # reason, maybe.
204
- v = true if Sisimai::Reason::UserUnknown.match(diagnostic)
205
- end
192
+ elsif argvs.smtpcommand == 'RCPT'
193
+ # When the SMTP command is not "RCPT", the session rejected by other
194
+ # reason, maybe.
195
+ return true if match(diagnostic)
206
196
  end
207
197
 
208
- return v
198
+ return false
209
199
  end
210
200
 
211
201
  end