| 1 | package Sisimai::Lhost::Sendmail; | ||||||||||||||||||||||||||||||||||||||
| 2 | 55 | ▶ | use parent 'Sisimai::Lhost'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 3 | 55 | ▶ | use v5.26; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 4 | 55 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 5 | 55 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | sub description { 'Sendmail Open Source: https://sendmail.org/' } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
description: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 8 | 1509 | ▶ | sub inquire { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
inquire: called CC=65 SCAR=42.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 9 | # Decode bounce messages from Sendmail Open Source | ||||||||||||||||||||||||||||||||||||||
| 10 | # @param [Hash] mhead Message headers of the bounce email | ||||||||||||||||||||||||||||||||||||||
| 11 | # @param [String] mbody Message body of the bounce email | ||||||||||||||||||||||||||||||||||||||
| 12 | # @return [Hash] The list of decoded bounces and a message/rfc822 part block | ||||||||||||||||||||||||||||||||||||||
| 13 | # @return [undef] failed to decode or the arguments are missing | ||||||||||||||||||||||||||||||||||||||
| 14 | # @see https://www.proofpoint.com/us/products/email-protection/open-source-email-solution | ||||||||||||||||||||||||||||||||||||||
| 15 | # @since v4.0.0 | ||||||||||||||||||||||||||||||||||||||
| 16 | 1509 | my $class = shift; | |||||||||||||||||||||||||||||||||||||
| 17 | 1509 | ▶ | my $mhead = shift // return undef; | ||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() // (return undef)
MC/DC100%1/1
shift() // (return undef)
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||
| 18 | 1508 | ▶ | my $mbody = shift // return undef; | ||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() // (return undef)
MC/DC100%1/1
shift() // (return undef)
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||
| 20 | 1507 | ▶ | return undef if $mhead->{'x-aol-ip'}; # X-AOL-IP is a header defined in AOL | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 21 | 1470 | ▶ | my $match = 0; $match ||= 1 if index($mhead->{'subject'}, 'see transcript for details') > -1; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$match ||= 1
MC/DC0%0/1
$match ||= 1
$match
Truth table50%1/2
A
A= $match
| |||||||||||||||||||||||||||||||||||||||
| 22 | 1470 | ▶ | $match ||= 1 if index($mhead->{'subject'}, 'Warning: ') == 0; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$match ||= 1
MC/DC0%0/1
$match ||= 1
$match
Truth table50%1/2
A
A= $match
| |||||||||||||||||||||||||||||||||||||||
| 23 | 1470 | ▶ | return undef unless $match > 0; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||
| 25 | 544 | require Sisimai::RFC1123; | |||||||||||||||||||||||||||||||||||||
| 26 | 544 | require Sisimai::SMTP::Reply; | |||||||||||||||||||||||||||||||||||||
| 27 | 544 | require Sisimai::SMTP::Status; | |||||||||||||||||||||||||||||||||||||
| 28 | 544 | require Sisimai::SMTP::Command; | |||||||||||||||||||||||||||||||||||||
| 29 | 544 | state $indicators = __PACKAGE__->INDICATORS; | |||||||||||||||||||||||||||||||||||||
| 30 | 544 | state $boundaries = ['Content-Type: message/rfc822', 'Content-Type: text/rfc822-headers']; | |||||||||||||||||||||||||||||||||||||
| 31 | 544 | state $startingof = { | |||||||||||||||||||||||||||||||||||||
| 32 | # savemail.c:1040|if (printheader && !putline(" ----- Transcript of session follows -----\n", | ||||||||||||||||||||||||||||||||||||||
| 33 | # savemail.c:1041| mci)) | ||||||||||||||||||||||||||||||||||||||
| 34 | # savemail.c:1042| goto writeerr; | ||||||||||||||||||||||||||||||||||||||
| 35 | # savemail.c:1360|if (!putline( | ||||||||||||||||||||||||||||||||||||||
| 36 | # savemail.c:1361| sendbody | ||||||||||||||||||||||||||||||||||||||
| 37 | # savemail.c:1362| ? " ----- Original message follows -----\n" | ||||||||||||||||||||||||||||||||||||||
| 38 | # savemail.c:1363| : " ----- Message header follows -----\n", | ||||||||||||||||||||||||||||||||||||||
| 39 | 'message' => [' ----- Transcript of session follows -----'], | ||||||||||||||||||||||||||||||||||||||
| 40 | 'error' => ['... while talking to '], | ||||||||||||||||||||||||||||||||||||||
| 41 | }; | ||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||
| 43 | 544 | ▶ | my $emailparts = Sisimai::RFC5322->part($mbody, $boundaries) // return undef; return undef unless $emailparts->[0]; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
"Sisimai::RFC5322"->part($mbody, $boundaries) // (return undef)
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)
| |||||||||||||||||||||||||||||||||||||||
| 44 | 544 | my $fieldtable = Sisimai::RFC1894->FIELDTABLE; | |||||||||||||||||||||||||||||||||||||
| 45 | 544 | my $dscontents = [__PACKAGE__->DELIVERYSTATUS]; my $v = undef; | |||||||||||||||||||||||||||||||||||||
| 46 | 544 | my $permessage = {}; # (Hash) Store values of each Per-Message field | |||||||||||||||||||||||||||||||||||||
| 47 | 544 | my $readcursor = 0; # (Integer) Points the current cursor position | |||||||||||||||||||||||||||||||||||||
| 48 | 544 | my $recipients = 0; # (Integer) The number of 'Final-Recipient' header | |||||||||||||||||||||||||||||||||||||
| 49 | 544 | my $thecommand = ''; # (String) SMTP Command name begin with the string '>>>' | |||||||||||||||||||||||||||||||||||||
| 50 | 544 | my $esmtpreply = []; # (Array) Reply from remote server on SMTP session | |||||||||||||||||||||||||||||||||||||
| 51 | 544 | my $sessionerr = 0; # (Integer) Flag, 1 if it is SMTP session error | |||||||||||||||||||||||||||||||||||||
| 52 | 544 | my $anotherset = {}; # (Hash) Another error information | |||||||||||||||||||||||||||||||||||||
| 53 | 544 | my $p = ''; | |||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||
| 55 | 544 | for my $e ( split("\n", $emailparts->[0]) ) { | |||||||||||||||||||||||||||||||||||||
| 56 | # Read error messages and delivery status lines from the head of the email to the previous | ||||||||||||||||||||||||||||||||||||||
| 57 | # line of the beginning of the original message. | ||||||||||||||||||||||||||||||||||||||
| 58 | 15385 | ▶ | unless( $readcursor ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 59 | # Beginning of the bounce message or the message/delivery-status part | ||||||||||||||||||||||||||||||||||||||
| 60 | 6361 | ▶ | $readcursor |= $indicators->{'deliverystatus'} if index($e, $startingof->{'message'}->[0]) == 0; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 61 | 6361 | next; | |||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||
| 63 | 9024 | ▶ | next if ($readcursor & $indicators->{'deliverystatus'}) == 0 || $e eq ""; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
($readcursor & $indicators->{"deliverystatus"}) == 0 or $e eq ""
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 ""
| |||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||
| 65 | 7933 | ▶ | if( my $f = Sisimai::RFC1894->match($e) ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 66 | # $e matched with any field defined in RFC3464 | ||||||||||||||||||||||||||||||||||||||
| 67 | 4635 | ▶ | next unless my $o = Sisimai::RFC1894->field($e); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 68 | 4635 | $v = $dscontents->[-1]; | |||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||
| 70 | 4635 | ▶ | if( $o->[3] eq 'addr' ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 71 | # Final-Recipient: rfc822; kijitora@example.jp | ||||||||||||||||||||||||||||||||||||||
| 72 | # X-Actual-Recipient: rfc822; kijitora@example.co.jp | ||||||||||||||||||||||||||||||||||||||
| 73 | 600 | ▶ | if( $o->[0] eq 'final-recipient' ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 74 | # Final-Recipient: rfc822; kijitora@example.jp | ||||||||||||||||||||||||||||||||||||||
| 75 | 537 | ▶ | if( $v->{'recipient'} ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 76 | # There are multiple recipient addresses in the message body. | ||||||||||||||||||||||||||||||||||||||
| 77 | 10 | push @$dscontents, __PACKAGE__->DELIVERYSTATUS; | |||||||||||||||||||||||||||||||||||||
| 78 | 10 | $v = $dscontents->[-1]; | |||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||
| 80 | 537 | $v->{'recipient'} = $o->[2]; | |||||||||||||||||||||||||||||||||||||
| 81 | 537 | $recipients++; | |||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||
| 83 | } else { | ||||||||||||||||||||||||||||||||||||||
| 84 | # X-Actual-Recipient: rfc822; kijitora@example.co.jp | ||||||||||||||||||||||||||||||||||||||
| 85 | 63 | $v->{'alias'} = $o->[2]; | |||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||
| 87 | } elsif( $o->[3] eq 'code' ) { | ||||||||||||||||||||||||||||||||||||||
| 88 | # Diagnostic-Code: SMTP; 550 5.1.1 <userunknown@example.jp>... User Unknown | ||||||||||||||||||||||||||||||||||||||
| 89 | 507 | $v->{'spec'} = $o->[1]; | |||||||||||||||||||||||||||||||||||||
| 90 | 507 | $v->{'diagnosis'} = $o->[2]; | |||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||
| 92 | } else { | ||||||||||||||||||||||||||||||||||||||
| 93 | # Other DSN fields defined in RFC3464 | ||||||||||||||||||||||||||||||||||||||
| 94 | 3528 | ▶ | next unless exists $fieldtable->{ $o->[0] }; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 95 | 3528 | ▶ | next if $o->[3] eq "host" && Sisimai::RFC1123->is_internethost($o->[2]) == 0; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$o->[3] eq "host" and "Sisimai::RFC1123"->is_internethost($o->[2]) == 0
MC/DC100%2/2
$o->[3] eq "host" and "Sisimai::RFC1123"->is_internethost($o->[2]) == 0
$o->[3] eq "host"
"Sisimai::RFC1123"->is_internethost($o->[2]) == 0
Truth table100%3/3
A and B
A= $o->[3] eq "host"B= "Sisimai::RFC1123"->is_internethost($o->[2]) == 0
| |||||||||||||||||||||||||||||||||||||||
| 96 | 3404 | $v->{ $fieldtable->{ $o->[0] } } = $o->[2]; | |||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||
| 98 | 3404 | ▶ | next unless $f == 1; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 99 | 1391 | $permessage->{ $fieldtable->{ $o->[0] } } = $o->[2]; | |||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||
| 101 | } else { | ||||||||||||||||||||||||||||||||||||||
| 102 | # The line does not begin with a DSN field defined in RFC3464 | ||||||||||||||||||||||||||||||||||||||
| 103 | # | ||||||||||||||||||||||||||||||||||||||
| 104 | # ----- Transcript of session follows ----- | ||||||||||||||||||||||||||||||||||||||
| 105 | # ... while talking to mta.example.org.: | ||||||||||||||||||||||||||||||||||||||
| 106 | # >>> DATA | ||||||||||||||||||||||||||||||||||||||
| 107 | # <<< 550 Unknown user recipient@example.jp | ||||||||||||||||||||||||||||||||||||||
| 108 | # 554 5.0.0 Service unavailable | ||||||||||||||||||||||||||||||||||||||
| 109 | 3298 | ▶ | if( substr($e, 0, 1) ne ' ') { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 110 | # Other error messages | ||||||||||||||||||||||||||||||||||||||
| 111 | 3273 | ▶ | if( index($e, '>>> ') == 0 ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 112 | # >>> DATA (Client Command) | ||||||||||||||||||||||||||||||||||||||
| 113 | 515 | ▶ | $thecommand ||= Sisimai::SMTP::Command->find($e); | ||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$thecommand ||= "Sisimai::SMTP::Command"->find($e)
MC/DC0%0/2
$thecommand ||= "Sisimai::SMTP::Command"->find($e)
$thecommand
"Sisimai::SMTP::Command"->find($e)
Truth table66%2/3
A ||= B
A= $thecommandB= "Sisimai::SMTP::Command"->find($e)
| |||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||
| 115 | } elsif( index($e, '<<< ') == 0 ) { | ||||||||||||||||||||||||||||||||||||||
| 116 | # <<< Response from the SMTP server | ||||||||||||||||||||||||||||||||||||||
| 117 | 937 | my $cv = substr($e, 4,); | |||||||||||||||||||||||||||||||||||||
| 118 | 937 | ▶ | push @$esmtpreply, $cv unless grep { $cv eq $_ } @$esmtpreply; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||
| 120 | } else { | ||||||||||||||||||||||||||||||||||||||
| 121 | # Detect an SMTP session error or a connection error | ||||||||||||||||||||||||||||||||||||||
| 122 | 1821 | ▶ | next if $sessionerr; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 123 | 676 | ▶ | if( index($e, $startingof->{'error'}->[0]) == 0 ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 124 | # ----- Transcript of session follows ----- | ||||||||||||||||||||||||||||||||||||||
| 125 | # ... while talking to mta.example.org.: | ||||||||||||||||||||||||||||||||||||||
| 126 | 454 | $sessionerr = 1; | |||||||||||||||||||||||||||||||||||||
| 127 | 454 | next; | |||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||
| 130 | 222 | ▶ | if( index($e, '<') == 0 && Sisimai::String->aligned(\$e, ['@', '>.', ' ']) ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
index($e, "<") == 0 and "Sisimai::String"->aligned(\$e, ["\@", ">.", " "])
MC/DC50%1/2
index($e, "<") == 0 and "Sisimai::String"->aligned(\$e, ["\@", ">.", " "])
index($e, "<") == 0
"Sisimai::String"->aligned(\$e, ["\@", ">.", " "])
Truth table66%2/3
A and B
A= index($e, "<") == 0B= "Sisimai::String"->aligned(\$e, ["\@", ">.", " "])
| |||||||||||||||||||||||||||||||||||||||
| 131 | # <kijitora@example.co.jp>... Deferred: Name server: example.co.jp.: host name lookup failure | ||||||||||||||||||||||||||||||||||||||
| 132 | 10 | $anotherset->{'recipient'} = Sisimai::Address->s3s4(substr($e, 0, index($e, '>'))); | |||||||||||||||||||||||||||||||||||||
| 133 | 10 | $anotherset->{'diagnosis'} = substr($e, index($e, ' ') + 1,); | |||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||
| 135 | } else { | ||||||||||||||||||||||||||||||||||||||
| 136 | # ----- Transcript of session follows ----- | ||||||||||||||||||||||||||||||||||||||
| 137 | # Message could not be delivered for too long | ||||||||||||||||||||||||||||||||||||||
| 138 | # Message will be deleted from queue | ||||||||||||||||||||||||||||||||||||||
| 139 | 212 | ▶ | my $cr = Sisimai::SMTP::Reply->find($e) || ''; | ||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
'Sisimai::SMTP::Reply'->find($e) || ''
MC/DC100%1/1
'Sisimai::SMTP::Reply'->find($e) || ''
'Sisimai::SMTP::Reply'->find($e)
Truth table100%2/2
A
A= 'Sisimai::SMTP::Reply'->find($e)
| |||||||||||||||||||||||||||||||||||||||
| 140 | 212 | ▶ | my $cs = Sisimai::SMTP::Status->find($e) || ''; | ||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
'Sisimai::SMTP::Status'->find($e) || ''
MC/DC100%1/1
'Sisimai::SMTP::Status'->find($e) || ''
'Sisimai::SMTP::Status'->find($e)
Truth table100%2/2
A
A= 'Sisimai::SMTP::Status'->find($e)
| |||||||||||||||||||||||||||||||||||||||
| 141 | 212 | ▶ | if( length($cr.$cs) > 7 ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 142 | # 550 5.1.2 <kijitora@example.org>... Message | ||||||||||||||||||||||||||||||||||||||
| 143 | # | ||||||||||||||||||||||||||||||||||||||
| 144 | # DBI connect('dbname=...') | ||||||||||||||||||||||||||||||||||||||
| 145 | # 554 5.3.0 unknown mailer error 255 | ||||||||||||||||||||||||||||||||||||||
| 146 | 48 | $anotherset->{'status'} = $cs; | |||||||||||||||||||||||||||||||||||||
| 147 | 48 | $anotherset->{'diagnosis'} .= ' '.$e; | |||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||
| 149 | ▶ | } elsif( index($e, 'Message ') == 0 || index($e, 'Warning: ') == 0 ) { | |||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
index($e, "Message ") == 0 or index($e, "Warning: ") == 0
MC/DC100%2/2
index($e, "Message ") == 0 or index($e, "Warning: ") == 0
index($e, "Message ") == 0
index($e, "Warning: ") == 0
Truth table100%3/3
A or B
A= index($e, "Message ") == 0B= index($e, "Warning: ") == 0
| |||||||||||||||||||||||||||||||||||||||
| 150 | # Message could not be delivered for too long | ||||||||||||||||||||||||||||||||||||||
| 151 | # Warning: message still undelivered after 4 hours | ||||||||||||||||||||||||||||||||||||||
| 152 | 45 | $anotherset->{'diagnosis'} .= ' '.$e; | |||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||
| 156 | } else { | ||||||||||||||||||||||||||||||||||||||
| 157 | # Continued line of the value of Diagnostic-Code field | ||||||||||||||||||||||||||||||||||||||
| 158 | 25 | ▶ | next if index($p, 'Diagnostic-Code:') != 0 || index($e, ' ') != 0; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
index($p, "Diagnostic-Code:") != 0 or index($e, " ") != 0
MC/DC50%1/2
index($p, "Diagnostic-Code:") != 0 or index($e, " ") != 0
index($p, "Diagnostic-Code:") != 0
index($e, " ") != 0
Truth table66%2/3
A or B
A= index($p, "Diagnostic-Code:") != 0B= index($e, " ") != 0
| |||||||||||||||||||||||||||||||||||||||
| 159 | 5 | $v->{'diagnosis'} .= ' '.$e; | |||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||
| 162 | } continue { | ||||||||||||||||||||||||||||||||||||||
| 163 | # Save the current line for the next loop | ||||||||||||||||||||||||||||||||||||||
| 164 | 15385 | $p = $e; | |||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||
| 166 | 544 | ▶ | return undef unless $recipients; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||
| 168 | 527 | require Sisimai::Eb; | |||||||||||||||||||||||||||||||||||||
| 169 | 527 | for my $e ( @$dscontents ) { | |||||||||||||||||||||||||||||||||||||
| 170 | # Set default values if each value is empty. | ||||||||||||||||||||||||||||||||||||||
| 171 | 537 | ▶ | $e->{ $_ } ||= $permessage->{ $_ } || '' for keys %$permessage; | ||||||||||||||||||||||||||||||||||||
|
Condition60%3/5
$e->{$_} ||= $permessage->{$_} || ""
$permessage->{$_} || ''
MC/DC0%0/2
$e->{$_} ||= $permessage->{$_} || ""
$e->{$_}
$permessage->{$_}
Truth table66%2/3
A ||= B
A= $e->{$_}B= $permessage->{$_}
| |||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||
| 173 | 537 | ▶ | if( exists $anotherset->{'diagnosis'} && $anotherset->{'diagnosis'} ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $anotherset->{"diagnosis"} and $anotherset->{"diagnosis"}
MC/DC50%1/2
exists $anotherset->{"diagnosis"} and $anotherset->{"diagnosis"}
exists $anotherset->{"diagnosis"}
$anotherset->{"diagnosis"}
Truth table66%2/3
A and B
A= exists $anotherset->{"diagnosis"}B= $anotherset->{"diagnosis"}
| |||||||||||||||||||||||||||||||||||||||
| 174 | # Copy alternative error message | ||||||||||||||||||||||||||||||||||||||
| 175 | 68 | ▶ | $e->{'diagnosis'} = $anotherset->{'diagnosis'} if index($e->{'diagnosis'}, ' ') == 0; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 176 | 68 | ▶ | $e->{'diagnosis'} = $anotherset->{'diagnosis'} if $e->{'diagnosis'} =~ /\A\d+\z/; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 177 | 68 | ▶ | $e->{'diagnosis'} ||= $anotherset->{'diagnosis'}; | ||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$e->{"diagnosis"} ||= $anotherset->{"diagnosis"}
MC/DC0%0/2
$e->{"diagnosis"} ||= $anotherset->{"diagnosis"}
$e->{"diagnosis"}
$anotherset->{"diagnosis"}
Truth table66%2/3
A ||= B
A= $e->{"diagnosis"}B= $anotherset->{"diagnosis"}
| |||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||
| 180 | 537 | while(1) { | |||||||||||||||||||||||||||||||||||||
| 181 | # Replace or append the error message in "diagnosis" with the ESMTP Reply Code when the | ||||||||||||||||||||||||||||||||||||||
| 182 | # following conditions have matched | ||||||||||||||||||||||||||||||||||||||
| 183 | 537 | ▶ | last if scalar @$esmtpreply == 0 || $recipients != 1; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
scalar @$esmtpreply == 0 or $recipients != 1
MC/DC100%2/2
scalar @$esmtpreply == 0 or $recipients != 1
scalar @$esmtpreply == 0
$recipients != 1
Truth table100%3/3
A or B
A= scalar @$esmtpreply == 0B= $recipients != 1
| |||||||||||||||||||||||||||||||||||||||
| 184 | 444 | $e->{'diagnosis'} = sprintf("%s %s", join(' ', @$esmtpreply), $e->{'diagnosis'}); | |||||||||||||||||||||||||||||||||||||
| 185 | 444 | last; | |||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||
| 187 | 537 | ▶ | $e->{'command'} ||= $thecommand || Sisimai::SMTP::Command->find($e->{'diagnosis'}) || ''; | ||||||||||||||||||||||||||||||||||||
|
Condition87%7/8
$e->{"command"} ||= $thecommand || "Sisimai::SMTP::Command"->find($e->{"diagnosis"}) || ""
$thecommand || 'Sisimai::SMTP::Command'->find($e->{'diagnosis'}) || ''
$thecommand or "Sisimai::SMTP::Command"->find($e->{"diagnosis"})
MC/DC0%0/3
$e->{"command"} ||= $thecommand || "Sisimai::SMTP::Command"->find($e->{"diagnosis"}) || ""
$e->{"command"}
$thecommand
"Sisimai::SMTP::Command"->find($e->{"diagnosis"})
Truth table0%0/4
A ||= B or C
A= $e->{"command"}B= $thecommandC= "Sisimai::SMTP::Command"->find($e->{"diagnosis"})
| |||||||||||||||||||||||||||||||||||||||
| 188 | 537 | ▶ | $e->{'command'} ||= $Sisimai::Eb::CeEHLO if scalar @$esmtpreply; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$e->{"command"} ||= $Sisimai::Eb::CeEHLO
MC/DC0%0/2
$e->{"command"} ||= $Sisimai::Eb::CeEHLO
$e->{"command"}
$Sisimai::Eb::CeEHLO
Truth table66%2/3
A ||= B
A= $e->{"command"}B= $Sisimai::Eb::CeEHLO
| |||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||
| 190 | 537 | while(1) { | |||||||||||||||||||||||||||||||||||||
| 191 | # Check alternative status code and override it | ||||||||||||||||||||||||||||||||||||||
| 192 | 537 | ▶ | last unless exists $anotherset->{'status'}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 193 | 48 | ▶ | last unless length $anotherset->{'status'}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 194 | 48 | ▶ | last if Sisimai::SMTP::Status->test($e->{'status'}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||
| 196 | 0 | $e->{'status'} = $anotherset->{'status'}; | |||||||||||||||||||||||||||||||||||||
| 197 | 0 | last; | |||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||
| 199 | # @example.jp, no local part | ||||||||||||||||||||||||||||||||||||||
| 200 | # Get email address from the value of Diagnostic-Code field | ||||||||||||||||||||||||||||||||||||||
| 201 | 537 | ▶ | next unless index($e->{'recipient'}, '@') == 0; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 202 | 5 | ▶ | my $cv = Sisimai::Address->find($e->{'diagnosis'}, 1) || []; | ||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
'Sisimai::Address'->find($e->{'diagnosis'}, 1) || []
MC/DC0%0/1
'Sisimai::Address'->find($e->{'diagnosis'}, 1) || []
'Sisimai::Address'->find($e->{'diagnosis'}, 1)
Truth table50%1/2
A
A= 'Sisimai::Address'->find($e->{'diagnosis'}, 1)
| |||||||||||||||||||||||||||||||||||||||
| 203 | 5 | ▶ | $e->{'recipient'} = $cv->[0]->{'address'} if scalar @$cv; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||
| 205 | 527 | return {"ds" => $dscontents, "rfc822" => $emailparts->[1]}; | |||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||
| 208 | 55 | 1; | |||||||||||||||||||||||||||||||||||||
| 209 | __END__ | ||||||||||||||||||||||||||||||||||||||