Sisimai/Rhost/Mimecast.pm

filter: Statementstmt 100% 28 / 28 Branchbran 100% 8 / 8 Conditioncond 66.6% 4 / 6 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 90.2% 46 / 51 CC 10 SCAR 20.1
CC
10
Cov
95%
find
10.0
BEGIN
1.0
BEGIN
1.0
CRAP 7.4
« Sisimai/Mail/Mbox.pm ↑ Summary Sisimai/Reason/UserUnknown.pm »
1 package Sisimai::Rhost::Mimecast;
2 5 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use Sisimai::SMTP::Reply;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 21 ▶sub find {
Subroutine find: called CC=10 SCAR=23.1
Pod undocumented
8 # Detect bounce reason from https://www.mimecast.com/
9 # @param [Sisimai::Fact] argvs Decoded email object
10 # @return [String] The bounce reason at Mimecast
11 # @since v4.25.15
12 21 my $class = shift;
13 21 ▶ my $argvs = shift // return "";
Condition100%2/2
shift() // (return "")
l!l
201
MC/DC100%1/1
shift() // (return "")
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
14 20 ▶ return '' unless $argvs->{'diagnosticcode'};
Branch: 1 branch
BranchTrueFalseTotal
unless $argvs->{"diagnosticcode"} 1 19 20
15 19 ▶ return '' unless Sisimai::SMTP::Reply->test($argvs->{'replycode'});
Branch: 1 branch
BranchTrueFalseTotal
unless "Sisimai::SMTP::Reply"->test($argvs->{"replycode"}) 2 17 19
16  
17 17 require Sisimai::Eb;
18 17 state $messagesof = {
19 # - https://community.mimecast.com/s/article/email-security-cloud-gateway-mimecast-smtp-error-codes
20 # - https://mimecastsupport.zendesk.com/hc/en-us/articles/34000709564691-Policies-Mimecast-SMTP-Error-Codes
21 $Sisimai::Eb::ReAUTH => [
22 # - The inbound message has been rejected because the originated IP address isn't list-
23 # ed in the published SPF records for the sending domain.
24 # - Ensure all the IP addresses for your mail servers are listed in your SPF records.
25 # Alternatively, create a DNS Authentication (Inbound / Outbound) policy with the
26 # "Inbound SPF" or "Reject on Hard Fail" option disabled. Messages that fail our SPF
27 # checks are subjected to spam and RBL checks, instead of being rejected.
28 [550, 'spf sender invalid - envelope rejected'],
29  
30 # - The DKIM key for the outbound message is broken and doesn't match the DNS record of
31 # the registered sender.
32 # - Check your organization's DNS record is populated with the right public key as part
33 # of the DNS Authentication Outbound Signing definition. The private key of the key-
34 # pair must be populated in the DNS Authentication policy, along with the domain and
35 # selector of that record.
36 [550, 'dkim sender invalid - envelope rejected'],
37  
38 # - The inbound message has been rejected because the originated IP address isn't list-
39 # ed in the published SPF records for the sending domain.
40 # - Ensure all the IP addresses for your mail servers are listed in your SPF records.
41 [550, 'dmarc sender invalid - envelope rejected'],
42 ],
43 $Sisimai::Eb::ReFAMA => [
44 # - The sending mail server is subjected to Greylisting. This requires the server to
45 # retry the connection, between one minute and 12 hours. Alternatively, the sender's
46 # IP address has a poor reputation.
47 # - These reputation checks can be bypassed with an Auto Allow or Permitted Senders
48 # policy. If it's legitimate traffic, amend your Greylisting policy.
49 [451, 'internal resources are temporarily unavailable'],
50  
51 # - Ongoing reputation checks have resulted in the message being rejected due to poor
52 # IP reputation. This could occur after a 4xx error.
53 # - Create an Auto Allow or Permitted Senders policy.
54 # Note:
55 # You can request a review of your source IP ranges by completing our online form.
56 [550, 'local ct ip reputation - (reject)'],
57 ],
58 $Sisimai::Eb::ReBLOC => [
59 # - Sender address blocked.
60 # A Blocked Senders Policy has blocked the sender's IP address.
61 # - The sender's IP address has been blocked by a Blocked Senders Policy.
62 # - Remove the entry from the policy.
63 [421, 'sender address blocked'],
64  
65 # - The Sender's IP address has been placed on the block list due to too many invalid
66 # connections.
67 # - The sender's mail server must retry the connection. The mail server performing the
68 # connection says the recipient address validation isn't responding.
69 [451, 'recipient temporarily unavailable'],
70  
71 # - You've reached your mail server's limit.
72 # - Wait and try again. The mail server won't accept any messages until you're under
73 # the limit.
74 [451, 'ip temporarily blacklisted'],
75  
76 # - The sender's IP address is listed in an RBL. The text displayed is specific to the
77 # RBL which lists the sender's IP address.
78 # - Bypass the RBL with an Auto Allow or Permitted Senders policy. Additionally request
79 # the associated IP address from the RBL.
80 #[550, '< details of RBL >'], NEED AN ACTUAL ERROR MESSAGE STRING
81 ],
82 $Sisimai::Eb::ReSIZE => [
83 # - The email size either exceeds an Email Size Limit policy or is larger than the
84 # Mimecast service limit. The default is 100 MB for the Legacy MTA, and 200 MB for
85 # "the Latest MTA".
86 # - Resend the message ensuring it's smaller than the limitation set. The transmission
87 # and content-encoding can add significantly to the total message size (e.g. a mes-
88 # sage with a 70 MB attachment, can have an overall size larger than 100 MB).
89 [554, 'maximum email size exceeded'],
90 ],
91 $Sisimai::Eb::ReTIME => [
92 # - Journal messages past the expiration
93 # - Attempts are being made to journal mail past the set expiry threshold.
94 # A retry response will replace the failure because the message is marked for retry
95 # if rejected, causing the journal queue to grow.
96 # - Check to confirm there are no significant time discrepancies on the mail server.
97 # Discontinue journaling old messages past the expiry threshold.
98 [550, 'journal messages past the expiration'],
99 ],
100 $Sisimai::Eb::ReTTLS => [
101 # - SMTP inbound TLS has been enabled but no SSL certificate (or no valid certificate)
102 # has been selected to be used.
103 # - Delete or change the Secure Receipt or Secure Delivery policy enforcing TLS.
104 # Alternatively, ensure the certificates on the mail server haven't expired.
105 # If using a proxy server, ensure it isn't intercepting the traffic and modifying
106 # encryption parameters.
107 ["454", "tls not available due to temporary reason"],
108  
109 # - This email has been sent using SMTP, but TLS is required by policy.
110 # - Delete or change the Secure Receipt or Secure Delivery policy enforcing TLS.
111 # Alternatively, ensure the certificates on the mail server haven't expired. If using
112 # a proxy server, ensure it isn't intercepting the traffic and modifying encryption
113 # parameters.
114 [553, 'this route requires encryption (tls)'],
115  
116 # - A TLS connection has been attempted using a TLS version that is lower than TLS 1.2.
117 # - Delete or change the Secure Receipt or Secure Delivery policy enforcing TLS.
118 # Alternatively, ensure the mail server attempting to connect is using the appropri-
119 # ate version of TLS.
120 [553, 'this route requires tls version 1.2 or greater'],
121  
122 # - A secure connection was attempted using ciphers that do not meet the configured ci-
123 # pher strength.
124 # - Delete or change the Secure Receipt or Secure Delivery policy enforcing TLS. Alter-
125 # natively, ensure the certificates on the mail server haven't expired. If using a
126 # proxy server, ensure it isn't intercepting the traffic and modifying encryption
127 # parameters.
128 [553, 'this route requires high-strength ciphers'],
129  
130 # - Validation on your umbrella account's domain name does not conform to your DNS.
131 # - Check you DNS has the required umbrella accounts listed as comma-separated values.
132 [554, 'configuration is invalid for this certificate'],
133 ],
134 $Sisimai::Eb::ReINET => [
135 # - The recipients' domains have MX records configured incorrectly
136 # - Check and remove any MX records that point to hostnames with outbound references.
137 # Only Inbound smart hosts are supported on MX records.
138 [451, 'the incorrect hostname used for inbounds'],
139 [550, 'the incorrect hostname used for inbounds'],
140  
141 # - The message has too many "received headers" as it has been forwarded across multi-
142 # ple hops. Once 25 hops have been reached, the email is rejected.
143 # - Investigate the email addresses in the communication pairs, to see what forwarders
144 # are configured on the mail servers.
145 [554, 'mail loop detected'],
146 ],
147 $Sisimai::Eb::RePASS => [
148 # - Both the sender and recipient domains specified in the transmission are external to
149 # Mimecast, and aren't allowed to relay through the Mimecast service and/or the con-
150 # necting IP address isn't recognized as authorized.
151 # - Mimecast customers should contact Mimecast Support to add the Authorized Outbound
152 # address, or to take other remedial action.
153 [451, 'open relay not allowed'],
154 [451, 'open relay is not allowed'],
155 ],
156 $Sisimai::Eb::Re00MX => [
157 # - The customer account Inbound emails are disabled in the Administration Console.
158 # - Contact Mimecast Support if the account's inbound traffic should be allowed.
159 [451, 'account inbounds disabled'],
160 ],
161 $Sisimai::Eb::Re___1 => [
162 # - The customer account outbound emails are disabled in the Administration Console.
163 # - Contact Mimecast Support if the account's outbound traffic should be allowed.
164 [451, 'account outbounds disabled'],
165  
166 # - Omni Directional hostnames are enabled.
167 # - Disable Omni Directional hostnames.
168 [451, 'hostname is not authorized'],
169  
170 # - Attempts are being made to journal mail that is past the set expiry threshold. The
171 # failure will be replaced by a retry response because the message is marked for re-
172 # try if rejected, causing the journal queue to grow.
173 # - Check to confirm there are no significant time discrepancies on the mail server.
174 # Discontinue journaling old messages past the expiry threshold.
175 [550, 'journal message past expiration'],
176 ],
177 $Sisimai::Eb::ReWONT => [
178 # - The message has triggered an Anti-Spoofing policy.
179 # - Create an Anti-Spoofing policy to take no action for the sender's address or IP ad-
180 # dress.
181 [550, 'anti-spoofing policy - inbound not allowed'],
182 [550, 'rejected by header-based anti-spoofing policy'],
183  
184 # - The message has triggered a Content Examination policy.
185 # - Either create a Content Examination Bypass policy or adjust the Content Examination
186 # policy as required.
187 [550, 'message bounced due to content examination policy'],
188  
189 # - The message has triggered a Geographical Restriction policy.
190 # - Delete or amend the policy.
191 [554, 'host network not allowed'],
192 [554, 'host network, not allowed'],
193 ],
194 $Sisimai::Eb::ReRATE => [
195 # - There are too many concurrent inbound connections for the account. The default is 20.
196 # - The IP address is automatically removed from the block list after five minutes.
197 # Continued invalid connections result in the IP being readded to the block list. En-
198 # sure you don't route outbound or journal messages to Mimecast from an IP address
199 # that hasn't been authorized to do so.
200 [451, 'account service is temporarily unavailable'],
201  
202 # - The sending server issues more than 100 RCPT TO entries. By default, Mimecast only
203 # accepts 100 RCPT TO entries per message body (DATA). The error triggers the sending
204 # mail server to provide the DATA for the first 100 recipients before it provides the
205 # next batch of RCPT TO entries.
206 # - Most mail servers respect the transient error and treat it as a "truncation request".
207 # If your mail server, firewall, or on-site solution doesn't respect the error, you
208 # must ensure that no more than 100 recipients are submitted.
209 # Note:
210 # Solutions like SMTP Fix-Up / MailGuard and ESMTP inspection on Cisco Pix and
211 # ASA Firewalls are known not to respect the transient error. We advise you to
212 # disable this functionality.
213 [452, 'too many recipients'],
214  
215 # - There are too many concurrent outbound connections for the account.
216 # - Send the messages in smaller chunks to recipients.
217 [550, 'exceeding outbound thread limit'],
218 ],
219 $Sisimai::Eb::ReFROM => [
220 # - The sender's email address or domain has triggered a Blocked Senders Policy or
221 # there's an SPF hard rejection.
222 # - Delete or modify the Blocked Senders policy to exclude the sender address.
223 [550, 'administrative prohibition envelope blocked'],
224  
225 # - A personal block policy is in place for the email address/domain.
226 # - Remove the email address/domain from the Managed Senders list.
227 [550, 'envelope blocked - user entry'],
228 [550, 'envelope blocked - user domain entry'],
229 [550, 'rejected by header-based manually blocked senders - block for manual block'],
230  
231 # - A Block Sender Policy has been applied to reject emails based on the Header From or
232 # Envelope From address.
233 # - Delete or change the Blocked Senders policy.
234 [550, 'rejected by header-based blocked senders - block policy for header from'],
235 [550, 'envelope rejected - block policy for envelope from address'],
236 ],
237 $Sisimai::Eb::ReSAFE => [
238 # - Messages submitted to SMTP port 587 require authentication. This error indicates
239 # the authentication details provided were incorrect.
240 # - Check your authentication details match an internal email address in Mimecast, with
241 # a corresponding Mimecast cloud password. Alternatively, consider sending the mes-
242 # sage on SMTP port 25.
243 [535, 'incorrect authentication data'],
244 [550, 'submitter failed to disabled'],
245 [550, 'submitter failed to authenticate'],
246 ],
247 $Sisimai::Eb::ReSPAM => [
248 # - A signature was detected that could either be a virus, or a spam score over the
249 # maximum threshold. The spam score isn't available in the Administration Console. If
250 # you aren't a Mimecast customer but have emails rejected with this error code, con-
251 # tact the recipient to adjust their configuration and permit your address. If unsuc-
252 # cessful, your IT department can submit a request to review these email rejections
253 # via our Sender Feedback form.
254 # - Anti-virus checks cannot be bypassed. Contact the sender to see if they can stop
255 # these messages from being blocked. Anti-spam checks can be bypassed using a Per-
256 # mitted Senders or Auto Allow policy. Rejected emails can be viewed in your Outbound
257 # Activity and searching for the required email address.
258 [554, 'email rejected due to security policies'],
259 ],
260 $Sisimai::Eb::RePROC => [
261 # - The Mimecast server is under maximum load.
262 # - No action is required from the end-user. The message will retry 30 times and when
263 # server resources are available, the message is processed.
264 [451, 'unable to process connection at this time'],
265  
266 # - The message was incorrectly terminated. This can be caused by:
267 # - Files that previously contained a virus, but haven't been cleaned by an anti-virus
268 # product, leaving traces in the message.
269 # - Firewall issues on the sender's side.
270 # - Incorrectly configured content rules on a security device.
271 # - Investigate the Intrusion Detection software or other SMTP protocol analyzers. If
272 # running a Cisco Firewall, ensure the Mail- guard or SMTP Fixup module is disabled.
273 [451, 'message ended early'],
274  
275 # - Generic error if the reason is unknown
276 # - Contact Mimecast Support.
277 [451, 'unable to process command'],
278  
279 # - Generic error if the reason is unknown
280 # - Contact Mimecast Support.
281 [451, 'unable to process an email at this time'],
282 ],
283 $Sisimai::Eb::ReUSER => [
284 # - The email address isn't a valid SMTP address.
285 # - The sender must resend the message to a valid internal email address.
286 [501, 'invalid address'],
287  
288 # - The server has encountered a bad sequence of commands, or it requires an authenti-
289 # cation.
290 # - In case of a "bad sequence", the server has pulled off its commands in the wrong
291 # order, usually because of a broken connection. If authentication is needed, enter
292 # your username and password.
293 [503, 'user unknown'],
294  
295 # - Known recipient, LDAP, or SMTP call forwarding recipient validation checks haven't
296 # returned a valid internal user.
297 # - The sender must resend the message to a valid internal recipient address.
298 [550, 'invalid recipient'],
299 ],
300 };
301  
302 17 ▶ my $issuedcode = lc $argvs->{'diagnosticcode'} // 0;
Condition50%1/2
lc $argvs->{"diagnosticcode"} // 0
l!l
170
MC/DC0%0/1
lc $argvs->{"diagnosticcode"} // 0
lc $argvs->{"diagnosticcode"}
Truth table50%1/2
A
A= lc $argvs->{"diagnosticcode"}
Aresult
11
00
303 17 ▶ my $esmtpreply = int $argvs->{'replycode'} // 0;
Condition50%1/2
int $argvs->{"replycode"} // 0
l!l
170
MC/DC0%0/1
int $argvs->{"replycode"} // 0
int $argvs->{"replycode"}
Truth table50%1/2
A
A= int $argvs->{"replycode"}
Aresult
11
00
304 17 my $reasontext = '';
305  
306 17 REASON: for my $e ( keys %$messagesof ) {
307 # Try to find with each error message defined in $messagesof
308 196 for my $f ( $messagesof->{ $e }->@* ) {
309 # Find an error reason
310 572 ▶ next unless $esmtpreply == $f->[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $esmtpreply == $f->[0] 428 144 572
311 144 ▶ next unless index($issuedcode, $f->[1]) > -1;
Branch: 1 branch
BranchTrueFalseTotal
unless index($issuedcode, $f->[1]) != -1 132 12 144
312 12 $reasontext = $e;
313 12 last REASON;
314 }
315 }
316 17 return $reasontext;
317 }
318  
319 5 1;
320 __END__
« Sisimai/Mail/Mbox.pm ↑ Summary Sisimai/Reason/UserUnknown.pm »