File Coverage

lib/Sisimai/Reason/NotAccept.pm
Criterion Covered Total %
statement 27 27 100.0
branch 8 8 100.0
condition 11 12 91.6
subroutine 7 7 100.0
pod 2 4 50.0
total 55 58 94.8


line stmt bran cond sub pod time code
1             package Sisimai::Reason::NotAccept;
2 55     55   1378 use v5.26;
  55         188  
3 55     55   232 use strict;
  55         69  
  55         1187  
4 55     55   182 use warnings;
  55         100  
  55         16934  
5              
6 26     26 1 72 sub text { 'notaccept' }
7 4     4 0 17 sub description { 'Delivery failed due to a destination mail server does not accept any email' }
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 1093     1093 1 3310 my $class = shift;
15 1093   100     2525 my $argv1 = shift // return 0;
16              
17             # Destination mail server does not accept any message
18 1092         1352 state $index = [
19             "destination seem to reject all mails", # OpenSMTPD/smtp/mta.c
20             "does not accept mail", # Sendmail, iCloud
21             "mail receiving disabled",
22             "mx or srv record indicated no smtp ", # Exim/routers/dnslookup.c:328
23             "name server: .: host not found", # Sendmail
24             "no host found for existing smtp ", # Exim/transports/smtp.c:3502
25             "no route for current request",
26             "null mx",
27             ];
28 1092         1246 state $pairs = [
29             ["no mx ", "found for "], # OpenSMTPD/smtp/mta.c
30             ];
31 1092 100       2039 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  8736         11684  
32 1080 100       1548 return 1 if grep { Sisimai::String->aligned(\$argv1, $_) } @$pairs;
  1080         2606  
33 1070         2347 return 0;
34             }
35              
36             sub true {
37             # Remote host does not accept any message
38             # @param [Sisimai::Fact] argvs Object to be detected the reason
39             # @return [Integer] 1: Not accept
40             # 0: Accept
41             # @since v4.0.0
42             # @see http://www.ietf.org/rfc/rfc2822.txt
43 636     636 0 1046 my $class = shift;
44 636   100     1475 my $argvs = shift // return 0;
45 635   100     1960 my $reply = $argvs->{'replycode'} || 0;
46              
47             # SMTP Reply Code is 521, 554 or 556
48 635         1629 require Sisimai::SMTP::Command;
49 635 100 100     2973 return 1 if $argvs->{'reason'} eq 'notaccept' || $reply == 521 || $reply == 556;
      66        
50 629 100       1882 return 0 if grep { $argvs->{'command'} eq $_ } Sisimai::SMTP::Command->BeforeRCPT->@*;
  3774         4843  
51 579         1738 return __PACKAGE__->match(lc $argvs->{'diagnosticcode'});
52             }
53              
54             1;
55             __END__