| 1 | package Sisimai::Lhost::X3; | ||||||||||||||||||||||||||||
| 2 | 35 | ▶ | use parent 'Sisimai::Lhost'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 35 | ▶ | use v5.26; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 35 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 35 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | sub description { 'Unknown MTA #3' } | ||||||||||||||||||||||||||
|
Subroutine
description: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 8 | 883 | ▶ | sub inquire { | ||||||||||||||||||||||||||
|
Subroutine
inquire: called CC=19 SCAR=29.7
Pod
documented
| |||||||||||||||||||||||||||||
| 9 | # Detect an error from Unknown MTA #3 | ||||||||||||||||||||||||||||
| 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.9 | ||||||||||||||||||||||||||||
| 15 | 883 | my $class = shift; | |||||||||||||||||||||||||||
| 16 | 883 | ▶ | 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 | 882 | ▶ | 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 | 881 | ▶ | return undef unless index($mhead->{'from'}, 'Mail Delivery System') == 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | 45 | ▶ | return undef unless index($mhead->{'subject'}, 'Delivery status notification') == 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 26 | require Sisimai::SMTP::Command; | |||||||||||||||||||||||||||
| 23 | 26 | state $indicators = __PACKAGE__->INDICATORS; | |||||||||||||||||||||||||||
| 24 | 26 | state $boundaries = ['Content-Type: message/rfc822']; | |||||||||||||||||||||||||||
| 25 | 26 | state $startingof = {'message' => [' This is an automatically generated Delivery Status Notification.']}; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 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)
| |||||||||||||||||||||||||||||
| 28 | 26 | my $dscontents = [__PACKAGE__->DELIVERYSTATUS]; my $v = undef; | |||||||||||||||||||||||||||
| 29 | 26 | my $readcursor = 0; # (Integer) Points the current cursor position | |||||||||||||||||||||||||||
| 30 | 26 | my $recipients = 0; # (Integer) The number of 'Final-Recipient' header | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 26 | for my $e ( split("\n", $emailparts->[0]) ) { | |||||||||||||||||||||||||||
| 33 | # Read error messages and delivery status lines from the head of the email to the previous | ||||||||||||||||||||||||||||
| 34 | # line of the beginning of the original message. | ||||||||||||||||||||||||||||
| 35 | 472 | ▶ | unless( $readcursor ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | # Beginning of the bounce message or message/delivery-status part | ||||||||||||||||||||||||||||
| 37 | 94 | ▶ | $readcursor |= $indicators->{'deliverystatus'} if index($e, $startingof->{'message'}->[0]) == 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 94 | next; | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | 378 | ▶ | 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 ""
| |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | # ============================================================================ | ||||||||||||||||||||||||||||
| 43 | # This is an automatically generated Delivery Status Notification. | ||||||||||||||||||||||||||||
| 44 | # | ||||||||||||||||||||||||||||
| 45 | # Delivery to the following recipients failed permanently: | ||||||||||||||||||||||||||||
| 46 | # | ||||||||||||||||||||||||||||
| 47 | # * kijitora@example.com | ||||||||||||||||||||||||||||
| 48 | # | ||||||||||||||||||||||||||||
| 49 | # | ||||||||||||||||||||||||||||
| 50 | # ============================================================================ | ||||||||||||||||||||||||||||
| 51 | # Technical details: | ||||||||||||||||||||||||||||
| 52 | # | ||||||||||||||||||||||||||||
| 53 | # SMTP:RCPT host 192.0.2.8: 553 5.3.0 <kijitora@example.com>... No such user here | ||||||||||||||||||||||||||||
| 54 | # | ||||||||||||||||||||||||||||
| 55 | # | ||||||||||||||||||||||||||||
| 56 | # ============================================================================ | ||||||||||||||||||||||||||||
| 57 | 191 | $v = $dscontents->[-1]; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 191 | ▶ | if( index($e, ' * ') > -1 && index($e, '@') > 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
index($e, " * ") != -1 and index($e, "\@") > 1
MC/DC50%1/2
index($e, " * ") != -1 and index($e, "\@") > 1
index($e, " * ") != -1
index($e, "\@") > 1
Truth table66%2/3
A and B
A= index($e, " * ") != -1B= index($e, "\@") > 1
| |||||||||||||||||||||||||||||
| 60 | # * kijitora@example.com | ||||||||||||||||||||||||||||
| 61 | 26 | ▶ | if( $v->{'recipient'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | # There are multiple recipient addresses in the message body. | ||||||||||||||||||||||||||||
| 63 | 0 | push @$dscontents, __PACKAGE__->DELIVERYSTATUS; | |||||||||||||||||||||||||||
| 64 | 0 | $v = $dscontents->[-1]; | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | 26 | $v->{'recipient'} = substr($e, index($e, ' * ') + 3,); | |||||||||||||||||||||||||||
| 67 | 26 | $recipients++; | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | } else { | ||||||||||||||||||||||||||||
| 70 | # Detect error message | ||||||||||||||||||||||||||||
| 71 | 165 | ▶ | if( index($e, 'SMTP:') == 0 ) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 72 | # SMTP:RCPT host 192.0.2.8: 553 5.3.0 <kijitora@example.com>... No such user here | ||||||||||||||||||||||||||||
| 73 | 11 | $v->{'command'} = Sisimai::SMTP::Command->find($e); | |||||||||||||||||||||||||||
| 74 | 11 | $v->{'diagnosis'} = $e; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | } elsif( index($e, 'Routing: ') == 0 ) { | ||||||||||||||||||||||||||||
| 77 | # Routing: Could not find a gateway for kijitora@example.co.jp | ||||||||||||||||||||||||||||
| 78 | 5 | $v->{'diagnosis'} = substr($e, 9,); | |||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | } elsif( index($e, 'Diagnostic-Code: smtp; ') == 0 ) { | ||||||||||||||||||||||||||||
| 81 | # Diagnostic-Code: smtp; 552 5.2.2 Over quota | ||||||||||||||||||||||||||||
| 82 | 5 | $v->{'diagnosis'} = substr($e, index($e, ';') + 2,); | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | 26 | ▶ | return undef unless $recipients; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | 26 | return {"ds" => $dscontents, "rfc822" => $emailparts->[1]}; | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 35 | 1; | |||||||||||||||||||||||||||
| 91 | __END__ | ||||||||||||||||||||||||||||