| 1 | package Sisimai::Lhost::EinsUndEins; | ||||||||||||||||||||||||||||
| 2 | 38 | ▶ | use parent 'Sisimai::Lhost'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 38 | ▶ | use v5.26; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 38 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 38 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | # X-UI-Out-Filterresults: unknown:0; | ||||||||||||||||||||||||||||
| 8 | 1 | ▶ | sub description { '1&1: https://www.1und1.de/' } | ||||||||||||||||||||||||||
|
Subroutine
description: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 9 | 894 | ▶ | sub inquire { | ||||||||||||||||||||||||||
|
Subroutine
inquire: called CC=23 SCAR=31.9
Pod
documented
| |||||||||||||||||||||||||||||
| 10 | # Detect an error from 1&1 | ||||||||||||||||||||||||||||
| 11 | # @param [Hash] mhead Message headers of a bounce email | ||||||||||||||||||||||||||||
| 12 | # @param [String] mbody Message body of a bounce email | ||||||||||||||||||||||||||||
| 13 | # @return [Hash] Bounce data list and message/rfc822 part | ||||||||||||||||||||||||||||
| 14 | # @return [undef] failed to decodes or the arguments are missing | ||||||||||||||||||||||||||||
| 15 | # @since v4.1.9 | ||||||||||||||||||||||||||||
| 16 | 894 | my $class = shift; | |||||||||||||||||||||||||||
| 17 | 894 | ▶ | 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()
| |||||||||||||||||||||||||||||
| 18 | 893 | ▶ | 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()
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 892 | ▶ | return undef unless index($mhead->{'from'}, '"Mail Delivery System"') == 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | 32 | ▶ | return undef unless $mhead->{'subject'} eq 'Mail delivery failed: returning message to sender'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 17 | require Sisimai::Eb; | |||||||||||||||||||||||||||
| 24 | 17 | state $indicators = __PACKAGE__->INDICATORS; | |||||||||||||||||||||||||||
| 25 | 17 | state $boundaries = ['--- The header of the original message is following. ---']; | |||||||||||||||||||||||||||
| 26 | 17 | state $startingof = { | |||||||||||||||||||||||||||
| 27 | 'message' => ['This message was created automatically by mail delivery software'], | ||||||||||||||||||||||||||||
| 28 | 'error' => ['For the following reason:'], | ||||||||||||||||||||||||||||
| 29 | }; | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 17 | ▶ | 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)
| |||||||||||||||||||||||||||||
| 32 | 17 | my $dscontents = [__PACKAGE__->DELIVERYSTATUS]; my $v = undef; | |||||||||||||||||||||||||||
| 33 | 17 | my $readcursor = 0; # (Integer) Points the current cursor position | |||||||||||||||||||||||||||
| 34 | 17 | my $recipients = 0; # (Integer) The number of 'Final-Recipient' header | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 17 | for my $e ( split("\n", $emailparts->[0]) ) { | |||||||||||||||||||||||||||
| 37 | # Read error messages and delivery status lines from the head of the email to the previous | ||||||||||||||||||||||||||||
| 38 | # line of the beginning of the original message. | ||||||||||||||||||||||||||||
| 39 | 166 | ▶ | unless( $readcursor ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | # Beginning of the bounce message or message/delivery-status part | ||||||||||||||||||||||||||||
| 41 | 17 | ▶ | $readcursor |= $indicators->{'deliverystatus'} if index($e, $startingof->{'message'}->[0]) == 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | 17 | next; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | 149 | ▶ | 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 ""
| |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | # The following address failed: | ||||||||||||||||||||||||||||
| 47 | # | ||||||||||||||||||||||||||||
| 48 | # general@example.eu | ||||||||||||||||||||||||||||
| 49 | # | ||||||||||||||||||||||||||||
| 50 | # For the following reason: | ||||||||||||||||||||||||||||
| 51 | # | ||||||||||||||||||||||||||||
| 52 | # Mail size limit exceeded. For explanation visit | ||||||||||||||||||||||||||||
| 53 | # http://postmaster.1and1.com/en/error-messages?ip=%1s | ||||||||||||||||||||||||||||
| 54 | 97 | $v = $dscontents->[-1]; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 97 | ▶ | if( $e =~ /\A\s*([^ ]+[@][^ ]+?)[:]?\z/ ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 57 | # general@example.eu OR | ||||||||||||||||||||||||||||
| 58 | # the line begin with 4 space characters, end with ":" like " neko@example.eu:" | ||||||||||||||||||||||||||||
| 59 | 17 | ▶ | if( $v->{'recipient'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | # There are multiple recipient addresses in the message body. | ||||||||||||||||||||||||||||
| 61 | 0 | push @$dscontents, __PACKAGE__->DELIVERYSTATUS; | |||||||||||||||||||||||||||
| 62 | 0 | $v = $dscontents->[-1]; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | 17 | $v->{'recipient'} = Sisimai::Address->s3s4($e); | |||||||||||||||||||||||||||
| 65 | 17 | $recipients++; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | } elsif( index($e, $startingof->{'error'}->[0]) == 0 ) { | ||||||||||||||||||||||||||||
| 68 | # For the following reason: | ||||||||||||||||||||||||||||
| 69 | 6 | $v->{'diagnosis'} = $e; | |||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | } else { | ||||||||||||||||||||||||||||
| 72 | 74 | ▶ | if( length $v->{'diagnosis'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | # Get error message and append the error message strings | ||||||||||||||||||||||||||||
| 74 | 12 | $v->{'diagnosis'} .= ' '.$e; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | } else { | ||||||||||||||||||||||||||||
| 77 | # OR the following format: | ||||||||||||||||||||||||||||
| 78 | # neko@example.fr: | ||||||||||||||||||||||||||||
| 79 | # SMTP error from remote server for TEXT command, host: ... | ||||||||||||||||||||||||||||
| 80 | 62 | $v->{'alterrors'} .= ' '.$e; | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | 17 | ▶ | return undef unless $recipients; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 17 | require Sisimai::SMTP::Command; | |||||||||||||||||||||||||||
| 87 | 17 | for my $e ( @$dscontents ) { | |||||||||||||||||||||||||||
| 88 | 17 | ▶ | $e->{'diagnosis'} ||= $e->{'alterrors'} || ''; | ||||||||||||||||||||||||||
|
Condition60%3/5
$e->{"diagnosis"} ||= $e->{"alterrors"} || ""
$e->{'alterrors'} || ''
MC/DC0%0/2
$e->{"diagnosis"} ||= $e->{"alterrors"} || ""
$e->{"diagnosis"}
$e->{'alterrors'}
Truth table66%2/3
A ||= B
A= $e->{"diagnosis"}B= $e->{'alterrors'}
| |||||||||||||||||||||||||||||
| 89 | 17 | $e->{'command'} = Sisimai::SMTP::Command->find($e->{'diagnosis'}); | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 17 | ▶ | if( Sisimai::String->aligned(\$e->{'diagnosis'}, ['host: ', ' reason:']) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 92 | # SMTP error from remote server for TEXT command, | ||||||||||||||||||||||||||||
| 93 | # host: smtp-in.orange.fr (193.252.22.65) | ||||||||||||||||||||||||||||
| 94 | # reason: 550 5.2.0 Mail rejete. Mail rejected. ofr_506 [506] | ||||||||||||||||||||||||||||
| 95 | 11 | my $p1 = index($e->{'diagnosis'}, 'host: '); | |||||||||||||||||||||||||||
| 96 | 11 | my $p2 = index($e->{'diagnosis'}, ' reason:'); | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 11 | $e->{'rhost'} = substr($e->{'diagnosis'}, $p1 + 6, $p2 - $p1 - 6); | |||||||||||||||||||||||||||
| 99 | 11 | ▶ | $e->{'command'} = $Sisimai::Eb::CeDATA if index($e->{'diagnosis'}, 'for TEXT command') > -1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 100 | 11 | ▶ | $e->{'spec'} = 'SMTP' if index($e->{'diagnosis'}, 'SMTP error') > -1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 101 | 11 | $e->{'status'} = Sisimai::SMTP::Status->find($e->{'diagnosis'}); | |||||||||||||||||||||||||||
| 102 | } else { | ||||||||||||||||||||||||||||
| 103 | # For the following reason: | ||||||||||||||||||||||||||||
| 104 | 6 | substr($e->{'diagnosis'}, 0, length $startingof->{'error'}->[0], ''); | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | 17 | return {"ds" => $dscontents, "rfc822" => $emailparts->[1]}; | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 38 | 1; | |||||||||||||||||||||||||||
| 111 | __END__ | ||||||||||||||||||||||||||||