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   1836 use feature ':5.10';
  47         82  
  47         3126  
3 47     47   232 use strict;
  47         66  
  47         853  
4 47     47   186 use warnings;
  47         69  
  47         85363  
5              
6 203     203 1 475 sub text { 'blocked' }
7 4     4 0 13 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 1137     1137 1 3743 my $class = shift;
15 1137   50     2415 my $argv1 = shift // return undef;
16              
17 1137         1818 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
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             |fix[ ]reverse[ ]dns[ ]for[ ][^ ]+
65             |go[ ]away
66             |helo[ ]command[ ]rejected:
67             |host[ ][^ ]+[ ]refused[ ]to[ ]talk[ ]to[ ]me:[ ]\d+[ ]blocked
68             |host[ ]network[ ]not[ ]allowed
69             |hosts[ ]with[ ]dynamic[ ]ip
70             |http://(?:
71             spf[.]pobox[.]com/why[.]html
72             |www[.]spamcop[.]net/bl[.]
73             )
74             |invalid[ ]ip[ ]for[ ]sending[ ]mail[ ]of[ ]domain
75             |ip[ ]\d{1,3}[.]\d{1,3}[.]\d{1,3}[.]\d{1,3}[ ]is[ ]blocked[ ]by[ ]earthlink # Earthlink
76             |ip[/]domain[ ]reputation[ ]problems
77             |ips[ ]with[ ]missing[ ]ptr[ ]records
78             |is[ ](?:
79             in[ ]a[ ]black[ ]list(?:[ ]at[ ][^ ]+[.])?
80             |in[ ]an[ ][^ ]+rbl[ ]on[ ][^ ]+
81             |not[ ]allowed[ ]to[ ]send[ ](?:
82             mail[ ]from
83             |from[ ][<][^ ]+[>][ ]per[ ]it's[ ]spf[ ]record
84             )
85             )
86             |mail[ ]server[ ]at[ ][^ ]+[ ]is[ ]blocked
87             |mail[ ]from[ ]\d+[.]\d+[.]\d+[.]\d[ ]refused:
88             |message[ ]from[ ][^ ]+[ ]rejected[ ]based[ ]on[ ]blacklist
89             |message[ ]was[ ]rejected[ ]for[ ]possible[ ]spam/virus[ ]content
90             |messages[ ]from[ ][^ ]+[ ]temporarily[ ]deferred[ ]due[ ]to[ ]user[ ]complaints # Yahoo!
91             |no[ ](?:
92             access[ ]from[ ]mail[ ]server
93             |ptr[ ]record[ ]found[.]
94             )
95             |not[ ]currently[ ]accepting[ ]mail[ ]from[ ]your[ ]ip # Microsoft
96             |part[ ]of[ ]their[ ]network[ ]is[ ]on[ ]our[ ]block[ ]list
97             |please[ ](?:
98             get[ ]a[ ]custom[ ]reverse[ ]dns[ ]name[ ]from[ ]your[ ]isp[ ]for[ ]your[ ]host
99             |inspect[ ]your[ ]spf[ ]settings
100             |use[ ]the[ ]smtp[ ]server[ ]of[ ]your[ ]isp
101             )
102             |ptr[ ]record[ ]setup
103             |rejected[ ]because[ ]the[ ]sending[ ]mta[ ]or[ ]the[ ]sender[ ]has[ ]not[ ]passed[ ]validation
104             |rejected[ ]due[ ]to[ ](?:
105             a[ ]poor[ ]email[ ]reputation[ ]score
106             |the[ ]sending[ ]mta's[ ]poor[ ]reputation
107             )
108             |rejecting[ ]open[ ]proxy # Sendmail(srvrsmtp.c)
109             |reverse[ ]dns[ ](?:
110             failed
111             |required
112             |lookup[ ]for[ ]host[ ][^ ]+[ ]failed[ ]permanently
113             )
114             |sender[ ]ip[ ](?:
115             address[ ]rejected
116             |reverse[ ]lookup[ ]rejected
117             )
118             |server[ ]access[ ](?:
119             [^ ]+[ ]forbidden[ ]by[ ]invalid[ ]rdns[ ]record[ ]of[ ]your[ ]mail[ ]server
120             |forbidden[ ]by[ ]your[ ]ip[ ]
121             )
122             |server[ ]ip[ ][^ ]+[ ]listed[ ]as[ ]abusive
123             |service[ ]not[ ]available,[ ]closing[ ]transmission[ ]channel
124             |service[ ]permits[ ]\d+[ ]unverifyable[ ]sending[ ]ips
125             |smtp[ ]error[ ]from[ ]remote[ ]mail[ ]server[ ]after[ ]initial[ ]connection: # Exim
126             |sorry,[ ](?:
127             that[ ]domain[ ]isn'?t[ ]in[ ]my[ ]list[ ]of[ ]allowed[ ]rcpthosts
128             |your[ ]remotehost[ ]looks[ ]suspiciously[ ]like[ ]spammer
129             )
130             |spf[ ](?:
131             [(]sender[ ]policy[ ]framework[)][ ]domain[ ]authentication[ ]fail
132             |record
133             |check:[ ]fail
134             )
135             |spf:[ ][^ ]+[ ]is[ ]not[ ]allowed[ ]to[ ]send[ ]mail[.][ ][a-z0-9]_401
136             |temporarily[ ]deferred[ ]due[ ]to[ ]unexpected[ ]volume[ ]or[ ]user[ ]complaints
137             |the[ ](?:email|domain|ip)[ ][^ ]+[ ]is[ ]blacklisted
138             |this[ ]system[ ]will[ ]not[ ]accept[ ]messages[ ]from[ ]servers[/]devices[ ]with[ ]no[ ]reverse[ ]dns
139             |to[ ]submit[ ]messages[ ]to[ ]this[ ]e-mail[ ]system[ ]has[ ]been[ ]rejected
140             |too[ ]many[ ](?:
141             spams[ ]from[ ]your[ ]ip # free.fr
142             |unwanted[ ]messages[ ]have[ ]been[ ]sent[ ]from[ ]the[ ]following[ ]ip[ ]address[ ]above
143             )
144             |unresolvable[ ]relay[ ]host[ ]name
145             |veuillez[ ]essayer[ ]plus[ ]tard[.][ ]service[ ]refused,[ ]please[ ]try[ ]later[.][ ][0-9a-z_]+(?:103|510)
146             |was[ ]blocked[ ]by[ ][^ ]+
147             |we[ ]do[ ]not[ ]accept[ ]mail[ ]from[ ](?: # @mail.ru
148             dynamic[ ]ips
149             |hosts[ ]with[ ]dynamic[ ]ip[ ]or[ ]generic[ ]dns[ ]ptr-records
150             )
151             |you[ ]are[ ](?:
152             not[ ]allowed[ ]to[ ]connect
153             |sending[ ]spam
154             )
155             |your[ ](?:
156             email[ ]address[ ]has[ ]been[ ]blacklisted
157             |network[ ]is[ ]temporary[ ]blacklisted
158             |sender's[ ]ip[ ]address[ ]is[ ]listed[ ]at[ ][^ ]+[.]abuseat[.]org
159             |server[ ]requires[ ]confirmation
160             )
161             )
162             }x;
163 1137 100       31594 return 1 if $argv1 =~ $regex;
164 939         3259 return 0;
165             }
166              
167             sub true {
168             # Rejected due to client IP address or hostname
169             # @param [Sisimai::Data] argvs Object to be detected the reason
170             # @return [Integer] 1: is blocked
171             # [Integer] 0: is not blocked by the client
172             # @see http://www.ietf.org/rfc/rfc2822.txt
173             # @since v4.0.0
174 697     697 0 1493 my $class = shift;
175 697   100     1651 my $argvs = shift // return undef;
176              
177 696 50       1469 return 1 if $argvs->reason eq 'blocked';
178 696 100 100     3592 return 1 if (Sisimai::SMTP::Status->name($argvs->deliverystatus) || '') eq 'blocked';
179 686 100       1929 return 1 if __PACKAGE__->match(lc $argvs->diagnosticcode);
180             }
181              
182             1;
183             __END__