| 1 | package Sisimai::Lhost::KDDI; | ||||||||||||||||||||||||||||||||||||||
| 2 | 41 | ▶ | use parent 'Sisimai::Lhost'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 3 | 41 | ▶ | use v5.26; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 4 | 41 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 5 | 41 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | sub description { 'au by KDDI: https://www.au.kddi.com' } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
description: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 8 | 914 | ▶ | sub inquire { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
inquire: called CC=31 SCAR=37.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 9 | # Detect an error from au by KDDI | ||||||||||||||||||||||||||||||||||||||
| 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 | 912 | ▶ | my $match = 0; $match ||= 1 if Sisimai::String->aligned(\$mhead->{'from'}, ['no-reply@.', '.dion.ne.jp']); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$match ||= 1
MC/DC0%0/1
$match ||= 1
$match
Truth table0%0/2
A
A= $match
| |||||||||||||||||||||||||||||||||||||||
| 19 | 912 | ▶ | $match ||= 1 if $mhead->{'reply-to'} && $mhead->{'reply-to'} eq 'no-reply@app.auone-net.jp'; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
$mhead->{"reply-to"} and $mhead->{"reply-to"} eq "no-reply\@app.auone-net.jp"
$match ||= 1
MC/DC100%2/2
$mhead->{"reply-to"} and $mhead->{"reply-to"} eq "no-reply\@app.auone-net.jp"
$mhead->{"reply-to"}
$mhead->{"reply-to"} eq "no-reply\@app.auone-net.jp"
MC/DC0%0/1
$match ||= 1
$match
Truth table100%3/3
A and B
A= $mhead->{"reply-to"}B= $mhead->{"reply-to"} eq "no-reply\@app.auone-net.jp"
Truth table50%1/2
A
A= $match
| |||||||||||||||||||||||||||||||||||||||
| 20 | 912 | ▶ | $match ||= 1 if grep { rindex($_, 'ezweb.ne.jp (') > -1 } $mhead->{'received'}->@*; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$match ||= 1
MC/DC0%0/1
$match ||= 1
$match
Truth table0%0/2
A
A= $match
| |||||||||||||||||||||||||||||||||||||||
| 21 | 912 | ▶ | $match ||= 1 if grep { rindex($_, '.au.com (') > -1 } $mhead->{'received'}->@*; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$match ||= 1
MC/DC0%0/1
$match ||= 1
$match
Truth table0%0/2
A
A= $match
| |||||||||||||||||||||||||||||||||||||||
| 22 | 912 | ▶ | return undef unless $match; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||
| 24 | 16 | state $indicators = __PACKAGE__->INDICATORS; | |||||||||||||||||||||||||||||||||||||
| 25 | 16 | state $boundaries = ['Content-Type: message/rfc822']; | |||||||||||||||||||||||||||||||||||||
| 26 | 16 | state $startingof = {'message' => ['Your mail sent on:', 'Your mail attempted to be delivered on:']}; | |||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||
| 28 | 16 | ▶ | 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)
| |||||||||||||||||||||||||||||||||||||||
| 29 | 16 | my $dscontents = [__PACKAGE__->DELIVERYSTATUS]; my $v = undef; | |||||||||||||||||||||||||||||||||||||
| 30 | 16 | my $readcursor = 0; # (Integer) Points the current cursor position | |||||||||||||||||||||||||||||||||||||
| 31 | 16 | my $recipients = 0; # (Integer) The number of 'Final-Recipient' header | |||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||
| 33 | 16 | for my $e ( split("\n", $emailparts->[0]) ) { | |||||||||||||||||||||||||||||||||||||
| 34 | # Read error messages and delivery status lines from the head of the email to the previous | ||||||||||||||||||||||||||||||||||||||
| 35 | # line of the beginning of the original message. | ||||||||||||||||||||||||||||||||||||||
| 36 | 138 | ▶ | unless( $readcursor ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 37 | # Beginning of the bounce message or message/delivery-status part | ||||||||||||||||||||||||||||||||||||||
| 38 | 106 | ▶ | $readcursor |= $indicators->{'deliverystatus'} if grep { index($e, $_) == 0 } $startingof->{'message'}->@*; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||
| 40 | 138 | ▶ | 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 | 48 | $v = $dscontents->[-1]; | |||||||||||||||||||||||||||||||||||||
| 43 | 48 | ▶ | if( index($e, ' Could not be delivered to: <') > -1 ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 44 | # Your mail sent on: Thu, 29 Apr 2010 11:04:47 +0900 | ||||||||||||||||||||||||||||||||||||||
| 45 | # Could not be delivered to: <******@**.***.**> | ||||||||||||||||||||||||||||||||||||||
| 46 | # As their mailbox is full. | ||||||||||||||||||||||||||||||||||||||
| 47 | 16 | ▶ | if( $v->{'recipient'} ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 48 | # There are multiple recipient addresses in the message body. | ||||||||||||||||||||||||||||||||||||||
| 49 | 0 | push @$dscontents, __PACKAGE__->DELIVERYSTATUS; | |||||||||||||||||||||||||||||||||||||
| 50 | 0 | $v = $dscontents->[-1]; | |||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||
| 53 | 16 | my $r = Sisimai::Address->s3s4(substr($e, index($e, '<') + 1, )); | |||||||||||||||||||||||||||||||||||||
| 54 | 16 | ▶ | next unless Sisimai::Address->is_emailaddress($r); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 55 | 16 | $v->{'recipient'} = $r; | |||||||||||||||||||||||||||||||||||||
| 56 | 16 | $recipients++; | |||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||
| 58 | } elsif( index($e, 'Your mail sent on: ') > -1 ) { | ||||||||||||||||||||||||||||||||||||||
| 59 | # Your mail sent on: Thu, 29 Apr 2010 11:04:47 +0900 | ||||||||||||||||||||||||||||||||||||||
| 60 | 16 | $v->{'date'} = substr($e, 19, ); | |||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||
| 62 | } else { | ||||||||||||||||||||||||||||||||||||||
| 63 | # As their mailbox is full. | ||||||||||||||||||||||||||||||||||||||
| 64 | 16 | ▶ | $v->{'diagnosis'} .= $e.' ' if index($e, ' ') == 0; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||
| 67 | 16 | ▶ | return undef unless $recipients; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||
| 69 | 16 | require Sisimai::Eb; | |||||||||||||||||||||||||||||||||||||
| 70 | 16 | require Sisimai::SMTP::Command; | |||||||||||||||||||||||||||||||||||||
| 71 | 16 | for my $e ( @$dscontents ) { | |||||||||||||||||||||||||||||||||||||
| 72 | 16 | ▶ | $e->{'command'} = Sisimai::SMTP::Command->find($e->{'diagnosis'}) || ''; | ||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
'Sisimai::SMTP::Command'->find($e->{'diagnosis'}) || ''
MC/DC0%0/1
'Sisimai::SMTP::Command'->find($e->{'diagnosis'}) || ''
'Sisimai::SMTP::Command'->find($e->{'diagnosis'})
Truth table50%1/2
A
A= 'Sisimai::SMTP::Command'->find($e->{'diagnosis'})
| |||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||
| 74 | 16 | ▶ | if( defined $mhead->{'x-spasign'} && $mhead->{'x-spasign'} eq 'NG' ) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $mhead->{"x-spasign"} and $mhead->{"x-spasign"} eq "NG"
MC/DC0%0/2
defined $mhead->{"x-spasign"} and $mhead->{"x-spasign"} eq "NG"
defined $mhead->{"x-spasign"}
$mhead->{"x-spasign"} eq "NG"
Truth table33%1/3
A and B
A= defined $mhead->{"x-spasign"}B= $mhead->{"x-spasign"} eq "NG"
| |||||||||||||||||||||||||||||||||||||||
| 75 | # Content-Type: text/plain; ..., X-SPASIGN: NG (spamghetti, au by KDDI) | ||||||||||||||||||||||||||||||||||||||
| 76 | # Filtered recipient returns message that include 'X-SPASIGN' header | ||||||||||||||||||||||||||||||||||||||
| 77 | 0 | $e->{'reason'} = $Sisimai::Eb::ReFILT; | |||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||
| 79 | } else { | ||||||||||||||||||||||||||||||||||||||
| 80 | # There is no X-SPASIGN: header in the bounce message | ||||||||||||||||||||||||||||||||||||||
| 81 | # set "UserUnknown" when the remote server rejected after RCPT command. | ||||||||||||||||||||||||||||||||||||||
| 82 | 16 | ▶ | $e->{'reason'} = $Sisimai::Eb::ReUSER if $e->{'command'} eq $Sisimai::Eb::CeRCPT; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||
| 85 | 16 | return {"ds" => $dscontents, "rfc822" => $emailparts->[1]}; | |||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||
| 88 | 41 | 1; | |||||||||||||||||||||||||||||||||||||
| 89 | __END__ | ||||||||||||||||||||||||||||||||||||||