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 55     55   1445 use v5.26;
  55         183  
3 55     55   466 use strict;
  55         71  
  55         1348  
4 55     55   202 use warnings;
  55         83  
  55         2188  
5 55     55   212 use Sisimai::String;
  55         80  
  55         21015  
6              
7 101     101 1 1124 sub text { 'blocked' }
8 4     4 0 19 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 1261     1261 1 3225 my $class = shift;
16 1261   100     3727 my $argv1 = shift // return 0;
17              
18 1260         1741 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 1260         1918 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 1260 100       2297 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  40320         47544  
81 1197 100       2113 return 1 if grep { Sisimai::String->aligned(\$argv1, $_) } @$pairs;
  31122         36490  
82 1163         2759 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 732     732 0 1239 my $class = shift;
93 732   100     1544 my $argvs = shift // return 0;
94              
95 731 100       1726 return 1 if $argvs->{'reason'} eq 'blocked';
96 730 100 100     1867 return 1 if (Sisimai::SMTP::Status->name($argvs->{'deliverystatus'}) || '') eq 'blocked';
97 725         2297 return __PACKAGE__->match(lc $argvs->{'diagnosticcode'});
98             }
99              
100             1;
101             __END__