| 1 | package Sisimai::Lhost::EZweb; | ||||||||||||||||||||||||||||||||||||||||||||||
| 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 { 'au EZweb: https://www.au.com/mobile/' } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
description: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 908 | ▶ | sub inquire { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inquire: called CC=39 SCAR=37.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # Detect an error from EZweb | ||||||||||||||||||||||||||||||||||||||||||||||
| 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 | 908 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 16 | 908 | ▶ | 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 | 907 | ▶ | 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 | # Pre-process email headers of NON-STANDARD bounce message au by EZweb, as known as ezweb.ne.jp. | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # Subject: Mail System Error - Returned Mail | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # From: <Postmaster@ezweb.ne.jp> | ||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # Received: from ezweb.ne.jp (wmflb12na02.ezweb.ne.jp [222.15.69.197]) | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # Received: from nmomta.auone-net.jp ([aaa.bbb.ccc.ddd]) by ... | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 906 | ▶ | my $match = 0; $match++ if rindex($mhead->{'from'}, 'Postmaster@ezweb.ne.jp') > -1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 906 | ▶ | $match++ if rindex($mhead->{'from'}, 'Postmaster@au.com') > -1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 906 | ▶ | $match++ if $mhead->{'subject'} eq 'Mail System Error - Returned Mail'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 906 | ▶ | $match++ if grep { rindex($_, 'ezweb.ne.jp (EZweb Mail) with') > -1 } $mhead->{'received'}->@*; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 906 | ▶ | $match++ if grep { rindex($_, '.au.com (') > -1 } $mhead->{'received'}->@*; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 906 | ▶ | if( defined $mhead->{'message-id'} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 844 | ▶ | $match++ if substr($mhead->{'message-id'}, -13, 13) eq '.ezweb.ne.jp>'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 844 | ▶ | $match++ if substr($mhead->{'message-id'}, -8, 8) eq '.au.com>'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 906 | ▶ | return undef if $match < 2; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 41 | require Sisimai::Eb; | |||||||||||||||||||||||||||||||||||||||||||||
| 36 | 41 | require Sisimai::SMTP::Command; | |||||||||||||||||||||||||||||||||||||||||||||
| 37 | 41 | state $indicators = __PACKAGE__->INDICATORS; | |||||||||||||||||||||||||||||||||||||||||||||
| 38 | 41 | state $boundaries = ["--------------------------------------------------", "Content-Type: message/rfc822"]; | |||||||||||||||||||||||||||||||||||||||||||||
| 39 | 41 | state $startingof = {"message" => ['The user(s) ', 'Your message ', 'Each of the following', '<']}; | |||||||||||||||||||||||||||||||||||||||||||||
| 40 | 41 | state $unpaiduser = [ | |||||||||||||||||||||||||||||||||||||||||||||
| 41 | # http://www.naruhodo-au.kddi.com/qa3429203.html | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # The recipient may be unpaid user...? | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | "The user(s) account is disabled.", | ||||||||||||||||||||||||||||||||||||||||||||||
| 44 | "The user(s) account is temporarily limited.", | ||||||||||||||||||||||||||||||||||||||||||||||
| 45 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 41 | ▶ | 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)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 41 | my $fieldtable = Sisimai::RFC1894->FIELDTABLE; | |||||||||||||||||||||||||||||||||||||||||||||
| 49 | 41 | my $dscontents = [__PACKAGE__->DELIVERYSTATUS]; my $v = undef; | |||||||||||||||||||||||||||||||||||||||||||||
| 50 | 41 | my $readcursor = 0; # Points the current cursor position | |||||||||||||||||||||||||||||||||||||||||||||
| 51 | 41 | my $recipients = 0; # The number of 'Final-Recipient' header | |||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 41 | for my $e ( split("\n", $emailparts->[0]) ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 54 | # Read error messages and delivery status lines from the head of the email to the previous | ||||||||||||||||||||||||||||||||||||||||||||||
| 55 | # line of the beginning of the original message. | ||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 533 | ▶ | unless( $readcursor ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | # Beginning of the bounce message or message/delivery-status part | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 301 | ▶ | $readcursor |= $indicators->{'deliverystatus'} if grep { index($e, $_) > -1 } $startingof->{'message'}->@*; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 533 | ▶ | next if ($readcursor & $indicators->{'deliverystatus'}) == 0 || $e eq ""; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
($readcursor & $indicators->{"deliverystatus"}) == 0 or $e eq ""
MC/DC100%2/2
($readcursor & $indicators->{"deliverystatus"}) == 0 or $e eq ""
($readcursor & $indicators->{"deliverystatus"}) == 0
$e eq ""
Truth table100%3/3
A or B
A= ($readcursor & $indicators->{"deliverystatus"}) == 0B= $e eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # The user(s) account is disabled. | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | # <***@ezweb.ne.jp>: 550 user unknown (in reply to RCPT TO command) | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # -- OR -- | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # Each of the following recipients was rejected by a remote | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | # mail server. | ||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # | ||||||||||||||||||||||||||||||||||||||||||||||
| 70 | # Recipient: <******@ezweb.ne.jp> | ||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # >>> RCPT TO:<******@ezweb.ne.jp> | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # <<< 550 <******@ezweb.ne.jp>: User unknown | ||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 197 | $v = $dscontents->[-1]; | |||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 197 | ▶ | if( Sisimai::String->aligned(\$e, ['<', '@', '>']) && (index($e, 'Recipient: <') > 1 || index($e, '<') == 0) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%6/6
"Sisimai::String"->aligned(\$e, ["<", "\@", ">"]) and index($e, "Recipient: <") > 1 || index($e, "<") == 0
index($e, "Recipient: <") > 1 or index($e, "<") == 0
MC/DC100%3/3
"Sisimai::String"->aligned(\$e, ["<", "\@", ">"]) and index($e, "Recipient: <") > 1 || index($e, "<") == 0
"Sisimai::String"->aligned(\$e, ["<", "\@", ">"])
index($e, "Recipient: <") > 1
index($e, "<") == 0
Truth table100%4/4
A and B or C
A= "Sisimai::String"->aligned(\$e, ["<", "\@", ">"])B= index($e, "Recipient: <") > 1C= index($e, "<") == 0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | # Recipient: <******@ezweb.ne.jp> OR <***@ezweb.ne.jp>: 550 user unknown ... | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 41 | my $p1 = index($e, '<'); | |||||||||||||||||||||||||||||||||||||||||||||
| 78 | 41 | my $p2 = index($e, '>'); | |||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 41 | ▶ | if( $v->{'recipient'} ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # There are multiple recipient addresses in the message body. | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | push @$dscontents, __PACKAGE__->DELIVERYSTATUS; | |||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | $v = $dscontents->[-1]; | |||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 41 | $v->{'recipient'} = Sisimai::Address->s3s4(substr($e, $p1, $p2 - $p1)); | |||||||||||||||||||||||||||||||||||||||||||||
| 86 | 41 | $v->{"diagnosis"} .= " ".$e; | |||||||||||||||||||||||||||||||||||||||||||||
| 87 | 41 | $recipients++; | |||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } elsif( my $f = Sisimai::RFC1894->match($e) ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # $e matched with any field defined in RFC3464 | ||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 50 | ▶ | next unless my $o = Sisimai::RFC1894->field($e); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 50 | ▶ | next unless exists $fieldtable->{ $o->[0] }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 50 | $v->{ $fieldtable->{ $o->[0] } } = $o->[2]; | |||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 96 | # The line does not begin with a DSN field defined in RFC3464 | ||||||||||||||||||||||||||||||||||||||||||||||
| 97 | # >>> RCPT TO:<******@ezweb.ne.jp> | ||||||||||||||||||||||||||||||||||||||||||||||
| 98 | # <<< 550 ... | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 106 | ▶ | next if Sisimai::String->is_8bit(\$e); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 106 | ▶ | $v->{"command"} = Sisimai::SMTP::Command->find($e) if index($e, " >>> ") > -1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 106 | $v->{"diagnosis"} .= " ".$e; | |||||||||||||||||||||||||||||||||||||||||||||
| 102 | } # End of error message part | ||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 41 | ▶ | return undef unless $recipients; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 41 | for my $e ( @$dscontents ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 107 | # Check each value of DeliveryMatter{}, try to detect the bounce reason. | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 41 | $e->{'diagnosis'} = Sisimai::String->sweep($e->{'diagnosis'}); | |||||||||||||||||||||||||||||||||||||||||||||
| 109 | 41 | ▶ | $e->{"command"} ||= Sisimai::SMTP::Command->find($e->{"diagnosis"}) || ""; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%5/5
$e->{"command"} ||= "Sisimai::SMTP::Command"->find($e->{"diagnosis"}) || ""
'Sisimai::SMTP::Command'->find($e->{'diagnosis'}) || ''
MC/DC100%2/2
$e->{"command"} ||= "Sisimai::SMTP::Command"->find($e->{"diagnosis"}) || ""
$e->{"command"}
'Sisimai::SMTP::Command'->find($e->{'diagnosis'})
Truth table100%3/3
A ||= B
A= $e->{"command"}B= 'Sisimai::SMTP::Command'->find($e->{'diagnosis'})
| |||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 41 | ▶ | if( defined $mhead->{'x-spasign'} && $mhead->{'x-spasign'} eq 'NG' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $mhead->{"x-spasign"} and $mhead->{"x-spasign"} eq "NG"
MC/DC50%1/2
defined $mhead->{"x-spasign"} and $mhead->{"x-spasign"} eq "NG"
defined $mhead->{"x-spasign"}
$mhead->{"x-spasign"} eq "NG"
Truth table66%2/3
A and B
A= defined $mhead->{"x-spasign"}B= $mhead->{"x-spasign"} eq "NG"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | # Content-Type: text/plain; ..., X-SPASIGN: NG (spamghetti, au by EZweb) | ||||||||||||||||||||||||||||||||||||||||||||||
| 113 | # Filtered recipient returns message that include 'X-SPASIGN' header | ||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 6 | $e->{'reason'} = $Sisimai::Eb::ReFILT; | |||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 117 | # There is no X-SPASIGN header or the value of the header is not "NG" | ||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 35 | ▶ | $e->{'reason'} = $Sisimai::Eb::ReQUIT if grep { index($e->{'diagnosis'}, $_) > -1 } $unpaiduser->@*; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 41 | ▶ | next if $e->{'reason'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 20 | ▶ | next if index($e->{'recipient'}, '@ezweb.ne.jp') > 1 || index($e->{'recipient'}, '@au.com') > 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
index($e->{"recipient"}, "\@ezweb.ne.jp") > 1 or index($e->{"recipient"}, "\@au.com") > 1
MC/DC50%1/2
index($e->{"recipient"}, "\@ezweb.ne.jp") > 1 or index($e->{"recipient"}, "\@au.com") > 1
index($e->{"recipient"}, "\@ezweb.ne.jp") > 1
index($e->{"recipient"}, "\@au.com") > 1
Truth table66%2/3
A or B
A= index($e->{"recipient"}, "\@ezweb.ne.jp") > 1B= index($e->{"recipient"}, "\@au.com") > 1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 5 | ▶ | $e->{"reason"} = $Sisimai::Eb::ReUSER if index($e->{"diagnosis"}, "<") == 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 41 | return {"ds" => $dscontents, "rfc822" => $emailparts->[1]}; | |||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 36 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 128 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||