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 13     13   1597 use feature ':5.10';
  13         20  
  13         830  
3 13     13   63 use strict;
  13         20  
  13         254  
4 13     13   52 use warnings;
  13         17  
  13         2996  
5              
6 7     7 1 14 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 192     192 1 312 my $class = shift;
15 192   50     480 my $argv1 = shift // return undef;
16              
17 192         276 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 192 100       2130 return 1 if $argv1 =~ $regex;
32 159         386 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 6 return undef;
42             }
43              
44             1;
45             __END__