Sisimai/Lhost/EinsUndEins.pm

filter: Statementstmt 96.5% 56 / 58 Branchbran 78.5% 22 / 28 Conditioncond 71.4% 10 / 14 MC/DCmcdc 42.8% 3 / 7 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 86.0% 99 / 115 CC 23 SCAR 30.1
CC
23
Cov
88%
inquire
24.4
BEGIN
1.0
BEGIN
1.0
CRAP 20.2
« Sisimai/Message.pm ↑ Summary Sisimai/SMTP/Transcript.pm »
1 package Sisimai::Lhost::EinsUndEins;
2 38 ▶use parent 'Sisimai::Lhost';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 38 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 38 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 38 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # X-UI-Out-Filterresults: unknown:0;
8 1 ▶sub description { '1&1: https://www.1und1.de/' }
Subroutine description: called CC=1 SCAR=0.0
Pod documented
9 894 ▶sub inquire {
Subroutine inquire: called CC=23 SCAR=31.9
Pod documented
10 # Detect an error from 1&1
11 # @param [Hash] mhead Message headers of a bounce email
12 # @param [String] mbody Message body of a bounce email
13 # @return [Hash] Bounce data list and message/rfc822 part
14 # @return [undef] failed to decodes or the arguments are missing
15 # @since v4.1.9
16 894 my $class = shift;
17 894 ▶ my $mhead = shift // return undef;
Condition100%2/2
shift() // (return undef)
l!l
8931
MC/DC100%1/1
shift() // (return undef)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
18 893 ▶ my $mbody = shift // return undef;
Condition100%2/2
shift() // (return undef)
l!l
8921
MC/DC100%1/1
shift() // (return undef)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
19  
20 892 ▶ return undef unless index($mhead->{'from'}, '"Mail Delivery System"') == 0;
Branch: 1 branch
BranchTrueFalseTotal
unless index($mhead->{"from"}, "\"Mail Delivery System\"") == 0 860 32 892
21 32 ▶ return undef unless $mhead->{'subject'} eq 'Mail delivery failed: returning message to sender';
Branch: 1 branch
BranchTrueFalseTotal
unless $mhead->{"subject"} eq "Mail delivery failed: returning message to sender" 15 17 32
22  
23 17 require Sisimai::Eb;
24 17 state $indicators = __PACKAGE__->INDICATORS;
25 17 state $boundaries = ['--- The header of the original message is following. ---'];
26 17 state $startingof = {
27 'message' => ['This message was created automatically by mail delivery software'],
28 'error' => ['For the following reason:'],
29 };
30  
31 17 ▶ my $emailparts = Sisimai::RFC5322->part($mbody, $boundaries) // return undef; return undef unless $emailparts->[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $emailparts->[0] 0 17 17
Condition50%1/2
"Sisimai::RFC5322"->part($mbody, $boundaries) // (return undef)
l!l
170
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
32 17 my $dscontents = [__PACKAGE__->DELIVERYSTATUS]; my $v = undef;
33 17 my $readcursor = 0; # (Integer) Points the current cursor position
34 17 my $recipients = 0; # (Integer) The number of 'Final-Recipient' header
35  
36 17 for my $e ( split("\n", $emailparts->[0]) ) {
37 # Read error messages and delivery status lines from the head of the email to the previous
38 # line of the beginning of the original message.
39 166 ▶ unless( $readcursor ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($readcursor) 17 149 166
40 # Beginning of the bounce message or message/delivery-status part
41 17 ▶ $readcursor |= $indicators->{'deliverystatus'} if index($e, $startingof->{'message'}->[0]) == 0;
Branch: 1 branch
BranchTrueFalseTotal
if index($e, $startingof->{"message"}[0]) == 0 17 0 17
42 17 next;
43 }
44 149 ▶ next if ($readcursor & $indicators->{'deliverystatus'}) == 0 || $e eq "";
Branch: 1 branch
BranchTrueFalseTotal
if ($readcursor & $indicators->{"deliverystatus"}) == 0 or $e eq "" 52 97 149
Condition66%2/3
($readcursor & $indicators->{"deliverystatus"}) == 0 or $e eq ""
l!l&&r!l&&!r
05297
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
45  
46 # The following address failed:
47 #
48 # general@example.eu
49 #
50 # For the following reason:
51 #
52 # Mail size limit exceeded. For explanation visit
53 # http://postmaster.1and1.com/en/error-messages?ip=%1s
54 97 $v = $dscontents->[-1];
55  
56 97 ▶ if( $e =~ /\A\s*([^ ]+[@][^ ]+?)[:]?\z/ ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($e =~ /\A\s*([^ ]+[\@][^ ]+?)[:]?\z/u) { } 17 80 97
elsif (index($e, $startingof->{'error'}[0]) == 0) { } 6 74 80
57 # general@example.eu OR
58 # the line begin with 4 space characters, end with ":" like " neko@example.eu:"
59 17 ▶ if( $v->{'recipient'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v->{"recipient"}) 0 17 17
60 # There are multiple recipient addresses in the message body.
61 0 push @$dscontents, __PACKAGE__->DELIVERYSTATUS;
62 0 $v = $dscontents->[-1];
63 }
64 17 $v->{'recipient'} = Sisimai::Address->s3s4($e);
65 17 $recipients++;
66  
67 } elsif( index($e, $startingof->{'error'}->[0]) == 0 ) {
68 # For the following reason:
69 6 $v->{'diagnosis'} = $e;
70  
71 } else {
72 74 ▶ if( length $v->{'diagnosis'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $v->{'diagnosis'}) { } 12 62 74
73 # Get error message and append the error message strings
74 12 $v->{'diagnosis'} .= ' '.$e;
75  
76 } else {
77 # OR the following format:
78 # neko@example.fr:
79 # SMTP error from remote server for TEXT command, host: ...
80 62 $v->{'alterrors'} .= ' '.$e;
81 }
82 }
83 }
84 17 ▶ return undef unless $recipients;
Branch: 1 branch
BranchTrueFalseTotal
unless $recipients 0 17 17
85  
86 17 require Sisimai::SMTP::Command;
87 17 for my $e ( @$dscontents ) {
88 17 ▶ $e->{'diagnosis'} ||= $e->{'alterrors'} || '';
Condition60%3/5
$e->{"diagnosis"} ||= $e->{"alterrors"} || ""
l!l&&r!l&&!r
6110
$e->{'alterrors'} || ''
l!l
110
MC/DC0%0/2
$e->{"diagnosis"} ||= $e->{"alterrors"} || ""
$e->{"diagnosis"} $e->{'alterrors'}
Truth table66%2/3
A ||= B
A= $e->{"diagnosis"}B= $e->{'alterrors'}
ABresult
1X1
011
000
89 17 $e->{'command'} = Sisimai::SMTP::Command->find($e->{'diagnosis'});
90  
91 17 ▶ if( Sisimai::String->aligned(\$e->{'diagnosis'}, ['host: ', ' reason:']) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ('Sisimai::String'->aligned(\$e->{'diagnosis'}, ['host: ', ' reason:'])) { } 11 6 17
92 # SMTP error from remote server for TEXT command,
93 # host: smtp-in.orange.fr (193.252.22.65)
94 # reason: 550 5.2.0 Mail rejete. Mail rejected. ofr_506 [506]
95 11 my $p1 = index($e->{'diagnosis'}, 'host: ');
96 11 my $p2 = index($e->{'diagnosis'}, ' reason:');
97  
98 11 $e->{'rhost'} = substr($e->{'diagnosis'}, $p1 + 6, $p2 - $p1 - 6);
99 11 ▶ $e->{'command'} = $Sisimai::Eb::CeDATA if index($e->{'diagnosis'}, 'for TEXT command') > -1;
Branch: 1 branch
BranchTrueFalseTotal
if index($e->{"diagnosis"}, "for TEXT command") != -1 11 0 11
100 11 ▶ $e->{'spec'} = 'SMTP' if index($e->{'diagnosis'}, 'SMTP error') > -1;
Branch: 1 branch
BranchTrueFalseTotal
if index($e->{"diagnosis"}, "SMTP error") != -1 11 0 11
101 11 $e->{'status'} = Sisimai::SMTP::Status->find($e->{'diagnosis'});
102 } else {
103 # For the following reason:
104 6 substr($e->{'diagnosis'}, 0, length $startingof->{'error'}->[0], '');
105 }
106 }
107 17 return {"ds" => $dscontents, "rfc822" => $emailparts->[1]};
108 }
109  
110 38 1;
111 __END__
« Sisimai/Message.pm ↑ Summary Sisimai/SMTP/Transcript.pm »