Sisimai/Lhost/Zoho.pm

filter: Statementstmt 90.9% 50 / 55 Branchbran 75.0% 18 / 24 Conditioncond 66.6% 6 / 9 MC/DCmcdc 40.0% 2 / 5 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 83.1% 84 / 101 CC 18 SCAR 27.7
CC
18
Cov
84%
inquire
20.1
BEGIN
1.0
BEGIN
1.0
CRAP 16.0
« Sisimai/Lhost/MailFoundry.pm ↑ Summary Sisimai/Lhost/GoogleGroups.pm »
1 package Sisimai::Lhost::Zoho;
2 40 ▶use parent 'Sisimai::Lhost';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 40 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 40 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 40 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶sub description { 'Zoho Mail: https://www.zoho.com/mail/' }
Subroutine description: called CC=1 SCAR=0.0
Pod documented
8 925 ▶sub inquire {
Subroutine inquire: called CC=18 SCAR=30.0
Pod documented
9 # Detect an error from Zoho Mail
10 # @param [Hash] mhead Message headers of a bounce email
11 # @param [String] mbody Message body of a bounce email
12 # @return [Hash] Bounce data list and message/rfc822 part
13 # @return [undef] failed to decode or the arguments are missing
14 # @since v4.1.7
15 925 my $class = shift;
16 925 ▶ my $mhead = shift // return undef; return undef unless $mhead->{'x-zohomail'};
Branch: 1 branch
BranchTrueFalseTotal
unless $mhead->{"x-zohomail"} 898 26 924
Condition100%2/2
shift() // (return undef)
l!l
9241
MC/DC100%1/1
shift() // (return undef)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
17 26 ▶ my $mbody = shift // return undef;
Condition50%1/2
shift() // (return undef)
l!l
260
MC/DC0%0/1
shift() // (return undef)
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
18  
19 # X-ZohoMail: Si CHF_MF_NL SS_10 UW48 UB48 FMWL UW48 UB48 SGR3_1_09124_42
20 # X-Zoho-Virus-Status: 2
21 # X-Mailer: Zoho Mail
22 26 state $indicators = __PACKAGE__->INDICATORS;
23 26 state $boundaries = ['Received: from mail.zoho.com by mx.zohomail.com'];
24 26 state $startingof = {'message' => ['This message was created automatically by mail delivery']};
25  
26 26 ▶ my $emailparts = Sisimai::RFC5322->part($mbody, $boundaries) // return undef; return undef unless $emailparts->[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $emailparts->[0] 0 26 26
Condition50%1/2
"Sisimai::RFC5322"->part($mbody, $boundaries) // (return undef)
l!l
260
MC/DC0%0/1
"Sisimai::RFC5322"->part($mbody, $boundaries) // (return undef)
"Sisimai::RFC5322"->part($mbody, $boundaries)
Truth table50%1/2
A
A= "Sisimai::RFC5322"->part($mbody, $boundaries)
Aresult
11
00
27 26 my $dscontents = [__PACKAGE__->DELIVERYSTATUS]; my $v = undef;
28 26 my $readcursor = 0; # (Integer) Points the current cursor position
29 26 my $recipients = 0; # (Integer) The number of 'Final-Recipient' header
30 26 my $qprintable = 0;
31  
32 26 for my $e ( split("\n", $emailparts->[0]) ) {
33 # Read error messages and delivery status lines from the head of the email to the previous
34 # line of the beginning of the original message.
35 219 ▶ unless( $readcursor ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($readcursor) 26 193 219
36 # Beginning of the bounce message or message/delivery-status part
37 26 ▶ $readcursor |= $indicators->{'deliverystatus'} if index($e, $startingof->{'message'}->[0]) == 0;
Branch: 1 branch
BranchTrueFalseTotal
if index($e, $startingof->{"message"}[0]) == 0 26 0 26
38 26 next;
39 }
40 193 ▶ next if ($readcursor & $indicators->{'deliverystatus'}) == 0 || $e eq "";
Branch: 1 branch
BranchTrueFalseTotal
if ($readcursor & $indicators->{"deliverystatus"}) == 0 or $e eq "" 61 132 193
Condition66%2/3
($readcursor & $indicators->{"deliverystatus"}) == 0 or $e eq ""
l!l&&r!l&&!r
061132
MC/DC50%1/2
($readcursor & $indicators->{"deliverystatus"}) == 0 or $e eq ""
($readcursor & $indicators->{"deliverystatus"}) == 0 $e eq ""
Truth table66%2/3
A or B
A= ($readcursor & $indicators->{"deliverystatus"}) == 0B= $e eq ""
ABresult
1X1
011
000
41  
42 # This message was created automatically by mail delivery software.
43 # A message that you sent could not be delivered to one or more of its recip=
44 # ients. This is a permanent error.=20
45 #
46 # kijitora@example.co.jp Invalid Address, ERROR_CODE :550, ERROR_CODE :5.1.=
47 # 1 <kijitora@example.co.jp>... User Unknown
48  
49 # This message was created automatically by mail delivery software.
50 # A message that you sent could not be delivered to one or more of its recipients. This is a permanent error.
51 #
52 # shironeko@example.org Invalid Address, ERROR_CODE :550, ERROR_CODE :Requested action not taken: mailbox unavailable
53 132 $v = $dscontents->[-1];
54  
55 132 ▶ if( Sisimai::String->aligned(\$e, ['@', ' ', 'ERROR_CODE :']) ) {
Branch: 2 branches
BranchTrueFalseTotal
if ('Sisimai::String'->aligned(\$e, ['@', ' ', 'ERROR_CODE :'])) { } 26 106 132
elsif (index($e, '[Status: ') == 0) { } 5 101 106
56 # kijitora@example.co.jp Invalid Address, ERROR_CODE :550, ERROR_CODE :5.1.=
57 26 ▶ if( $v->{'recipient'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v->{"recipient"}) 5 21 26
58 # There are multiple recipient addresses in the message body.
59 5 push @$dscontents, __PACKAGE__->DELIVERYSTATUS;
60 5 $v = $dscontents->[-1];
61 }
62 26 $v->{'recipient'} = substr($e, 0, index($e, ' '));
63 26 $v->{'diagnosis'} = substr($e, index($e, ' ') + 1,);
64  
65 26 ▶ if( substr($v->{'diagnosis'}, -1, 1) eq '=' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($v->{"diagnosis"}, -1, 1) eq "=") 0 26 26
66 # Quoted printable
67 0 substr($v->{'diagnosis'}, -1, 1, '');
68 0 $qprintable = 1;
69 }
70 26 $recipients++;
71  
72 } elsif( index($e, '[Status: ') == 0 ) {
73 # Expired
74 # [Status: Error, Address: <kijitora@6kaku.example.co.jp>, ResponseCode 421, , Host not reachable.]
75 5 ▶ if( $v->{'recipient'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v->{"recipient"}) 0 5 5
76 # There are multiple recipient addresses in the message body.
77 0 push @$dscontents, __PACKAGE__->DELIVERYSTATUS;
78 0 $v = $dscontents->[-1];
79 }
80 5 my $p1 = index($e, '<');
81 5 my $p2 = index($e, '>', $p1 + 2);
82 5 $v->{'recipient'} = Sisimai::Address->s3s4(substr($e, $p1, $p2 - $p1));
83 5 $v->{'diagnosis'} = $e;
84 5 $recipients++;
85  
86 } else {
87 # Continued line
88 101 ▶ next unless $qprintable;
Branch: 1 branch
BranchTrueFalseTotal
unless $qprintable 101 0 101
89 0 $v->{'diagnosis'} .= $e;
90 }
91 }
92 26 ▶ return undef unless $recipients;
Branch: 1 branch
BranchTrueFalseTotal
unless $recipients 0 26 26
93 26 return {"ds" => $dscontents, "rfc822" => $emailparts->[1]};
94 }
95  
96 40 1;
97 __END__
« Sisimai/Lhost/MailFoundry.pm ↑ Summary Sisimai/Lhost/GoogleGroups.pm »