| 1 | package Sisimai::Lhost::X1; | ||||||||||||||||||||||||||||
| 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 #1' } | ||||||||||||||||||||||||||
|
Subroutine
description: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 8 | 878 | ▶ | sub inquire { | ||||||||||||||||||||||||||
|
Subroutine
inquire: called CC=20 SCAR=30.3
Pod
documented
| |||||||||||||||||||||||||||||
| 9 | # Detect an error from Unknown MTA #1 | ||||||||||||||||||||||||||||
| 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.3 | ||||||||||||||||||||||||||||
| 15 | 878 | my $class = shift; | |||||||||||||||||||||||||||
| 16 | 878 | ▶ | 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 | 877 | ▶ | 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 | 876 | my $proceedsto = 0; | |||||||||||||||||||||||||||
| 20 | 876 | ▶ | $proceedsto = 1 if index($mhead->{'subject'}, 'Returned Mail: ') == 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 876 | ▶ | $proceedsto = 1 if index($mhead->{'subject'}, 'Mail Delivery Failure') == 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 876 | ▶ | $proceedsto = 1 if Sisimai::String->aligned(\$mhead->{'from'}, ['"Mail Deliver', 'System" ']); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 876 | ▶ | return undef unless $proceedsto; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 50 | state $indicators = __PACKAGE__->INDICATORS; | |||||||||||||||||||||||||||
| 26 | 50 | state $boundaries = ['Content-Type: message/rfc822', 'Received: from ']; | |||||||||||||||||||||||||||
| 27 | 50 | state $markingsof = {'message' => ['The original message was received at ']}; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 50 | ▶ | 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)
| |||||||||||||||||||||||||||||
| 30 | 50 | my $dscontents = [__PACKAGE__->DELIVERYSTATUS]; my $v = undef; | |||||||||||||||||||||||||||
| 31 | 50 | my $readcursor = 0; # (Integer) Points the current cursor position | |||||||||||||||||||||||||||
| 32 | 50 | my $recipients = 0; # (Integer) The number of 'Final-Recipient' header | |||||||||||||||||||||||||||
| 33 | 50 | my $datestring = ''; # (String) Date string | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 50 | for my $e ( split("\n", $emailparts->[0]) ) { | |||||||||||||||||||||||||||
| 36 | # Read error messages and delivery status lines from the head of the email to the previous | ||||||||||||||||||||||||||||
| 37 | # line of the beginning of the original message. | ||||||||||||||||||||||||||||
| 38 | 1042 | ▶ | unless( $readcursor ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | # Beginning of the bounce message or message/delivery-status part | ||||||||||||||||||||||||||||
| 40 | 894 | ▶ | $readcursor |= $indicators->{'deliverystatus'} if index($e, $markingsof->{'message'}->[0]) == 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 894 | next; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | 148 | ▶ | 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 ""
| |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | # The original message was received at Thu, 29 Apr 2010 23:34:45 +0900 (JST) | ||||||||||||||||||||||||||||
| 46 | # from shironeko@example.jp | ||||||||||||||||||||||||||||
| 47 | # | ||||||||||||||||||||||||||||
| 48 | # ---The following addresses had delivery errors--- | ||||||||||||||||||||||||||||
| 49 | # | ||||||||||||||||||||||||||||
| 50 | # kijitora@example.co.jp [User unknown] | ||||||||||||||||||||||||||||
| 51 | 79 | $v = $dscontents->[-1]; | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 79 | ▶ | if( Sisimai::String->aligned(\$e, ['@', ' [', ']']) ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 54 | # kijitora@example.co.jp [User unknown] | ||||||||||||||||||||||||||||
| 55 | 21 | ▶ | if( $v->{'recipient'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | # There are multiple recipient addresses in the message body. | ||||||||||||||||||||||||||||
| 57 | 0 | push @$dscontents, __PACKAGE__->DELIVERYSTATUS; | |||||||||||||||||||||||||||
| 58 | 0 | $v = $dscontents->[-1]; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | 21 | my $p1 = index($e, ' '); | |||||||||||||||||||||||||||
| 61 | 21 | my $p2 = index($e, ']'); | |||||||||||||||||||||||||||
| 62 | 21 | $v->{'recipient'} = substr($e, 0, $p1); | |||||||||||||||||||||||||||
| 63 | 21 | $v->{'diagnosis'} = substr($e, $p1 + 2, $p2 - $p1 - 2); | |||||||||||||||||||||||||||
| 64 | 21 | $recipients++; | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | } elsif( index($e, $markingsof->{'message'}->[0]) == 0 ) { | ||||||||||||||||||||||||||||
| 67 | # The original message was received at Thu, 29 Apr 2010 23:34:45 +0900 (JST) | ||||||||||||||||||||||||||||
| 68 | 0 | $datestring = substr($e, length $markingsof->{'message'}->[0],); | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | 50 | ▶ | return undef unless $recipients; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 21 | ▶ | $_->{'date'} = $datestring || '' for @$dscontents; | ||||||||||||||||||||||||||
|
Condition50%1/2
$datestring || ''
MC/DC0%0/1
$datestring || ''
$datestring
Truth table50%1/2
A
A= $datestring
| |||||||||||||||||||||||||||||
| 74 | 21 | return {"ds" => $dscontents, "rfc822" => $emailparts->[1]}; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 35 | 1; | |||||||||||||||||||||||||||
| 78 | __END__ | ||||||||||||||||||||||||||||