File Coverage

lib/Sisimai/Reason/NotAccept.pm
Criterion Covered Total %
statement 22 24 91.6
branch 5 10 50.0
condition 3 4 75.0
subroutine 7 7 100.0
pod 2 4 50.0
total 39 49 79.5


line stmt bran cond sub pod time code
1             package Sisimai::Reason::NotAccept;
2 39     39   1125 use feature ':5.10';
  39         78  
  39         2766  
3 39     39   236 use strict;
  39         72  
  39         736  
4 39     39   181 use warnings;
  39         69  
  39         11153  
5              
6 1     1 1 615 sub text { 'notaccept' }
7 4     4 0 14 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 596     596 1 1042 my $class = shift;
15 596   50     1559 my $argv1 = shift // return undef;
16              
17             # Destination mail server does not accept any message
18 596         901 state $index = [
19             'does not accept mail (nullmx)',
20             'host/domain does not accept mail', # iCloud
21             'host does not accept mail', # Sendmail
22             'name server: .: host not found', # Sendmail
23             'no mx record found for domain=', # Oath(Yahoo!)
24             'no route for current request',
25             'smtp protocol returned a permanent error',
26             ];
27 596 100       1230 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  4172         7179  
28 585         1565 return 0;
29             }
30              
31             sub true {
32             # Remote host does not accept any message
33             # @param [Sisimai::Data] argvs Object to be detected the reason
34             # @return [Integer] 1: Not accept
35             # 0: Accept
36             # @since v4.0.0
37             # @see http://www.ietf.org/rfc/rfc2822.txt
38 2     2 0 6 my $class = shift;
39 2   100     8 my $argvs = shift // return undef;
40 1 50       7 return 1 if $argvs->reason eq 'notaccept';
41              
42             # SMTP Reply Code is 521, 554 or 556
43 1 50       13 return 1 if $argvs->replycode =~ /\A(?:521|554|556)\z/;
44 1 50       14 return 0 if $argvs->smtpcommand ne 'MAIL';
45 0 0         return 1 if __PACKAGE__->match(lc $argvs->diagnosticcode);
46 0           return 0;
47             }
48              
49             1;
50             __END__