| 1 | package Sisimai::Lhost::IMailServer; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 36 | ▶ | use parent 'Sisimai::Lhost'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 36 | ▶ | use v5.26; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 36 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 36 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | sub description { 'Progress iMail Server: https://community.progress.com/s/products/imailserver' } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
description: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 893 | ▶ | sub inquire { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inquire: called CC=25 SCAR=32.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # Detect an error from Progress iMail Server | ||||||||||||||||||||||||||||||||||||||||||||||
| 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.1 | ||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 893 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 16 | 893 | ▶ | 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 | 892 | ▶ | 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 | |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # X-Mailer: <SMTP32 v8.22> | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 891 | ▶ | my $match = 0; $match ||= 1 if index($mhead->{'subject'}, 'Undeliverable Mail ') == 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$match ||= 1
MC/DC0%0/1
$match ||= 1
$match
Truth table50%1/2
A
A= $match
| |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 891 | ▶ | $match ||= 1 if defined $mhead->{'x-mailer'} && index($mhead->{'x-mailer'}, '<SMTP32 v') == 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%5/5
defined $mhead->{"x-mailer"} and index($mhead->{"x-mailer"}, "<SMTP32 v") == 0
$match ||= 1
MC/DC100%2/2
defined $mhead->{"x-mailer"} and index($mhead->{"x-mailer"}, "<SMTP32 v") == 0
defined $mhead->{"x-mailer"}
index($mhead->{"x-mailer"}, "<SMTP32 v") == 0
MC/DC100%1/1
$match ||= 1
$match
Truth table100%3/3
A and B
A= defined $mhead->{"x-mailer"}B= index($mhead->{"x-mailer"}, "<SMTP32 v") == 0
Truth table100%2/2
A
A= $match
| |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 891 | ▶ | return undef unless $match; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 26 | require Sisimai::Eb; | |||||||||||||||||||||||||||||||||||||||||||||
| 25 | 26 | state $boundaries = ['Original message follows.']; | |||||||||||||||||||||||||||||||||||||||||||||
| 26 | 26 | state $startingof = {'error' => ['Body of message generated response:']}; | |||||||||||||||||||||||||||||||||||||||||||||
| 27 | 26 | state $messagesof = { | |||||||||||||||||||||||||||||||||||||||||||||
| 28 | $Sisimai::Eb::ReUSER => ['Unknown user', 'Invalid final delivery userid'], | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | $Sisimai::Eb::ReTIME => ['Delivery failed '], | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 26 | ▶ | 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)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 26 | my $dscontents = [__PACKAGE__->DELIVERYSTATUS]; my $v = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 34 | 26 | my $recipients = 0; # (Integer) The number of 'Final-Recipient' header | |||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 26 | 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 | |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # Unknown user: kijitora@example.com | ||||||||||||||||||||||||||||||||||||||||||||||
| 41 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # Original message follows. | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 96 | $v = $dscontents->[-1]; | |||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 96 | my $p0 = index($e, ': '); | |||||||||||||||||||||||||||||||||||||||||||||
| 46 | 96 | ▶ | if( ($p0 > 8 && Sisimai::String->aligned(\$e, [': ', '@'])) || index($e, 'undeliverable ') == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$p0 > 8 and "Sisimai::String"->aligned(\$e, [": ", "\@"]) or index($e, "undeliverable ") == 0
$p0 > 8 and "Sisimai::String"->aligned(\$e, [": ", "\@"])
MC/DC100%3/3
$p0 > 8 and "Sisimai::String"->aligned(\$e, [": ", "\@"]) or index($e, "undeliverable ") == 0
$p0 > 8
"Sisimai::String"->aligned(\$e, [": ", "\@"])
index($e, "undeliverable ") == 0
Truth table80%4/5
A and B or C
A= $p0 > 8B= "Sisimai::String"->aligned(\$e, [": ", "\@"])C= index($e, "undeliverable ") == 0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # Unknown user: kijitora@example.com | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # undeliverable to kijitora@example.com | ||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 26 | ▶ | if( $v->{'recipient'} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 50 | # There are multiple recipient addresses in the message body. | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | push @$dscontents, __PACKAGE__->DELIVERYSTATUS; | |||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $v = $dscontents->[-1]; | |||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 26 | $v->{'diagnosis'} = $e; | |||||||||||||||||||||||||||||||||||||||||||||
| 55 | 26 | $v->{'recipient'} = Sisimai::Address->s3s4($e); | |||||||||||||||||||||||||||||||||||||||||||||
| 56 | 26 | $recipients++; | |||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | # Other error message text | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 70 | ▶ | $v->{'alterrors'} //= ''; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$v->{"alterrors"} //= ""
MC/DC100%1/1
$v->{"alterrors"} //= ""
$v->{"alterrors"}
Truth table100%2/2
A
A= $v->{"alterrors"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 70 | ▶ | $v->{'alterrors'} .= ' '.$e if $v->{'alterrors'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 70 | ▶ | $v->{'alterrors'} = $e if index($e, $startingof->{'error'}->[0]) > -1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 26 | ▶ | return undef unless $recipients; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 26 | require Sisimai::SMTP::Command; | |||||||||||||||||||||||||||||||||||||||||||||
| 68 | 26 | for my $e ( @$dscontents ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 69 | 26 | ▶ | if( exists $e->{'alterrors'} && $e->{'alterrors'} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $e->{"alterrors"} and $e->{"alterrors"}
MC/DC50%1/2
exists $e->{"alterrors"} and $e->{"alterrors"}
exists $e->{"alterrors"}
$e->{"alterrors"}
Truth table66%2/3
A and B
A= exists $e->{"alterrors"}B= $e->{"alterrors"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | # Copy alternative error message | ||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 5 | $e->{'diagnosis'} = $e->{'alterrors'}.' '.$e->{'diagnosis'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 72 | 5 | delete $e->{'alterrors'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 26 | $e->{'command'} = Sisimai::SMTP::Command->find($e->{'diagnosis'}); | |||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 26 | SESSION: for my $r ( keys %$messagesof ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 77 | # Verify each regular expression of session errors | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 47 | ▶ | next unless grep { index($e->{'diagnosis'}, $_) > -1 } $messagesof->{ $r }->@*; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 16 | $e->{'reason'} = $r; | |||||||||||||||||||||||||||||||||||||||||||||
| 80 | 16 | last; | |||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 26 | return {"ds" => $dscontents, "rfc822" => $emailparts->[1]}; | |||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 36 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 87 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||