PageRenderTime 50ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/Kernel/cpan-lib/Sisimai/Reason/Blocked.pm

https://github.com/OTRS/otrs
Perl | 227 lines | 221 code | 1 blank | 5 comment | 0 complexity | f006fcd3bba03e1db8f8392493c35b69 MD5 | raw file
Possible License(s): GPL-3.0, Apache-2.0, LGPL-2.1
  1. package Sisimai::Reason::Blocked;
  2. use feature ':5.10';
  3. use strict;
  4. use warnings;
  5. sub text { 'blocked' }
  6. sub description { 'Email rejected due to client IP address or a hostname' }
  7. sub match {
  8. # Try to match that the given text and regular expressions
  9. # @param [String] argv1 String to be matched with regular expressions
  10. # @return [Integer] 0: Did not match
  11. # 1: Matched
  12. # @since v4.0.0
  13. my $class = shift;
  14. my $argv1 = shift // return undef;
  15. my $regex = qr{(?>
  16. access[ ]denied[.][ ]ip[ ]name[ ]lookup[ ]failed
  17. |access[ ]from[ ]ip[ ]address[ ].+[ ]blocked
  18. |all[ ]mail[ ]servers[ ]must[ ]have[ ]a[ ]ptr[ ]record[ ]with[ ]a[ ]valid[ ]reverse[ ]dns[ ]entry
  19. |bad[ ]sender[ ]ip[ ]address
  20. |banned[ ]sending[ ]ip # Office365
  21. |blacklisted[ ]by
  22. |(?:blocked|refused)[ ]-[ ]see[ ]https?://
  23. |blocked[ ]using[ ]
  24. |can[']t[ ]determine[ ]purported[ ]responsible[ ]address
  25. |cannot[ ](?:
  26. find[ ]your[ ]hostname
  27. |resolve[ ]your[ ]address
  28. )
  29. |client[ ]host[ ](?:
  30. .+[ ]blocked[ ]using
  31. |rejected:[ ](?:
  32. abus[ ]detecte[ ]gu_eib_0[24] # SFR
  33. |cannot[ ]find[ ]your[ ]hostname # Yahoo!
  34. |may[ ]not[ ]be[ ]mail[ ]exchanger
  35. |was[ ]not[ ]authenticated # Microsoft
  36. )
  37. )
  38. |confirm[ ]this[ ]mail[ ]server
  39. |connection[ ](?:
  40. dropped
  41. |refused[ ]by
  42. |reset[ ]by[ ]peer
  43. |was[ ]dropped[ ]by[ ]remote[ ]host
  44. )
  45. |connections[ ](?:
  46. not[ ]accepted[ ]from[ ]ip[ ]addresses[ ]on[ ]spamhaus[ ]xbl
  47. |will[ ]not[ ]be[ ]accepted[ ]from[ ].+because[ ]the[ ]ip[ ]is[ ]in[ ]spamhaus's[ ]list
  48. )
  49. |currently[ ]sending[ ]spam[ ]see:[ ]
  50. |domain[ ](?:
  51. .+[ ]mismatches[ ]client[ ]ip
  52. |does[ ]not[ ]exist:
  53. )
  54. |dns[ ]lookup[ ]failure:[ ].+[ ]try[ ]again[ ]later
  55. |dnsbl:attrbl
  56. |dynamic/zombied/spam[ ]ips[ ]blocked
  57. |email[ ]blocked[ ]by[ ](?:.+[.]barracudacentral[.]org|spamhaus)
  58. |esmtp[ ]not[ ]accepting[ ]connections # icloud.com
  59. |fix[ ]reverse[ ]dns[ ]for[ ].+
  60. |go[ ]away
  61. |helo[ ]command[ ]rejected:
  62. |host[ ].+[ ]refused[ ]to[ ]talk[ ]to[ ]me:[ ]\d+[ ]blocked
  63. |hosts[ ]with[ ]dynamic[ ]ip
  64. |http://(?:
  65. spf[.]pobox[.]com/why[.]html
  66. |www[.]spamcop[.]net/bl[.]
  67. )
  68. |invalid[ ]ip[ ]for[ ]sending[ ]mail[ ]of[ ]domain
  69. |ip[ ]\d{1,3}[.]\d{1,3}[.]\d{1,3}[.]\d{1,3}[ ]is[ ]blocked[ ]by[ ]earthlink # Earthlink
  70. |ip[/]domain[ ]reputation[ ]problems
  71. |ips[ ]with[ ]missing[ ]ptr[ ]records
  72. |is[ ](?:
  73. in[ ]a[ ]black[ ]list[ ]at[ ].+[.]
  74. |in[ ]an[ ].*rbl[ ]on[ ].+
  75. |not[ ]allowed[ ]to[ ]send[ ](?:
  76. mail[ ]from
  77. |from[ ].+[ ]per[ ]it's[ ]spf[ ]record
  78. )
  79. )
  80. |mail[ ]server[ ]at[ ].+[ ]is[ ]blocked
  81. |mail[ ]from[ ]\d+[.]\d+[.]\d+[.]\d[ ]refused:
  82. |message[ ]from[ ].+[ ]rejected[ ]based[ ]on[ ]blacklist
  83. |messages[ ]from[ ].+[ ]temporarily[ ]deferred[ ]due[ ]to[ ]user[ ]complaints # Yahoo!
  84. |no[ ](?:
  85. access[ ]from[ ]mail[ ]server
  86. |ptr[ ]record[ ]found[.]
  87. )
  88. |not[ ]currently[ ]accepting[ ]mail[ ]from[ ]your[ ]ip # Microsoft
  89. |part[ ]of[ ]their[ ]network[ ]is[ ]on[ ]our[ ]block[ ]list
  90. |please[ ](?:
  91. get[ ]a[ ]custom[ ]reverse[ ]dns[ ]name[ ]from[ ]your[ ]isp[ ]for[ ]your[ ]host
  92. |inspect[ ]your[ ]spf[ ]settings
  93. |use[ ]the[ ]smtp[ ]server[ ]of[ ]your[ ]isp
  94. )
  95. |ptr[ ]record[ ]setup
  96. |rejecting[ ]open[ ]proxy # Sendmail(srvrsmtp.c)
  97. |reverse[ ]dns[ ](?:
  98. failed
  99. |required
  100. |lookup[ ]for[ ]host[ ].+[ ]failed[ ]permanently
  101. )
  102. |sender[ ]ip[ ](?:
  103. address[ ]rejected
  104. |reverse[ ]lookup[ ]rejected
  105. )
  106. |server[ ]access[ ](?:
  107. .+[ ]forbidden[ ]by[ ]invalid[ ]rdns[ ]record[ ]of[ ]your[ ]mail[ ]server
  108. |forbidden[ ]by[ ]your[ ]ip[ ]
  109. )
  110. |server[ ]ip[ ].+[ ]listed[ ]as[ ]abusive
  111. |service[ ]permits[ ]\d+[ ]unverifyable[ ]sending[ ]ips
  112. |smtp[ ]error[ ]from[ ]remote[ ]mail[ ]server[ ]after[ ]initial[ ]connection: # Exim
  113. |sorry,[ ](?:
  114. that[ ]domain[ ]isn'?t[ ]in[ ]my[ ]list[ ]of[ ]allowed[ ]rcpthosts
  115. |your[ ]remotehost[ ]looks[ ]suspiciously[ ]like[ ]spammer
  116. )
  117. |spf[ ](?:
  118. .+[ ]domain[ ]authentication[ ]fail
  119. |record
  120. |check:[ ]fail
  121. )
  122. |spf:[ ].+[ ]is[ ]not[ ]allowed[ ]to[ ]send[ ]mail.+[a-z]{3}.+401
  123. |the[ ](?:email|domain|ip).+[ ]is[ ]blacklisted
  124. |this[ ]system[ ]will[ ]not[ ]accept[ ]messages[ ]from[ ]servers[/]devices[ ]with[ ]no[ ]reverse[ ]dns
  125. |too[ ]many[ ]spams[ ]from[ ]your[ ]ip # free.fr
  126. |unresolvable[ ]relay[ ]host[ ]name
  127. |veuillez[ ]essayer[ ]plus[ ]tard.+[a-z]{3}.+(?:103|510)
  128. |your[ ](?:
  129. network[ ]is[ ]temporary[ ]blacklisted
  130. |sender's[ ]ip[ ]address[ ]is[ ]listed[ ]at[ ].+[.]abuseat[.]org
  131. |server[ ]requires[ ]confirmation
  132. )
  133. |was[ ]blocked[ ]by[ ].+
  134. |we[ ]do[ ]not[ ]accept[ ]mail[ ]from[ ](?: # @mail.ru
  135. dynamic[ ]ips
  136. |hosts[ ]with[ ]dynamic[ ]ip[ ]or[ ]generic[ ]dns[ ]ptr-records
  137. )
  138. |you[ ]are[ ](?:
  139. not[ ]allowed[ ]to[ ]connect
  140. |sending[ ]spam
  141. )
  142. |your[ ](?:
  143. access[ ]to[ ]submit[ ]messages[ ]to[ ]this[ ]e-mail[ ]system[ ]has[ ]been[ ]rejected
  144. |message[ ]was[ ]rejected[ ]for[ ]possible[ ]spam/virus[ ]content
  145. )
  146. )
  147. }x;
  148. return 1 if $argv1 =~ $regex;
  149. return 0;
  150. }
  151. sub true {
  152. # Rejected due to client IP address or hostname
  153. # @param [Sisimai::Data] argvs Object to be detected the reason
  154. # @return [Integer] 1: is blocked
  155. # [Integer] 0: is not blocked by the client
  156. # @see http://www.ietf.org/rfc/rfc2822.txt
  157. # @since v4.0.0
  158. my $class = shift;
  159. my $argvs = shift // return undef;
  160. return 1 if $argvs->reason eq 'blocked';
  161. return 1 if Sisimai::SMTP::Status->name($argvs->deliverystatus) eq 'blocked';
  162. return 1 if __PACKAGE__->match(lc $argvs->diagnosticcode);
  163. }
  164. 1;
  165. __END__
  166. =encoding utf-8
  167. =head1 NAME
  168. Sisimai::Reason::Blocked - Bounce reason is "blocked" or not.
  169. =head1 SYNOPSIS
  170. use Sisimai::Reason::Blocked;
  171. print Sisimai::Reason::Blocked->match('Access from ip address 192.0.2.1 blocked'); # 1
  172. =head1 DESCRIPTION
  173. Sisimai::Reason::Blocked checks the bounce reason is "blocked" or not. This
  174. class is called only Sisimai::Reason class.
  175. This is the error that SMTP connection was rejected due to a client IP address
  176. or a hostname, or the parameter of "HELO/EHLO" command. This reason has added
  177. in Sisimai 4.0.0 and does not exist in any version of bounceHammer.
  178. <kijitora@example.net>:
  179. Connected to 192.0.2.112 but my name was rejected.
  180. Remote host said: 501 5.0.0 Invalid domain name
  181. =head1 CLASS METHODS
  182. =head2 C<B<text()>>
  183. C<text()> returns string: "blocked".
  184. print Sisimai::Reason::Blocked->text; # blocked
  185. =head2 C<B<match(I<string>)>>
  186. C<match()> returns 1 if the argument matched with patterns defined in this class.
  187. print Sisimai::Reason::Blocked->match('Access from ip address 192.0.2.1 blocked'); # 1
  188. =head2 C<B<true(I<Sisimai::Data>)>>
  189. C<true()> returns 1 if the bounce reason is "blocked". The argument must be
  190. Sisimai::Data object and this method is called only from Sisimai::Reason class.
  191. =head1 AUTHOR
  192. azumakuniyuki
  193. =head1 COPYRIGHT
  194. Copyright (C) 2014-2018 azumakuniyuki, All rights reserved.
  195. =head1 LICENSE
  196. This software is distributed under The BSD 2-Clause License.
  197. =cut