File Coverage

lib/Sisimai/Reason/NotAccept.pm
Criterion Covered Total %
statement 24 24 100.0
branch 4 6 66.6
condition 9 12 75.0
subroutine 7 7 100.0
pod 2 4 50.0
total 46 53 86.7


line stmt bran cond sub pod time code
1             package Sisimai::Reason::NotAccept;
2 46     46   4060 use v5.26;
  46         164  
3 46     46   252 use strict;
  46         79  
  46         1242  
4 46     46   220 use warnings;
  46         73  
  46         15925  
5              
6 1     1 1 652 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 794     794 1 3197 my $class = shift;
15 794   100     2890 my $argv1 = shift // return 0;
16              
17             # Destination mail server does not accept any message
18 793         1337 state $index = [
19             "does not accept mail", # Sendmail, iCloud
20             "mail receiving disabled",
21             "name server: .: host not found", # Sendmail
22             "no mx record found for domain=", # Oath(Yahoo!)
23             "no route for current request",
24             ];
25 793 100       2077 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  3965         8219  
26 786         2756 return 0;
27             }
28              
29             sub true {
30             # Remote host does not accept any message
31             # @param [Sisimai::Fact] argvs Object to be detected the reason
32             # @return [Integer] 1: Not accept
33             # 0: Accept
34             # @since v4.0.0
35             # @see http://www.ietf.org/rfc/rfc2822.txt
36 4     4 0 14 my $class = shift;
37 4   100     15 my $argvs = shift // return 0; my $reply = int $argvs->{'replycode'} || 0;
  3   50     97  
38              
39             # SMTP Reply Code is 521, 554 or 556
40 3         17 require Sisimai::SMTP::Command;
41 3 50 66     18 return 1 if $argvs->{'reason'} eq 'notaccept' || $reply == 521 || $reply == 556;
      66        
42 2 50       17 return 0 if grep { $argvs->{'command'} eq $_ } Sisimai::SMTP::Command->BeforeRCPT->@*;
  12         18  
43 2         9 return __PACKAGE__->match(lc $argvs->{'diagnosticcode'});
44             }
45              
46             1;
47             __END__