| 1 | package Sisimai::Lhost::Biglobe; | ||||||||||||||||||||||||||||
| 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 { 'BIGLOBE: https://www.biglobe.ne.jp' } | ||||||||||||||||||||||||||
|
Subroutine
description: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 8 | 914 | ▶ | sub inquire { | ||||||||||||||||||||||||||
|
Subroutine
inquire: called CC=19 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 9 | # Detect an error from Biglobe | ||||||||||||||||||||||||||||
| 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 | 914 | my $class = shift; | |||||||||||||||||||||||||||
| 16 | 914 | ▶ | 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 | 913 | ▶ | 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 | 912 | ▶ | return undef unless index($mhead->{'from'}, 'postmaster@') > -1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | 199 | ▶ | return undef unless grep { index($mhead->{'from'}, '@'.$_.'.ne.jp') > -1 } (qw|biglobe inacatv tmtv ttv|); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 6 | ▶ | return undef unless index($mhead->{'subject'}, 'Returned mail:') == 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 6 | state $indicators = __PACKAGE__->INDICATORS; | |||||||||||||||||||||||||||
| 24 | 6 | state $boundaries = ['Content-Type: message/rfc822']; | |||||||||||||||||||||||||||
| 25 | 6 | state $startingof = { | |||||||||||||||||||||||||||
| 26 | 'message' => [' ----- The following addresses had delivery problems -----'], | ||||||||||||||||||||||||||||
| 27 | 'error' => [' ----- Non-delivered information -----'], | ||||||||||||||||||||||||||||
| 28 | }; | ||||||||||||||||||||||||||||
| 29 | 6 | ▶ | 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 | 6 | my $dscontents = [__PACKAGE__->DELIVERYSTATUS]; my $v = undef; | |||||||||||||||||||||||||||
| 31 | 6 | my $readcursor = 0; # (Integer) Points the current cursor position | |||||||||||||||||||||||||||
| 32 | 6 | my $recipients = 0; # (Integer) The number of 'Final-Recipient' header | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 6 | for my $e ( split("\n", $emailparts->[0]) ) { | |||||||||||||||||||||||||||
| 35 | # Read error messages and delivery status lines from the head of the email to the previous | ||||||||||||||||||||||||||||
| 36 | # line of the beginning of the original message. | ||||||||||||||||||||||||||||
| 37 | 42 | ▶ | unless( $readcursor ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | # Beginning of the bounce message or message/delivery-status part | ||||||||||||||||||||||||||||
| 39 | 18 | ▶ | $readcursor |= $indicators->{'deliverystatus'} if index($e, $startingof->{'message'}->[0]) == 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 18 | next; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | 24 | ▶ | 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 ""
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | # This is a MIME-encapsulated message. | ||||||||||||||||||||||||||||
| 45 | # | ||||||||||||||||||||||||||||
| 46 | # ----_Biglobe000000/00000.biglobe.ne.jp | ||||||||||||||||||||||||||||
| 47 | # Content-Type: text/plain; charset="iso-2022-jp" | ||||||||||||||||||||||||||||
| 48 | # | ||||||||||||||||||||||||||||
| 49 | # ----- The following addresses had delivery problems ----- | ||||||||||||||||||||||||||||
| 50 | # ********@***.biglobe.ne.jp | ||||||||||||||||||||||||||||
| 51 | # | ||||||||||||||||||||||||||||
| 52 | # ----- Non-delivered information ----- | ||||||||||||||||||||||||||||
| 53 | # The number of messages in recipient's mailbox exceeded the local limit. | ||||||||||||||||||||||||||||
| 54 | # | ||||||||||||||||||||||||||||
| 55 | # ----_Biglobe000000/00000.biglobe.ne.jp | ||||||||||||||||||||||||||||
| 56 | # Content-Type: message/rfc822 | ||||||||||||||||||||||||||||
| 57 | # | ||||||||||||||||||||||||||||
| 58 | 18 | $v = $dscontents->[-1]; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 18 | ▶ | 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
| |||||||||||||||||||||||||||||
| 61 | # ----- The following addresses had delivery problems ----- | ||||||||||||||||||||||||||||
| 62 | # ********@***.biglobe.ne.jp | ||||||||||||||||||||||||||||
| 63 | 6 | ▶ | if( $v->{'recipient'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | # There are multiple recipient addresses in the message body. | ||||||||||||||||||||||||||||
| 65 | 0 | push @$dscontents, __PACKAGE__->DELIVERYSTATUS; | |||||||||||||||||||||||||||
| 66 | 0 | $v = $dscontents->[-1]; | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | 6 | ▶ | next unless Sisimai::Address->is_emailaddress($e); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | 6 | $v->{'recipient'} = $e; | |||||||||||||||||||||||||||
| 70 | 6 | $recipients++; | |||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | } else { | ||||||||||||||||||||||||||||
| 73 | 12 | ▶ | next if index($e, '--') > -1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | 6 | $v->{'diagnosis'} .= $e.' '; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | 6 | ▶ | return undef unless $recipients; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | 6 | return {"ds" => $dscontents, "rfc822" => $emailparts->[1]}; | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 36 | 1; | |||||||||||||||||||||||||||
| 82 | __END__ | ||||||||||||||||||||||||||||