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   2067 use feature ':5.10';
  17         33  
  17         1120  
3 17     17   93 use strict;
  17         33  
  17         292  
4 17     17   75 use warnings;
  17         26  
  17         4679  
5              
6 7     7 1 18 sub text { 'mailererror' }
7 4     4 0 15 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 414 my $class = shift;
15 227   50     612 my $argv1 = shift // return undef;
16              
17 227         366 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       3594 return 1 if $argv1 =~ $regex;
32 194         587 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 9 return undef;
42             }
43              
44             1;
45             __END__