File Coverage

lib/Sisimai/Reason/MailerError.pm
Criterion Covered Total %
statement 17 17 100.0
branch 2 2 100.0
condition 1 2 50.0
subroutine 7 7 100.0
pod 2 4 50.0
total 29 32 90.6


line stmt bran cond sub pod time code
1             package Sisimai::Reason::MailerError;
2 17     17   1984 use feature ':5.10';
  17         39  
  17         1194  
3 17     17   99 use strict;
  17         32  
  17         296  
4 17     17   86 use warnings;
  17         34  
  17         4848  
5              
6 7     7 1 18 sub text { 'mailererror' }
7 4     4 0 14 sub description { 'Email returned due to a mailer program has not exited successfully' }
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 227     227 1 478 my $class = shift;
15 227   50     596 my $argv1 = shift // return undef;
16              
17 227         352 state $regex = qr{(?>
18             \Aprocmail:[ ] # procmail
19             |bin/(?:procmail|maildrop)
20             |command[ ](?:
21             failed:[ ]
22             |died[ ]with[ ]status[ ]\d+
23             |output:
24             )
25             |exit[ ]\d+
26             |mailer[ ]error
27             |pipe[ ]to[ ][|][/][^ ]+
28             |x[-]unix[;][ ]\d+ # X-UNIX; 127
29             )
30             }x;
31 227 100       3737 return 1 if $argv1 =~ $regex;
32 194         633 return 0;
33             }
34              
35             sub true {
36             # The bounce reason is mailer error or not
37             # @param [Sisimai::Data] argvs Object to be detected the reason
38             # @return [Integer] 1: is mailer error
39             # 0: is not mailer error
40             # @see http://www.ietf.org/rfc/rfc2822.txt
41 2     2 0 7 return undef;
42             }
43              
44             1;
45             __END__