File Coverage

lib/Sisimai/Reason/Blocked.pm
Criterion Covered Total %
statement 27 27 100.0
branch 8 8 100.0
condition 6 6 100.0
subroutine 8 8 100.0
pod 2 4 50.0
total 51 53 96.2


line stmt bran cond sub pod time code
1             package Sisimai::Reason::Blocked;
2 52     52   2331 use v5.26;
  52         215  
3 52     52   624 use strict;
  52         97  
  52         1738  
4 52     52   252 use warnings;
  52         102  
  52         2929  
5 52     52   350 use Sisimai::String;
  52         125  
  52         25649  
6              
7 101     101 1 322 sub text { 'blocked' }
8 4     4 0 18 sub description { 'Email rejected due to client IP address or a hostname' }
9             sub match {
10             # Try to match that the given text and regular expressions
11             # @param [String] argv1 String to be matched with regular expressions
12             # @return [Integer] 0: Did not match
13             # 1: Matched
14             # @since v4.0.0
15 1189     1189 1 3748 my $class = shift;
16 1189   100     4366 my $argv1 = shift // return 0;
17              
18 1188         2601 state $index = [
19             "bad sender ip address",
20             "banned sending ip", # Office365
21             "blacklisted by",
22             "dnsbl:attrbl",
23             "client host rejected: abus detecte gu_eib_02", # SFR
24             "client host rejected: abus detecte gu_eib_04", # SFR
25             "client host rejected: may not be mail exchanger",
26             "connection refused by",
27             "currently sending spam see: ",
28             "domain does not exist:",
29             "domain isn't in my list of allowed rcpthosts",
30             "error: no valid recipients from ",
31             "esmtp not accepting connections", # icloud.com
32             "extreme bad ip profile",
33             "helo command rejected:",
34             "host network not allowed",
35             "invalid ip for sending mail of domain",
36             "is in a black list",
37             "is not allowed to send mail from",
38             "no access from mail server",
39             "part of their network is on our block list",
40             "please use the smtp server of your isp",
41             "rejected because the sending mta or the sender has not passed validation",
42             "rejecting open proxy", # Sendmail(srvrsmtp.c)
43             "sender ip address rejected",
44             "server access forbidden by your ip ",
45             "smtp error from remote mail server after initial connection:", # Exim
46             "you are not allowed to connect",
47             "your ip address is listed in the rbl",
48             "your network is temporary blacklisted",
49             "your remotehost looks suspiciously like spammer",
50             "your server requires confirmation",
51             ];
52 1188         2807 state $pairs = [
53             ["(", "@", ":blocked)"],
54             ["access from ip address ", " blocked"],
55             ["blocked by ", " dnsbl"],
56             ["client ", " blocked using"],
57             ["connection ", "dropped"],
58             ["client host ", " blocked using"],
59             ["connections will not be accepted from ", " because the ip is in spamhaus's list"],
60             ["dynamic", " ip"],
61             ["email blocked by ", ".barracudacentral.org"],
62             ["email blocked by ", "spamhaus"],
63             ["from ", " ip address"],
64             ["host ", " said: ", "550 blocked"],
65             ["host ", " refused to talk to me: ", " blocked"],
66             ["ip ", " is blocked by earthlink"], # Earthlink
67             ["is in an ", "rbl on "],
68             ["mail server at ", " is blocked"],
69             ["mail from "," refused"],
70             ["message from ", " rejected based on blacklist"],
71             ["messages from ", " temporarily deferred due to user complaints"], # Yahoo!
72             ["server ip ", " listed as abusive"],
73             ["sorry! your ip address", " is blocked by rbl"], # junkemailfilter.com
74             ["the ", " is blacklisted"], # the email, the domain, the ip
75             ["veuillez essayer plus tard. service refused, please try later. ", "103"],
76             ["veuillez essayer plus tard. service refused, please try later. ", "510"],
77             ["your access ip", " has been rejected"],
78             ["your sender's ip address is listed at ", ".abuseat.org"],
79             ];
80 1188 100       3351 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  38016         72342  
81 1125 100       2923 return 1 if grep { Sisimai::String->aligned(\$argv1, $_) } @$pairs;
  29250         56581  
82 1091         5138 return 0;
83             }
84              
85             sub true {
86             # Rejected due to client IP address or hostname
87             # @param [Sisimai::Fact] argvs Object to be detected the reason
88             # @return [Integer] 1: is blocked
89             # [Integer] 0: is not blocked by the client
90             # @see http://www.ietf.org/rfc/rfc2822.txt
91             # @since v4.0.0
92 665     665 0 1425 my $class = shift;
93 665   100     3960 my $argvs = shift // return 0;
94              
95 664 100       2415 return 1 if $argvs->{'reason'} eq 'blocked';
96 663 100 100     4441 return 1 if (Sisimai::SMTP::Status->name($argvs->{'deliverystatus'}) || '') eq 'blocked';
97 658         3643 return __PACKAGE__->match(lc $argvs->{'diagnosticcode'});
98             }
99              
100             1;
101             __END__