File Coverage

lib/Sisimai/Rhost/IUA.pm
Criterion Covered Total %
statement 16 16 100.0
branch 6 6 100.0
condition 4 4 100.0
subroutine 4 4 100.0
pod 0 1 0.0
total 30 31 96.7


line stmt bran cond sub pod time code
1             package Sisimai::Rhost::IUA;
2 6     6   2254 use v5.26;
  6         27  
3 6     6   57 use strict;
  6         14  
  6         207  
4 6     6   32 use warnings;
  6         13  
  6         1796  
5              
6             sub find {
7             # Detect bounce reason from https://www.i.ua/
8             # @param [Sisimai::Fact] argvs Decoded email object
9             # @return [String] The bounce reason at https://www.i.ua/
10             # @since v4.25.0
11 16     16 0 1126 my $class = shift;
12 16 100 100     63 my $argvs = shift // return ""; return "" unless $argvs->{'diagnosticcode'};
  15         77  
13              
14 14         75 state $errorcodes = {
15             # https://mail.i.ua/err/$(CODE)
16             '1' => 'norelaying', # The use of SMTP as mail gate is forbidden.
17             '2' => 'userunknown', # User is not found.
18             '3' => 'suspend', # Mailbox was not used for more than 3 months
19             '4' => 'mailboxfull', # Mailbox is full.
20             '5' => 'ratelimited', # Letter sending limit is exceeded.
21             '6' => 'norelaying', # Use SMTP of your provider to send mail.
22             '7' => 'blocked', # Wrong value if command HELO/EHLO parameter.
23             '8' => 'rejected', # Couldn't check sender address.
24             '9' => 'blocked', # IP-address of the sender is blacklisted.
25             '10' => 'filtered', # Not in the list Mail address management.
26             };
27 14         52 my $issuedcode = lc $argvs->{'diagnosticcode'};
28 14 100       104 my $codenumber = index($issuedcode, '.i.ua/err/') > 0 ? substr($issuedcode, index($issuedcode, '/err/') + 5, 2) : 0;
29 14 100       80 $codenumber = substr($codenumber, 0, 1) if index($codenumber, '/') == 1;
30 14   100     105 return $errorcodes->{ $codenumber } || '';
31             }
32              
33             1;
34             __END__