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 15     15   1583 use feature ':5.10';
  15         29  
  15         943  
3 15     15   70 use strict;
  15         24  
  15         249  
4 15     15   63 use warnings;
  15         20  
  15         4050  
5              
6 1     1 1 5 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 202     202 1 340 my $class = shift;
15 202   50     485 my $argv1 = shift // return undef;
16              
17             # Destination mail server does not accept any message
18 202         310 state $index = [
19             'host/domain does not accept mail', # iCloud
20             'host does not accept mail', # Sendmail
21             'name server: .: host not found', # Sendmail
22             'no mx record found for domain=', # Oath(Yahoo!)
23             'no route for current request',
24             'smtp protocol returned a permanent error',
25             ];
26 202 100       373 return 1 if grep { rindex($argv1, $_) > -1 } @$index;
  1212         1906  
27 191         424 return 0;
28             }
29              
30             sub true {
31             # Remote host does not accept any message
32             # @param [Sisimai::Data] argvs Object to be detected the reason
33             # @return [Integer] 1: Not accept
34             # 0: Accept
35             # @since v4.0.0
36             # @see http://www.ietf.org/rfc/rfc2822.txt
37 2     2 0 4 my $class = shift;
38 2   100     6 my $argvs = shift // return undef;
39 1 50       3 return 1 if $argvs->reason eq 'notaccept';
40              
41             # SMTP Reply Code is 521, 554 or 556
42 1 50       6 return 1 if $argvs->replycode =~ /\A(?:521|554|556)\z/;
43 1 50       8 return 0 if $argvs->smtpcommand ne 'MAIL';
44 0 0         return 1 if __PACKAGE__->match(lc $argvs->diagnosticcode);
45 0           return 0;
46             }
47              
48             1;
49             __END__