File Coverage

lib/Sisimai/Reason/Blocked.pm
Criterion Covered Total %
statement 21 21 100.0
branch 7 8 87.5
condition 5 6 83.3
subroutine 7 7 100.0
pod 2 4 50.0
total 42 46 91.3


line stmt bran cond sub pod time code
1             package Sisimai::Reason::Blocked;
2 47     47   2328 use feature ':5.10';
  47         86  
  47         3605  
3 47     47   271 use strict;
  47         98  
  47         942  
4 47     47   253 use warnings;
  47         73  
  47         105541  
5              
6 203     203 1 1276 sub text { 'blocked' }
7 4     4 0 21 sub description { 'Email rejected due to client IP address or a hostname' }
8             sub match {
9             # Try to match that the given text and regular expressions
10             # @param [String] argv1 String to be matched with regular expressions
11             # @return [Integer] 0: Did not match
12             # 1: Matched
13             # @since v4.0.0
14 1123     1123 1 4257 my $class = shift;
15 1123   50     2485 my $argv1 = shift // return undef;
16              
17 1123         1652 state $regex = qr{(?>
18             [ ]said:[ ]550[ ]blocked
19             |[(][^ ]+[@][^ ]+:blocked[)]
20             |access[ ]denied[.][ ]ip[ ]name[ ]lookup[ ]failed
21             |access[ ]from[ ]ip[ ]address[ ][^ ]+[ ]blocked
22             |all[ ]mail[ ]servers[ ]must[ ]have[ ]a[ ]ptr[ ]record[ ]with[ ]a[ ]valid[ ]reverse[ ]dns[ ]entry
23             |bad[ ](:?dns[ ]ptr[ ]resource[ ]record|sender[ ]ip[ ]address)
24             |banned[ ]sending[ ]ip # Office365
25             |blacklisted[ ]by
26             |(?:blocked|refused)[ ]-[ ]see[ ]https?://
27             |blocked[ ]using[ ]
28             |can[']t[ ]determine[ ]purported[ ]responsible[ ]address
29             |cannot[ ](?:
30             find[ ]your[ ]hostname
31             |resolve[ ]your[ ]address
32             )
33             |client[ ]host[ ](?:
34             [^ ]+[ ]blocked[ ]using
35             |rejected:[ ](?:
36             abus[ ]detecte[ ]gu_eib_0[24] # SFR
37             |cannot[ ]find[ ]your[ ]hostname # Yahoo!
38             |may[ ]not[ ]be[ ]mail[ ]exchanger
39             |was[ ]not[ ]authenticated # Microsoft
40             )
41             )
42             |confirm[ ]this[ ]mail[ ]server
43             |connection[ ](?:
44             dropped
45             |refused[ ]by
46             |reset[ ]by[ ]peer
47             |was[ ]dropped[ ]by[ ]remote[ ]host
48             )
49             |connections[ ](?:
50             not[ ]accepted[ ]from[ ]ip[ ]addresses[ ]on[ ]spamhaus[ ]xbl
51             |will[ ]not[ ]be[ ]accepted[ ]from[ ][^ ]+,[ ]because[ ]the[ ]ip[ ]is[ ]in[ ]spamhaus's[ ]list
52             )
53             |currently[ ]sending[ ]spam[ ]see:[ ]
54             |domain[ ](?:
55             [^ ]+[ ]mismatches[ ]client[ ]ip
56             |does[ ]not[ ]exist:
57             )
58             |dns[ ]lookup[ ]failure:[ ][^ ]+[ ]try[ ]again[ ]later
59             |dnsbl:(?:attrbl|rbl[ ]\d+[<][ ].+[ ][>]_is_blocked)
60             |dynamic/zombied/spam[ ]ips[ ]blocked
61             |email[ ]blocked[ ]by[ ](?:[^ ]+[.]barracudacentral[.]org|spamhaus)
62             |error:[ ]no[ ]valid[ ]recipients[ ]from[ ]
63             |esmtp[ ]not[ ]accepting[ ]connections # icloud.com
64             |extreme[ ]bad[ ]ip[ ]profile
65             |fix[ ]reverse[ ]dns[ ]for[ ][^ ]+
66             |go[ ]away
67             |helo[ ]command[ ]rejected:
68             |host[ ][^ ]+[ ]refused[ ]to[ ]talk[ ]to[ ]me:[ ]\d+[ ]blocked
69             |host[ ]network[ ]not[ ]allowed
70             |hosts[ ]with[ ]dynamic[ ]ip
71             |http://(?:
72             spf[.]pobox[.]com/why[.]html
73             |www[.]spamcop[.]net/bl[.]
74             )
75             |invalid[ ]ip[ ]for[ ]sending[ ]mail[ ]of[ ]domain
76             |ip[ ]\d{1,3}[.]\d{1,3}[.]\d{1,3}[.]\d{1,3}[ ]is[ ]blocked[ ]by[ ]earthlink # Earthlink
77             |ip[/]domain[ ]reputation[ ]problems
78             |ips[ ]with[ ]missing[ ]ptr[ ]records
79             |is[ ](?:
80             in[ ]a[ ]black[ ]list(?:[ ]at[ ][^ ]+[.])?
81             |in[ ]an[ ][^ ]+rbl[ ]on[ ][^ ]+
82             |not[ ]allowed[ ]to[ ]send[ ](?:
83             mail[ ]from
84             |from[ ][<][^ ]+[>][ ]per[ ]it's[ ]spf[ ]record
85             )
86             )
87             |mail[ ]server[ ]at[ ][^ ]+[ ]is[ ]blocked
88             |mail[ ]from[ ]\d+[.]\d+[.]\d+[.]\d[ ]refused:
89             |message[ ]from[ ][^ ]+[ ]rejected[ ]based[ ]on[ ]blacklist
90             |message[ ]was[ ]rejected[ ]for[ ]possible[ ]spam/virus[ ]content
91             |messages[ ]from[ ][^ ]+[ ]temporarily[ ]deferred[ ]due[ ]to[ ]user[ ]complaints # Yahoo!
92             |no[ ](?:
93             access[ ]from[ ]mail[ ]server
94             |ptr[ ]record[ ]found[.]
95             )
96             |not[ ]currently[ ]accepting[ ]mail[ ]from[ ]your[ ]ip # Microsoft
97             |part[ ]of[ ]their[ ]network[ ]is[ ]on[ ]our[ ]block[ ]list
98             |please[ ](?:
99             get[ ]a[ ]custom[ ]reverse[ ]dns[ ]name[ ]from[ ]your[ ]isp[ ]for[ ]your[ ]host
100             |inspect[ ]your[ ]spf[ ]settings
101             |use[ ]the[ ]smtp[ ]server[ ]of[ ]your[ ]isp
102             )
103             |ptr[ ]record[ ]setup
104             |rejected[ ]because[ ]the[ ]sending[ ]mta[ ]or[ ]the[ ]sender[ ]has[ ]not[ ]passed[ ]validation
105             |rejected[ ]due[ ]to[ ](?:
106             a[ ]poor[ ]email[ ]reputation[ ]score
107             |the[ ]sending[ ]mta's[ ]poor[ ]reputation
108             )
109             |rejecting[ ]open[ ]proxy # Sendmail(srvrsmtp.c)
110             |reverse[ ]dns[ ](?:
111             failed
112             |required
113             |lookup[ ]for[ ]host[ ][^ ]+[ ]failed[ ]permanently
114             )
115             |sender[ ]ip[ ](?:
116             address[ ]rejected
117             |reverse[ ]lookup[ ]rejected
118             )
119             |server[ ]access[ ](?:
120             [^ ]+[ ]forbidden[ ]by[ ]invalid[ ]rdns[ ]record[ ]of[ ]your[ ]mail[ ]server
121             |forbidden[ ]by[ ]your[ ]ip[ ]
122             )
123             |server[ ]ip[ ][^ ]+[ ]listed[ ]as[ ]abusive
124             |service[ ]not[ ]available,[ ]closing[ ]transmission[ ]channel
125             |service[ ]permits[ ]\d+[ ]unverifyable[ ]sending[ ]ips
126             |smtp[ ]error[ ]from[ ]remote[ ]mail[ ]server[ ]after[ ]initial[ ]connection: # Exim
127             |sorry,[ ](?:
128             that[ ]domain[ ]isn'?t[ ]in[ ]my[ ]list[ ]of[ ]allowed[ ]rcpthosts
129             |your[ ]remotehost[ ]looks[ ]suspiciously[ ]like[ ]spammer
130             )
131             |spf[ ](?:
132             [(]sender[ ]policy[ ]framework[)][ ]domain[ ]authentication[ ]fail
133             |record
134             |check:[ ]fail
135             )
136             |spf:[ ][^ ]+[ ]is[ ]not[ ]allowed[ ]to[ ]send[ ]mail[.][ ][a-z0-9]_401
137             |temporarily[ ]deferred[ ]due[ ]to[ ]unexpected[ ]volume[ ]or[ ]user[ ]complaints
138             |the[ ](?:email|domain|ip)[ ][^ ]+[ ]is[ ]blacklisted
139             |this[ ]system[ ]will[ ]not[ ]accept[ ]messages[ ]from[ ]servers[/]devices[ ]with[ ]no[ ]reverse[ ]dns
140             |to[ ]submit[ ]messages[ ]to[ ]this[ ]e-mail[ ]system[ ]has[ ]been[ ]rejected
141             |too[ ]many[ ](?:
142             spams[ ]from[ ]your[ ]ip # free.fr
143             |unwanted[ ]messages[ ]have[ ]been[ ]sent[ ]from[ ]the[ ]following[ ]ip[ ]address[ ]above
144             )
145             |unresolvable[ ]relay[ ]host[ ]name
146             |veuillez[ ]essayer[ ]plus[ ]tard[.][ ]service[ ]refused,[ ]please[ ]try[ ]later[.][ ][0-9a-z_]+(?:103|510)
147             |was[ ]blocked[ ]by[ ][^ ]+
148             |we[ ]do[ ]not[ ]accept[ ]mail[ ]from[ ](?: # @mail.ru
149             dynamic[ ]ips
150             |hosts[ ]with[ ]dynamic[ ]ip[ ]or[ ]generic[ ]dns[ ]ptr-records
151             )
152             |you[ ]are[ ](?:
153             not[ ]allowed[ ]to[ ]connect
154             |sending[ ]spam
155             )
156             |your[ ](?:
157             email[ ]address[ ]has[ ]been[ ]blacklisted
158             |network[ ]is[ ]temporary[ ]blacklisted
159             |sender's[ ]ip[ ]address[ ]is[ ]listed[ ]at[ ][^ ]+[.]abuseat[.]org
160             |server[ ]requires[ ]confirmation
161             )
162             )
163             }x;
164 1123 100       36523 return 1 if $argv1 =~ $regex;
165 925         3709 return 0;
166             }
167              
168             sub true {
169             # Rejected due to client IP address or hostname
170             # @param [Sisimai::Data] argvs Object to be detected the reason
171             # @return [Integer] 1: is blocked
172             # [Integer] 0: is not blocked by the client
173             # @see http://www.ietf.org/rfc/rfc2822.txt
174             # @since v4.0.0
175 687     687 0 1290 my $class = shift;
176 687   100     1605 my $argvs = shift // return undef;
177              
178 686 50       1392 return 1 if $argvs->reason eq 'blocked';
179 686 100 100     3649 return 1 if (Sisimai::SMTP::Status->name($argvs->deliverystatus) || '') eq 'blocked';
180 676 100       1707 return 1 if __PACKAGE__->match(lc $argvs->diagnosticcode);
181             }
182              
183             1;
184             __END__