Sisimai/Lhost/DeutscheTelekom.pm

filter: Statementstmt 96.0% 49 / 51 Branchbran 81.8% 18 / 22 Conditioncond 63.1% 12 / 19 MC/DCmcdc 36.3% 4 / 11 Subroutinesub 100% 6 / 6 Podpod 100% 2 / 2 totaltotal 81.9% 91 / 111 CC 20 SCAR 28.7
CC
20
Cov
86%
inquire
21.8
BEGIN
1.0
BEGIN
1.0
CRAP 17.6
« Sisimai/SMTP/Command.pm ↑ Summary Sisimai/Lhost/GoogleWorkspace.pm »
1 package Sisimai::Lhost::DeutscheTelekom;
2 42 ▶use parent 'Sisimai::Lhost';
Subroutine BEGIN: called CC=1 SCAR=0.0
3 42 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 42 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 42 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶sub description { 'Deutsche Telekom: https://www.telekom.com/' }
Subroutine description: called CC=1 SCAR=0.0
Pod documented
8 929 ▶sub inquire {
Subroutine inquire: called CC=20 SCAR=30.8
Pod documented
9 # Detect an error from T-Online, Deutsche Telekom.
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 v5.7.0
15 929 my $class = shift;
16 929 ▶ my $mhead = shift // return undef;
Condition100%2/2
shift() // (return undef)
l!l
9281
MC/DC100%1/1
shift() // (return undef)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
17 928 ▶ my $mbody = shift // return undef;
Condition100%2/2
shift() // (return undef)
l!l
9271
MC/DC100%1/1
shift() // (return undef)
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
18  
19 # - T-Online: https://www.t-online.de/, @t-online.de, @magenta.de
20 # - DeutscheTelekom: https://www.telekom.com/
21 # - Based on the bounce format of Smail 3, the original design model for Exim
22 # - Tailored for Deutsche Telekom's internal Smail 3 fork with custom banners
23 # - Module name follows the infrastructure owner for cross-language compatibility
24 # - Smail 3: http://www.weird.com/~woods/projects/smail.html
25  
26 # smail-3.2.0.108/src/
27 # notify.c:1052|(void) fprintf(f, "Subject: mail failed, %s\nReference: <%s@%s>\n\n",
28 # notify.c:1053| subject_to, message_id, primary_name);
29 #
30 # T-Online specific headers
31 # Received: from mailin42.aul.t-online.de (mailin42.aul.t-online.de [192.51.100.1])
32 # by mailout11.t-online.de (Postfix) with SMTP id 05E5A1CAC0
33 # From: Mail Delivery System <Mailer-Daemon@t-online.de>
34 # X-TOI-MSGID: c9412855-531f-497b-b007-5ffc033877a0
35 927 ▶ state $bannerDTAG = __PACKAGE__->BannerDTAG; return undef unless grep { index($$mbody, $_) > -1 } $bannerDTAG->@*;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {index($$mbody, $_) != -1;} @$bannerDTAG 912 15 927
36 15 state $indicators = __PACKAGE__->INDICATORS;
37 15 state $startingof = { 'message' => [$bannerDTAG->[1]] };
38  
39 15 my $emailparts = Sisimai::RFC5322->part($mbody, [$bannerDTAG->[3], $bannerDTAG->[2]]);
40 15 ▶ return undef if ref($emailparts) eq '' || $emailparts->[0] eq '';
Branch: 1 branch
BranchTrueFalseTotal
if ref $emailparts eq "" or $emailparts->[0] eq "" 0 15 15
Condition33%1/3
ref $emailparts eq "" or $emailparts->[0] eq ""
l!l&&r!l&&!r
0015
MC/DC0%0/2
ref $emailparts eq "" or $emailparts->[0] eq ""
ref $emailparts eq "" $emailparts->[0] eq ""
Truth table33%1/3
A or B
A= ref $emailparts eq ""B= $emailparts->[0] eq ""
ABresult
1X1
011
000
41  
42 15 my $dscontents = [__PACKAGE__->DELIVERYSTATUS]; my $v = undef;
43 15 my $messagelog = '';
44 15 my $readcursor = 0; # (Integer) Points the current cursor position
45 15 my $recipients = 0; # (Integer) The number of 'Final-Recipient' header
46  
47 15 for my $e ( split("\n", $emailparts->[0]) ) {
48 # Read error messages and delivery status lines from the head of the email to the previous
49 # line of the beginning of the original message.
50 60 ▶ unless( $readcursor ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($readcursor) 25 35 60
51 # Beginning of the bounce message or message/delivery-status part
52 25 ▶ if( index($e, $startingof->{'message'}->[0]) == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (index($e, $startingof->{'message'}[0]) == 0) { } 15 10 25
53 # |------------------------- Failed addresses follow: ---------------------|
54 15 $readcursor |= $indicators->{'deliverystatus'};
55  
56 } else {
57 # |------------------------- Message log follows: -------------------------|
58 # The line above may appears only in Smail 3.
59 #
60 # smail-3.2.0.108/src/
61 # models.c:787| if (deliver == NULL && defer == NULL) {
62 # models.c:788| write_log(WRITE_LOG_MLOG, "no valid recipients were found for this message");
63 # models.c:789| return_to_sender = TRUE;
64 # models.c:879| }
65 10 ▶ $messagelog .= " ".$e if $e ne "" && index($e, $bannerDTAG->[0]) < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $e ne "" and index($e, $bannerDTAG->[0]) == -1 5 5 10
Condition66%2/3
$e ne "" and index($e, $bannerDTAG->[0]) == -1
!ll&&!rl&&r
055
MC/DC50%1/2
$e ne "" and index($e, $bannerDTAG->[0]) == -1
$e ne "" index($e, $bannerDTAG->[0]) == -1
Truth table66%2/3
A and B
A= $e ne ""B= index($e, $bannerDTAG->[0]) == -1
ABresult
0X0
100
111
66 }
67 25 next;
68 }
69 35 ▶ next if ($readcursor & $indicators->{'deliverystatus'}) == 0 || $e eq "";
Branch: 1 branch
BranchTrueFalseTotal
if ($readcursor & $indicators->{"deliverystatus"}) == 0 or $e eq "" 0 35 35
Condition33%1/3
($readcursor & $indicators->{"deliverystatus"}) == 0 or $e eq ""
l!l&&r!l&&!r
0035
MC/DC0%0/2
($readcursor & $indicators->{"deliverystatus"}) == 0 or $e eq ""
($readcursor & $indicators->{"deliverystatus"}) == 0 $e eq ""
Truth table33%1/3
A or B
A= ($readcursor & $indicators->{"deliverystatus"}) == 0B= $e eq ""
ABresult
1X1
011
000
70  
71 # |------------------------- Failed addresses follow: ---------------------|
72 # <example@t-online.de>
73 # 552 5.2.2 <example@t-online.de> Quota exceeded (mailbox for user is full)
74 #
75 # |------------------------- Message header follows: ----------------------|
76 # Received: from mail.fragdenstaat.de ([94.130.55.89]) by mailin41.mgt.mul.t-online.de.example.com
77 # with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted)
78 # ...
79 35 $v = $dscontents->[-1];
80  
81 35 ▶ if( index($e, ' <') == 0 && substr($e, -1, 1) eq '>' && index($e, ' ', 1) < 0 ) {
Branch: 2 branches
BranchTrueFalseTotal
if (index($e, ' <') == 0 and substr($e, -1, 1) eq '>' and index($e, ' ', 1) == -1) { } 15 20 35
elsif ('Sisimai::String'->aligned(\$e, [' ', '@', '.', ' ... '])) { } 5 15 20
Condition66%4/6
index($e, " <") == 0 and substr($e, -1, 1) eq ">" and index($e, " ", 1) == -1
!ll&&!rl&&r
20015
index($e, " <") == 0 and substr($e, -1, 1) eq ">"
!ll&&!rl&&r
20015
MC/DC33%1/3
index($e, " <") == 0 and substr($e, -1, 1) eq ">" and index($e, " ", 1) == -1
index($e, " <") == 0 substr($e, -1, 1) eq ">" index($e, " ", 1) == -1
Truth table50%2/4
A and B and C
A= index($e, " <") == 0B= substr($e, -1, 1) eq ">"C= index($e, " ", 1) == -1
ABCresult
0XX0
10X0
1100
1111
82 # Deutsche Telekom: The recipient address is enclosed in angle brackets.
83 # |------------------------- Failed addresses follow: ---------------------|
84 15 ▶ if( $v->{'recipient'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v->{"recipient"}) 5 10 15
85 # There are multiple recipient addresses in the message body.
86 5 push @$dscontents, __PACKAGE__->DELIVERYSTATUS;
87 5 $v = $dscontents->[-1];
88 }
89 15 $v->{'recipient'} = substr($e, 2, index($e, '>'));
90 15 $recipients++;
91  
92 } elsif( Sisimai::String->aligned(\$e, [' ', '@', '.', ' ... ']) ) {
93 # Smail 3:
94 # - The recipient address is not enclosed in angle brackets.
95 # - Error message begins with " ... failed:"
96 # smail-3.2.0.108/src/
97 # notify.c:845| if (cur->error) {
98 # notify.c:846| (void) fprintf(f, " %s ... failed: %s\n",
99 # notify.c:847| cur->in_addr ? cur->in_addr : "(unknown)",
100 # notify.c:848| cur->error->message);
101 # notify.c:849| }
102 # |------------------------- Failed addresses follow: ---------------------|
103 # kijitora@neko.nyaan.example.com ... unknown host
104 5 ▶ if( $v->{'recipient'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v->{"recipient"}) 0 5 5
105 # There are multiple recipient addresses in the message body.
106 0 push @$dscontents, __PACKAGE__->DELIVERYSTATUS;
107 0 $v = $dscontents->[-1];
108 }
109 5 $v->{'recipient'} = substr($e, 1, index($e, ' ', 1) - 1);
110 5 $v->{'diagnosis'} = $messagelog.' '.$e;
111 5 $recipients++;
112  
113 } else {
114 # 552 5.2.2 <example@t-online.de> Quota exceeded (mailbox for user is full)
115 15 $v->{'diagnosis'} = $e;
116 }
117 }
118 15 ▶ return undef unless $recipients;
Branch: 1 branch
BranchTrueFalseTotal
unless $recipients 0 15 15
119 15 return {"ds" => $dscontents, "rfc822" => $emailparts->[1]};
120 }
121  
122 42 1;
123 __END__
« Sisimai/SMTP/Command.pm ↑ Summary Sisimai/Lhost/GoogleWorkspace.pm »