| 1 | package Sisimai::Lhost::Postfix; | ||||||||||||||||||||||||||||||||||||||||
| 2 | 48 | ▶ | use parent 'Sisimai::Lhost'; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 3 | 48 | ▶ | use v5.26; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 4 | 48 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 5 | 48 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | sub description { 'Postfix: https://www.postfix.org/' } | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
description: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 8 | 1463 | ▶ | sub inquire { | ||||||||||||||||||||||||||||||||||||||
|
Subroutine
inquire: called CC=85 SCAR=45.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||
| 9 | # Decode bounce messages from Postfix | ||||||||||||||||||||||||||||||||||||||||
| 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.0.0 | ||||||||||||||||||||||||||||||||||||||||
| 15 | 1463 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||
| 16 | 1463 | ▶ | 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()
| |||||||||||||||||||||||||||||||||||||||||
| 17 | 1462 | ▶ | 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()
| |||||||||||||||||||||||||||||||||||||||||
| 18 | 1461 | my $match = 0; | |||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||
| 20 | 1461 | ▶ | if( index($mhead->{'subject'}, 'SMTP server: errors from ') > 0 ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 21 | # src/smtpd/smtpd_chat.c:|337: post_mail_fprintf(notice, "Subject: %s SMTP server: errors from %s", | ||||||||||||||||||||||||||||||||||||||||
| 22 | # src/smtpd/smtpd_chat.c:|338: var_mail_name, state->namaddr); | ||||||||||||||||||||||||||||||||||||||||
| 23 | 5 | $match = 2; | |||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||
| 25 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 26 | # Subject: Undelivered Mail Returned to Sender | ||||||||||||||||||||||||||||||||||||||||
| 27 | 1456 | ▶ | $match = 1 if $mhead->{'subject'} eq 'Undelivered Mail Returned to Sender'; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||
| 29 | 1461 | ▶ | return undef if $match == 0 || $mhead->{'x-aol-ip'}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$match == 0 or $mhead->{"x-aol-ip"}
MC/DC100%2/2
$match == 0 or $mhead->{"x-aol-ip"}
$match == 0
$mhead->{"x-aol-ip"}
Truth table100%3/3
A or B
A= $match == 0B= $mhead->{"x-aol-ip"}
| |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||
| 31 | 626 | require Sisimai::Eb; | |||||||||||||||||||||||||||||||||||||||
| 32 | 626 | require Sisimai::RFC1123; | |||||||||||||||||||||||||||||||||||||||
| 33 | 626 | require Sisimai::SMTP::Reply; | |||||||||||||||||||||||||||||||||||||||
| 34 | 626 | require Sisimai::SMTP::Status; | |||||||||||||||||||||||||||||||||||||||
| 35 | 626 | require Sisimai::SMTP::Command; | |||||||||||||||||||||||||||||||||||||||
| 36 | 626 | state $indicators = __PACKAGE__->INDICATORS; | |||||||||||||||||||||||||||||||||||||||
| 37 | 626 | state $boundaries = ['Content-Type: message/rfc822', 'Content-Type: text/rfc822-headers']; | |||||||||||||||||||||||||||||||||||||||
| 38 | 626 | state $startingof = { | |||||||||||||||||||||||||||||||||||||||
| 39 | # Postfix manual - bounce(5) - http://www.postfix.org/bounce.5.html | ||||||||||||||||||||||||||||||||||||||||
| 40 | 'message' => [ | ||||||||||||||||||||||||||||||||||||||||
| 41 | ['The ', 'Postfix '], # The Postfix program, The Postfix on <os> program | ||||||||||||||||||||||||||||||||||||||||
| 42 | ['The ', 'mail system'], # The mail system | ||||||||||||||||||||||||||||||||||||||||
| 43 | ['The ', 'program'], # The <name> pogram | ||||||||||||||||||||||||||||||||||||||||
| 44 | ['This is the', 'Postfix'], # This is the Postfix program | ||||||||||||||||||||||||||||||||||||||||
| 45 | ['This is the', 'mail system'], # This is the mail system at host <hostname> | ||||||||||||||||||||||||||||||||||||||||
| 46 | ], | ||||||||||||||||||||||||||||||||||||||||
| 47 | }; | ||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||
| 49 | 626 | ▶ | 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)
| |||||||||||||||||||||||||||||||||||||||||
| 50 | 626 | my $dscontents = [__PACKAGE__->DELIVERYSTATUS]; my $v = undef; | |||||||||||||||||||||||||||||||||||||||
| 51 | 626 | my $permessage = {}; # (Hash) Store values of each Per-Message field | |||||||||||||||||||||||||||||||||||||||
| 52 | 626 | my $recipients = 0; # (Integer) The number of 'Final-Recipient' header | |||||||||||||||||||||||||||||||||||||||
| 53 | 626 | my $anotherset = {}; # (Hash) Another error information | |||||||||||||||||||||||||||||||||||||||
| 54 | 626 | my $nomessages = 0; # (Integer) Delivery report unavailable | |||||||||||||||||||||||||||||||||||||||
| 55 | 626 | my @commandset; # (Array) ``in reply to * command'' list | |||||||||||||||||||||||||||||||||||||||
| 56 | 626 | my $p = ''; | |||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||
| 58 | 626 | ▶ | if( $match == 2 ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 59 | # The message body starts with 'Transcript of session follows.' | ||||||||||||||||||||||||||||||||||||||||
| 60 | 5 | require Sisimai::SMTP::Transcript; | |||||||||||||||||||||||||||||||||||||||
| 61 | 5 | ▶ | my $transcript = Sisimai::SMTP::Transcript->rise($emailparts->[0], 'In:', 'Out:') || return undef; | ||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
'Sisimai::SMTP::Transcript'->rise($emailparts->[0], 'In:', 'Out:') || (return undef)
MC/DC0%0/1
'Sisimai::SMTP::Transcript'->rise($emailparts->[0], 'In:', 'Out:') || (return undef)
'Sisimai::SMTP::Transcript'->rise($emailparts->[0], 'In:', 'Out:')
Truth table50%1/2
A
A= 'Sisimai::SMTP::Transcript'->rise($emailparts->[0], 'In:', 'Out:')
| |||||||||||||||||||||||||||||||||||||||||
| 62 | 5 | ▶ | return undef if scalar @$transcript == 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||
| 64 | 5 | for my $e ( @$transcript ) { | |||||||||||||||||||||||||||||||||||||||
| 65 | # Pick email addresses, error messages, and the last SMTP command. | ||||||||||||||||||||||||||||||||||||||||
| 66 | 40 | ▶ | $v ||= $dscontents->[-1]; | ||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$v ||= $dscontents->[-1]
MC/DC0%0/2
$v ||= $dscontents->[-1]
$v
$dscontents->[-1]
Truth table66%2/3
A ||= B
A= $vB= $dscontents->[-1]
| |||||||||||||||||||||||||||||||||||||||||
| 67 | 40 | $p = $e->{'response'}; | |||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||
| 69 | 40 | ▶ | if( $e->{'command'} eq $Sisimai::Eb::CeEHLO || $e->{'command'} eq $Sisimai::Eb::CeHELO ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%2/3
$e->{"command"} eq $Sisimai::Eb::CeEHLO or $e->{"command"} eq $Sisimai::Eb::CeHELO
MC/DC50%1/2
$e->{"command"} eq $Sisimai::Eb::CeEHLO or $e->{"command"} eq $Sisimai::Eb::CeHELO
$e->{"command"} eq $Sisimai::Eb::CeEHLO
$e->{"command"} eq $Sisimai::Eb::CeHELO
Truth table66%2/3
A or B
A= $e->{"command"} eq $Sisimai::Eb::CeEHLOB= $e->{"command"} eq $Sisimai::Eb::CeHELO
| |||||||||||||||||||||||||||||||||||||||||
| 70 | # Use the argument of EHLO/HELO command as a value of "lhost" | ||||||||||||||||||||||||||||||||||||||||
| 71 | 5 | $v->{'lhost'} = $e->{'argument'}; | |||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||
| 73 | } elsif( $e->{'command'} eq $Sisimai::Eb::CeMAIL ) { | ||||||||||||||||||||||||||||||||||||||||
| 74 | # Set the argument of "MAIL" command to pseudo To: header of the original message | ||||||||||||||||||||||||||||||||||||||||
| 75 | 5 | ▶ | $emailparts->[1] .= sprintf("To: %s\n", $e->{'argument'}) unless length $emailparts->[1]; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||
| 77 | } elsif( $e->{'command'} eq $Sisimai::Eb::CeRCPT ) { | ||||||||||||||||||||||||||||||||||||||||
| 78 | # RCPT TO: <...> | ||||||||||||||||||||||||||||||||||||||||
| 79 | 5 | ▶ | if( $v->{'recipient'} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 80 | # There are multiple recipient addresses in the transcript of session | ||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | push @$dscontents, __PACKAGE__->DELIVERYSTATUS; | |||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $v = $dscontents->[-1]; | |||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||
| 84 | 5 | $v->{'recipient'} = $e->{'argument'}; | |||||||||||||||||||||||||||||||||||||||
| 85 | 5 | $recipients++; | |||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||
| 87 | 40 | ▶ | next if int($p->{'reply'}) < 400; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||
| 89 | 5 | push @commandset, $e->{'command'}; | |||||||||||||||||||||||||||||||||||||||
| 90 | 5 | ▶ | $v->{'diagnosis'} ||= join ' ', $p->{'text'}->@*; | ||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$v->{"diagnosis"} ||= join(" ", @{$p->{"text"}})
MC/DC0%0/2
$v->{"diagnosis"} ||= join(" ", @{$p->{"text"}})
$v->{"diagnosis"}
join(" ", @{$p->{"text"}})
Truth table33%1/3
A ||= B
A= $v->{"diagnosis"}B= join(" ", @{$p->{"text"}})
| |||||||||||||||||||||||||||||||||||||||||
| 91 | 5 | ▶ | $v->{'replycode'} ||= $p->{'reply'}; | ||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$v->{"replycode"} ||= $p->{"reply"}
MC/DC0%0/2
$v->{"replycode"} ||= $p->{"reply"}
$v->{"replycode"}
$p->{"reply"}
Truth table33%1/3
A ||= B
A= $v->{"replycode"}B= $p->{"reply"}
| |||||||||||||||||||||||||||||||||||||||||
| 92 | 5 | ▶ | $v->{'status'} ||= $p->{'status'}; | ||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$v->{"status"} ||= $p->{"status"}
MC/DC0%0/2
$v->{"status"} ||= $p->{"status"}
$v->{"status"}
$p->{"status"}
Truth table33%1/3
A ||= B
A= $v->{"status"}B= $p->{"status"}
| |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||
| 94 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 95 | 621 | my $fieldtable = Sisimai::RFC1894->FIELDTABLE; | |||||||||||||||||||||||||||||||||||||||
| 96 | 621 | my $readcursor = 0; # (Integer) Points the current cursor position | |||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||
| 98 | # The message body is a general bounce mail message of Postfix | ||||||||||||||||||||||||||||||||||||||||
| 99 | 621 | for my $e ( split("\n", $emailparts->[0]) ) { | |||||||||||||||||||||||||||||||||||||||
| 100 | # Read error messages and delivery status lines from the head of the email to the previous | ||||||||||||||||||||||||||||||||||||||||
| 101 | # line of the beginning of the original message. | ||||||||||||||||||||||||||||||||||||||||
| 102 | 19823 | ▶ | unless( $readcursor ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 103 | # Beginning of the bounce message or message/delivery-status part | ||||||||||||||||||||||||||||||||||||||||
| 104 | 3220 | ▶ | $readcursor |= $indicators->{'deliverystatus'} if grep { Sisimai::String->aligned(\$e, $_) } $startingof->{'message'}->@*; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 105 | 3220 | next; | |||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||
| 107 | 16603 | ▶ | 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 ""
| |||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||
| 109 | 12520 | ▶ | if( my $f = Sisimai::RFC1894->match($e) ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 110 | # $e matched with any field defined in RFC3464 | ||||||||||||||||||||||||||||||||||||||||
| 111 | 4310 | ▶ | next unless my $o = Sisimai::RFC1894->field($e); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 112 | 4310 | $v = $dscontents->[-1]; | |||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||
| 114 | 4310 | ▶ | if( $o->[3] eq 'addr' ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||
| 115 | # Final-Recipient: rfc822; kijitora@example.jp | ||||||||||||||||||||||||||||||||||||||||
| 116 | # X-Actual-Recipient: rfc822; kijitora@example.co.jp | ||||||||||||||||||||||||||||||||||||||||
| 117 | 1052 | ▶ | if( Sisimai::Address->is_emailaddress($o->[2]) ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 118 | # The email address is a valid email address, avoid an email address without a | ||||||||||||||||||||||||||||||||||||||||
| 119 | # valid domain part such as "neko@mailhost". | ||||||||||||||||||||||||||||||||||||||||
| 120 | 1047 | ▶ | if( $o->[0] eq 'final-recipient' ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 121 | # Final-Recipient: rfc822; kijitora@example.jp | ||||||||||||||||||||||||||||||||||||||||
| 122 | 555 | ▶ | if( $v->{'recipient'} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 123 | # There are multiple recipient addresses in the message body. | ||||||||||||||||||||||||||||||||||||||||
| 124 | 15 | push @$dscontents, __PACKAGE__->DELIVERYSTATUS; | |||||||||||||||||||||||||||||||||||||||
| 125 | 15 | $v = $dscontents->[-1]; | |||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||
| 127 | 555 | $v->{'recipient'} = $o->[2]; | |||||||||||||||||||||||||||||||||||||||
| 128 | 555 | $recipients++; | |||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||
| 130 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 131 | # X-Actual-Recipient: rfc822; kijitora@example.co.jp | ||||||||||||||||||||||||||||||||||||||||
| 132 | 492 | $v->{'alias'} = $o->[2]; | |||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||
| 135 | } elsif( $o->[3] eq 'code' ) { | ||||||||||||||||||||||||||||||||||||||||
| 136 | # Diagnostic-Code: SMTP; 550 5.1.1 <userunknown@example.jp>... User Unknown | ||||||||||||||||||||||||||||||||||||||||
| 137 | 560 | $v->{'spec'} = $o->[1]; | |||||||||||||||||||||||||||||||||||||||
| 138 | 560 | ▶ | $v->{'spec'} = 'SMTP' if uc $v->{'spec'} eq 'X-POSTFIX'; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 139 | 560 | $v->{'diagnosis'} = $o->[2]; | |||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||
| 141 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 142 | # Other DSN fields defined in RFC3464 | ||||||||||||||||||||||||||||||||||||||||
| 143 | 2698 | ▶ | next unless exists $fieldtable->{ $o->[0] }; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 144 | 2698 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||
| 145 | 2682 | $v->{ $fieldtable->{ $o->[0] } } = $o->[2]; | |||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||
| 147 | 2682 | ▶ | next unless $f == 1; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 148 | 1089 | $permessage->{ $fieldtable->{ $o->[0] } } = $o->[2]; | |||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||
| 150 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 151 | # If you do so, please include this problem report. You can | ||||||||||||||||||||||||||||||||||||||||
| 152 | # delete your own text from the attached returned message. | ||||||||||||||||||||||||||||||||||||||||
| 153 | # | ||||||||||||||||||||||||||||||||||||||||
| 154 | # The mail system | ||||||||||||||||||||||||||||||||||||||||
| 155 | # | ||||||||||||||||||||||||||||||||||||||||
| 156 | # <userunknown@example.co.jp>: host mx.example.co.jp[192.0.2.153] said: 550 | ||||||||||||||||||||||||||||||||||||||||
| 157 | # 5.1.1 <userunknown@example.co.jp>... User Unknown (in reply to RCPT TO command) | ||||||||||||||||||||||||||||||||||||||||
| 158 | 8210 | ▶ | if( index($p, 'Diagnostic-Code:') == 0 && index($e, ' ') > -1 ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
index($p, "Diagnostic-Code:") == 0 and index($e, " ") != -1
MC/DC50%1/2
index($p, "Diagnostic-Code:") == 0 and index($e, " ") != -1
index($p, "Diagnostic-Code:") == 0
index($e, " ") != -1
Truth table66%2/3
A and B
A= index($p, "Diagnostic-Code:") == 0B= index($e, " ") != -1
| |||||||||||||||||||||||||||||||||||||||||
| 159 | # Continued line of the value of Diagnostic-Code header | ||||||||||||||||||||||||||||||||||||||||
| 160 | 821 | $v->{'diagnosis'} .= ' '.Sisimai::String->sweep($e); | |||||||||||||||||||||||||||||||||||||||
| 161 | 821 | $e = 'Diagnostic-Code: '.$e; | |||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||
| 163 | } elsif( Sisimai::String->aligned(\$e, ['X-Postfix-Sender:', 'rfc822;', '@']) ) { | ||||||||||||||||||||||||||||||||||||||||
| 164 | # X-Postfix-Sender: rfc822; shironeko@example.org | ||||||||||||||||||||||||||||||||||||||||
| 165 | 523 | $emailparts->[1] .= sprintf("X-Postfix-Sender: %s\n", substr($e, index($e, ';') + 1,)); | |||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||
| 167 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 168 | # Alternative error message and recipient | ||||||||||||||||||||||||||||||||||||||||
| 169 | 6866 | ▶ | if( index($e, ' (in reply to ') > -1 || index($e, 'command)') > -1 ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
Condition100%3/3
index($e, " (in reply to ") != -1 or index($e, "command)") != -1
MC/DC100%2/2
index($e, " (in reply to ") != -1 or index($e, "command)") != -1
index($e, " (in reply to ") != -1
index($e, "command)") != -1
Truth table100%3/3
A or B
A= index($e, " (in reply to ") != -1B= index($e, "command)") != -1
| |||||||||||||||||||||||||||||||||||||||||
| 170 | # 5.1.1 <userunknown@example.co.jp>... User Unknown (in reply to RCPT TO | ||||||||||||||||||||||||||||||||||||||||
| 171 | 603 | ▶ | my $cv = Sisimai::SMTP::Command->find($e); push @commandset, $cv if $cv; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 172 | 603 | ▶ | $anotherset->{'diagnosis'} .= ' '.$e if $anotherset->{'diagnosis'}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||
| 174 | } elsif( Sisimai::String->aligned(\$e, ['<', '@', '>', '(expanded from <', '):']) ) { | ||||||||||||||||||||||||||||||||||||||||
| 175 | # <r@example.ne.jp> (expanded from <kijitora@example.org>): user ... | ||||||||||||||||||||||||||||||||||||||||
| 176 | 40 | my $p1 = index($e, '> '); | |||||||||||||||||||||||||||||||||||||||
| 177 | 40 | my $p2 = index($e, '(expanded from ', $p1); | |||||||||||||||||||||||||||||||||||||||
| 178 | 40 | my $p3 = index($e, '>): ', $p2 + 14); | |||||||||||||||||||||||||||||||||||||||
| 179 | 40 | $anotherset->{'recipient'} = Sisimai::Address->s3s4(substr($e, 0, $p1)); | |||||||||||||||||||||||||||||||||||||||
| 180 | 40 | $anotherset->{'alias'} = Sisimai::Address->s3s4(substr($e, $p2 + 15, $p3 - $p2 - 15)); | |||||||||||||||||||||||||||||||||||||||
| 181 | 40 | $anotherset->{'diagnosis'} = substr($e, $p3 + 3,); | |||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||
| 183 | ▶ | } elsif( index($e, '<') == 0 && Sisimai::String->aligned(\$e, ['<', '@', '>:']) ) { | |||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
index($e, "<") == 0 and "Sisimai::String"->aligned(\$e, ["<", "\@", ">:"])
MC/DC100%2/2
index($e, "<") == 0 and "Sisimai::String"->aligned(\$e, ["<", "\@", ">:"])
index($e, "<") == 0
"Sisimai::String"->aligned(\$e, ["<", "\@", ">:"])
Truth table100%3/3
A and B
A= index($e, "<") == 0B= "Sisimai::String"->aligned(\$e, ["<", "\@", ">:"])
| |||||||||||||||||||||||||||||||||||||||||
| 184 | # <kijitora@exmaple.jp>: ... | ||||||||||||||||||||||||||||||||||||||||
| 185 | 514 | $anotherset->{'recipient'} = Sisimai::Address->s3s4(substr($e, 0, index($e, '>'))); | |||||||||||||||||||||||||||||||||||||||
| 186 | 514 | $anotherset->{'diagnosis'} = substr($e, index($e, '>:') + 2,); | |||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||
| 188 | } elsif( index($e, '--- Delivery report unavailable ---') > -1 ) { | ||||||||||||||||||||||||||||||||||||||||
| 189 | # postfix-3.1.4/src/bounce/bounce_notify_util.c | ||||||||||||||||||||||||||||||||||||||||
| 190 | # bounce_notify_util.c:602|if (bounce_info->log_handle == 0 | ||||||||||||||||||||||||||||||||||||||||
| 191 | # bounce_notify_util.c:602||| bounce_log_rewind(bounce_info->log_handle)) { | ||||||||||||||||||||||||||||||||||||||||
| 192 | # bounce_notify_util.c:602|if (IS_FAILURE_TEMPLATE(bounce_info->template)) { | ||||||||||||||||||||||||||||||||||||||||
| 193 | # bounce_notify_util.c:602| post_mail_fputs(bounce, ""); | ||||||||||||||||||||||||||||||||||||||||
| 194 | # bounce_notify_util.c:602| post_mail_fputs(bounce, "\t--- delivery report unavailable ---"); | ||||||||||||||||||||||||||||||||||||||||
| 195 | # bounce_notify_util.c:602| count = 1; /* xxx don't abort */ | ||||||||||||||||||||||||||||||||||||||||
| 196 | # bounce_notify_util.c:602|} | ||||||||||||||||||||||||||||||||||||||||
| 197 | # bounce_notify_util.c:602|} else { | ||||||||||||||||||||||||||||||||||||||||
| 198 | 5 | $nomessages = 1; | |||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||
| 200 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 201 | # Get an error message continued from the previous line | ||||||||||||||||||||||||||||||||||||||||
| 202 | 5704 | ▶ | next unless $anotherset->{'diagnosis'}; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 203 | 2018 | ▶ | $anotherset->{'diagnosis'} .= ' '.substr($e, 4,) if index($e, ' ') == 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||
| 206 | } # End of message/delivery-status | ||||||||||||||||||||||||||||||||||||||||
| 207 | } continue { | ||||||||||||||||||||||||||||||||||||||||
| 208 | # Save the current line for the next loop | ||||||||||||||||||||||||||||||||||||||||
| 209 | 19823 | $p = $e; | |||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||
| 211 | } # End of for() | ||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||
| 213 | 626 | ▶ | unless( $recipients ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 214 | # Fallback: get a recipient address from error messages | ||||||||||||||||||||||||||||||||||||||||
| 215 | 81 | for my $e ( 'recipient', 'alias' ) { | |||||||||||||||||||||||||||||||||||||||
| 216 | # Set a valid recipient address picked from $anotherset | ||||||||||||||||||||||||||||||||||||||||
| 217 | 147 | ▶ | next unless Sisimai::Address->is_emailaddress($anotherset->{ $e }); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 218 | 20 | $dscontents->[-1]->{'recipient'} = $anotherset->{ $e }; | |||||||||||||||||||||||||||||||||||||||
| 219 | 20 | $recipients++; | |||||||||||||||||||||||||||||||||||||||
| 220 | 20 | last; | |||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||
| 223 | 81 | ▶ | if( $recipients == 0 ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 224 | # Get a recipient address from message/rfc822 part if the delivery report was unavailable: | ||||||||||||||||||||||||||||||||||||||||
| 225 | # '--- Delivery report unavailable ---' | ||||||||||||||||||||||||||||||||||||||||
| 226 | 61 | my $p1 = index($emailparts->[1], "\nTo: "); | |||||||||||||||||||||||||||||||||||||||
| 227 | 61 | my $p2 = index($emailparts->[1], "\n", $p1 + 6); | |||||||||||||||||||||||||||||||||||||||
| 228 | 61 | ▶ | if( $nomessages && $p1 > 0 ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$nomessages and $p1 > 0
MC/DC50%1/2
$nomessages and $p1 > 0
$nomessages
$p1 > 0
Truth table66%2/3
A and B
A= $nomessagesB= $p1 > 0
| |||||||||||||||||||||||||||||||||||||||||
| 229 | # Try to get a recipient address from To: field in the original | ||||||||||||||||||||||||||||||||||||||||
| 230 | # message at message/rfc822 part | ||||||||||||||||||||||||||||||||||||||||
| 231 | 5 | $dscontents->[-1]->{'recipient'} = Sisimai::Address->s3s4(substr($emailparts->[1], $p1 + 5, $p2 - $p1 - 5)); | |||||||||||||||||||||||||||||||||||||||
| 232 | 5 | $recipients++; | |||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||
| 236 | 626 | ▶ | return undef unless $recipients; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||
| 238 | 570 | for my $e ( @$dscontents ) { | |||||||||||||||||||||||||||||||||||||||
| 239 | # Set default values if each value is empty. | ||||||||||||||||||||||||||||||||||||||||
| 240 | 585 | ▶ | $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->{$_}
| |||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||
| 242 | 585 | ▶ | if( $anotherset->{'diagnosis'} ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 243 | # Copy alternative error message | ||||||||||||||||||||||||||||||||||||||||
| 244 | 554 | $anotherset->{'diagnosis'} = Sisimai::String->sweep($anotherset->{'diagnosis'}); | |||||||||||||||||||||||||||||||||||||||
| 245 | 554 | ▶ | $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"}
| |||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||
| 247 | 554 | ▶ | if( $e->{'diagnosis'} =~ /\A\d+\z/ ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 248 | # Override the value of diagnostic code message | ||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | $e->{'diagnosis'} = $anotherset->{'diagnosis'}; | |||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||
| 251 | } else { | ||||||||||||||||||||||||||||||||||||||||
| 252 | # More detailed error message is in "$anotherset" | ||||||||||||||||||||||||||||||||||||||||
| 253 | 554 | my $as = ''; # status | |||||||||||||||||||||||||||||||||||||||
| 254 | 554 | my $ar = ''; # replycode | |||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||
| 256 | 554 | ▶ | if( Sisimai::SMTP::Status->is_ambiguous($e->{'status'}) ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 257 | # Check the value of D.S.N. in $anotherset is neither an empty nor *.0.0. | ||||||||||||||||||||||||||||||||||||||||
| 258 | 192 | ▶ | $as = Sisimai::SMTP::Status->find($anotherset->{'diagnosis'}) || ''; | ||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
'Sisimai::SMTP::Status'->find($anotherset->{'diagnosis'}) || ''
MC/DC100%1/1
'Sisimai::SMTP::Status'->find($anotherset->{'diagnosis'}) || ''
'Sisimai::SMTP::Status'->find($anotherset->{'diagnosis'})
Truth table100%2/2
A
A= 'Sisimai::SMTP::Status'->find($anotherset->{'diagnosis'})
| |||||||||||||||||||||||||||||||||||||||||
| 259 | 192 | ▶ | $e->{'status'} = $as unless Sisimai::SMTP::Status->is_ambiguous($as); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||
| 262 | 554 | ▶ | if( $e->{'replycode'} eq '' || substr($e->{'replycode'}, -2, 2) eq '00' ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$e->{"replycode"} eq "" or substr($e->{"replycode"}, -2, 2) eq "00"
MC/DC0%0/2
$e->{"replycode"} eq "" or substr($e->{"replycode"}, -2, 2) eq "00"
$e->{"replycode"} eq ""
substr($e->{"replycode"}, -2, 2) eq "00"
Truth table33%1/3
A or B
A= $e->{"replycode"} eq ""B= substr($e->{"replycode"}, -2, 2) eq "00"
| |||||||||||||||||||||||||||||||||||||||||
| 263 | # Check the value of SMTP reply code in $anotherset | ||||||||||||||||||||||||||||||||||||||||
| 264 | 554 | ▶ | $ar = Sisimai::SMTP::Reply->find($anotherset->{'diagnosis'}) || ''; | ||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
'Sisimai::SMTP::Reply'->find($anotherset->{'diagnosis'}) || ''
MC/DC100%1/1
'Sisimai::SMTP::Reply'->find($anotherset->{'diagnosis'}) || ''
'Sisimai::SMTP::Reply'->find($anotherset->{'diagnosis'})
Truth table100%2/2
A
A= 'Sisimai::SMTP::Reply'->find($anotherset->{'diagnosis'})
| |||||||||||||||||||||||||||||||||||||||||
| 265 | 554 | ▶ | if( length($ar) > 0 && substr($ar, -2, 2) ne '00' ) { | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
length $ar > 0 and substr($ar, -2, 2) ne "00"
MC/DC50%1/2
length $ar > 0 and substr($ar, -2, 2) ne "00"
length $ar > 0
substr($ar, -2, 2) ne "00"
Truth table66%2/3
A and B
A= length $ar > 0B= substr($ar, -2, 2) ne "00"
| |||||||||||||||||||||||||||||||||||||||||
| 266 | # The SMTP reply code is neither an empty nor *00 | ||||||||||||||||||||||||||||||||||||||||
| 267 | 481 | $e->{'replycode'} = $ar; | |||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||
| 271 | 554 | while(1) { | |||||||||||||||||||||||||||||||||||||||
| 272 | # Replace $e->{'diagnosis'} with the value of $anotherset->{'diagnosis'} when | ||||||||||||||||||||||||||||||||||||||||
| 273 | # all the following conditions have not matched. | ||||||||||||||||||||||||||||||||||||||||
| 274 | 554 | ▶ | last if length($as.$ar) == 0; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 275 | 481 | ▶ | last if length($anotherset->{'diagnosis'}) < length($e->{'diagnosis'}); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 276 | 481 | ▶ | last if index($anotherset->{'diagnosis'}, $e->{'diagnosis'}) == -1; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||
| 278 | 449 | $e->{'diagnosis'} = $anotherset->{'diagnosis'}; | |||||||||||||||||||||||||||||||||||||||
| 279 | 449 | last; | |||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||
| 283 | 585 | $e->{'diagnosis'} = Sisimai::String->sweep($e->{'diagnosis'}); | |||||||||||||||||||||||||||||||||||||||
| 284 | 585 | ▶ | $e->{'command'} = shift @commandset || Sisimai::SMTP::Command->find($e->{'diagnosis'}) || ''; | ||||||||||||||||||||||||||||||||||||||
|
Condition100%5/5
shift @commandset || 'Sisimai::SMTP::Command'->find($e->{'diagnosis'}) || ''
shift @commandset or "Sisimai::SMTP::Command"->find($e->{"diagnosis"})
MC/DC100%2/2
shift @commandset || 'Sisimai::SMTP::Command'->find($e->{'diagnosis'}) || ''
shift @commandset
"Sisimai::SMTP::Command"->find($e->{"diagnosis"})
Truth table100%3/3
A or B
A= shift @commandsetB= "Sisimai::SMTP::Command"->find($e->{"diagnosis"})
| |||||||||||||||||||||||||||||||||||||||||
| 285 | 585 | ▶ | $e->{'command'} ||= $Sisimai::Eb::CeHELO if index($e->{'diagnosis'}, 'refused to talk to me:') > -1; | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$e->{"command"} ||= $Sisimai::Eb::CeHELO
MC/DC0%0/2
$e->{"command"} ||= $Sisimai::Eb::CeHELO
$e->{"command"}
$Sisimai::Eb::CeHELO
Truth table33%1/3
A ||= B
A= $e->{"command"}B= $Sisimai::Eb::CeHELO
| |||||||||||||||||||||||||||||||||||||||||
| 286 | 585 | ▶ | $e->{'spec'} ||= 'SMTP' if Sisimai::String->aligned(\$e->{'diagnosis'}, ['host ', ' said:']); | ||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$e->{"spec"} ||= "SMTP"
MC/DC100%1/1
$e->{"spec"} ||= "SMTP"
$e->{"spec"}
Truth table100%2/2
A
A= $e->{"spec"}
| |||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||
| 288 | 570 | return {"ds" => $dscontents, "rfc822" => $emailparts->[1]}; | |||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||
| 291 | 48 | 1; | |||||||||||||||||||||||||||||||||||||||
| 292 | __END__ | ||||||||||||||||||||||||||||||||||||||||