File Coverage

lib/Sisimai/Order.pm
Criterion Covered Total %
statement 25 25 100.0
branch 2 2 100.0
condition 4 4 100.0
subroutine 6 6 100.0
pod 1 2 50.0
total 38 39 97.4


line stmt bran cond sub pod time code
1             package Sisimai::Order;
2 90     90   122413 use v5.26;
  90         254  
3 90     90   316 use strict;
  90         108  
  90         1760  
4 90     90   274 use warnings;
  90         167  
  90         3579  
5 90     90   28851 use Sisimai::Lhost;
  90         166  
  90         37680  
6              
7             sub make {
8             # Returns an MTA Order decided by the first word of the "Subject": header
9             # @param [String] argv0 Subject header string
10             # @return [Array] Order of MTA modules
11             # @since v4.25.4
12 3537     3537 0 206202 my $class = shift;
13 3537   100     6022 my $argv0 = shift || return []; y/_[] / /s, s/\A[ ]+// for $argv0;
  3519         10301  
14 3519         8081 my @words = split(/[ ]/, lc($argv0), 3);
15 3519         6575 my $first = '';
16              
17             # The following order is decided by the first 2 words of Subject: header
18 3519         8066 state $subject = {
19             'abuse-report' => ['Sisimai::ARF'],
20             'auto' => ['Sisimai::RFC3834'],
21             'auto-reply' => ['Sisimai::RFC3834'],
22             'automatic-reply' => ['Sisimai::RFC3834'],
23             'aws-notification' => ['Sisimai::Lhost::AmazonSES'],
24             'complaint-about' => ['Sisimai::ARF'],
25             'delivery-failure' => ['Sisimai::Lhost::Domino', 'Sisimai::Lhost::X2'],
26             'delivery-notification' => ['Sisimai::Lhost::MessagingServer'],
27             'delivery-status' => [
28             'Sisimai::Lhost::OpenSMTPD',
29             'Sisimai::Lhost::GoogleWorkspace',
30             'Sisimai::Lhost::Gmail',
31             'Sisimai::Lhost::GoogleGroups',
32             'Sisimai::Lhost::AmazonSES',
33             'Sisimai::Lhost::X3',
34             ],
35             'dmarc-ietf-dmarc' => ['Sisimai::ARF'],
36             'email-feedback' => ['Sisimai::ARF'],
37             'failed-delivery' => ['Sisimai::Lhost::X2'],
38             'failure-delivery' => ['Sisimai::Lhost::X2'],
39             'failure-notice' => ['Sisimai::Lhost::qmail', 'Sisimai::Lhost::mFILTER', 'Sisimai::Lhost::Activehunter'],
40             'loop-alert' => ['Sisimai::Lhost::FML'],
41             'mail-could' => ['Sisimai::Lhost::TrendMicro'],
42             'mail-delivery' => [
43             'Sisimai::Lhost::Exim',
44             'Sisimai::Lhost::DragonFly',
45             'Sisimai::Lhost::GMX',
46             'Sisimai::Lhost::Zoho',
47             'Sisimai::Lhost::EinsUndEins',
48             'Sisimai::Lhost::DeutscheTelekom',
49             ],
50             'mail-failed' => ['Sisimai::Lhost::DeutscheTelekom'],
51             'mail-failure' => ['Sisimai::Lhost::Exim'],
52             'mail-system' => ['Sisimai::Lhost::EZweb'],
53             'message-delivery' => ['Sisimai::Lhost::MailFoundry'],
54             'message-frozen' => ['Sisimai::Lhost::Exim'],
55             'non-recapitabile' => ['Sisimai::Lhost::Exchange2007'],
56             'non-remis' => ['Sisimai::Lhost::Exchange2007'],
57             'notice' => ['Sisimai::Lhost::Courier'],
58             'postmaster-email' => ['Sisimai::Lhost::Mimecast'],
59             'postmaster-notify' => ['Sisimai::Lhost::Sendmail'],
60             'returned-mail' => [
61             'Sisimai::Lhost::Sendmail',
62             'Sisimai::Lhost::Biglobe',
63             'Sisimai::Lhost::V5sendmail',
64             'Sisimai::Lhost::X1',
65             ],
66             'there-was' => ['Sisimai::Lhost::X6'],
67             'undeliverable' => ['Sisimai::Lhost::Exchange2007', 'Sisimai::Lhost::Exchange2003'],
68             'undeliverable-mail' => ['Sisimai::Lhost::MailMarshal', 'Sisimai::Lhost::IMailServer'],
69             'undeliverable-message' => ['Sisimai::Lhost::Notes', 'Sisimai::Lhost::Verizon'],
70             'undelivered-mail' => ['Sisimai::Lhost::Postfix', 'Sisimai::Lhost::Zoho'],
71             'warning' => ['Sisimai::Lhost::Sendmail', 'Sisimai::Lhost::Exim'],
72             };
73              
74 3519 100       7070 if( rindex($words[0], ':') > 0 ) {
75             # Undeliverable: ..., notify: ...
76 206         541 $first = lc substr($argv0, 0, index($argv0, ':'));
77              
78             } else {
79             # Postmaster notify, returned mail, ...
80 3313         9565 $first = join('-', splice(@words, 0, 2));
81             }
82 3519         4803 $first =~ y/:",*//d;
83 3519   100     13768 return $subject->{ $first } || [];
84             }
85              
86             sub another {
87             # Make MTA modules list as a spare
88             # @return [Array] Ordered module list
89             # @since v4.13.1
90              
91             # There are another patterns in the value of "Subject:" header of a bounce mail generated by the
92             # following MTA modules
93 88     88 1 466 state $orderE0 = [
94             'Sisimai::Lhost::Exim',
95             'Sisimai::Lhost::Sendmail',
96             'Sisimai::Lhost::Exchange2007',
97             'Sisimai::Lhost::Exchange2003',
98             'Sisimai::Lhost::AmazonSES',
99             'Sisimai::Lhost::TrendMicro',
100             'Sisimai::Lhost::DeutscheTelekom',
101             'Sisimai::Lhost::KDDI',
102             'Sisimai::Lhost::FML',
103             'Sisimai::Lhost::Verizon',
104             'Sisimai::Lhost::ApacheJames',
105             'Sisimai::Lhost::X2',
106             ];
107              
108             # Fallback list: The following MTA/ESP modules is not listed orderE0
109 88         634 state $orderE1 = [
110             'Sisimai::Lhost::Postfix',
111             'Sisimai::Lhost::OpenSMTPD',
112             'Sisimai::Lhost::qmail',
113             'Sisimai::Lhost::Courier',
114             'Sisimai::Lhost::MessagingServer',
115             'Sisimai::Lhost::GoogleWorkspace',
116             'Sisimai::Lhost::Gmail',
117             'Sisimai::Lhost::GMX',
118             'Sisimai::Lhost::Zoho',
119             'Sisimai::Lhost::Domino',
120             'Sisimai::Lhost::Notes',
121             'Sisimai::Lhost::IMailServer',
122             'Sisimai::Lhost::mFILTER',
123             'Sisimai::Lhost::Activehunter',
124             'Sisimai::Lhost::MailFoundry',
125             'Sisimai::Lhost::GoogleGroups',
126             'Sisimai::Lhost::MailMarshal',
127             'Sisimai::Lhost::V5sendmail',
128             'Sisimai::Lhost::EZweb',
129             'Sisimai::Lhost::Biglobe',
130             'Sisimai::Lhost::EinsUndEins',
131             'Sisimai::Lhost::DragonFly',
132             'Sisimai::Lhost::X1',
133             'Sisimai::Lhost::X3',
134             'Sisimai::Lhost::X6',
135             ];
136 88         667 return [@$orderE0, @$orderE1];
137             };
138              
139             1;
140             __END__