-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #509 from sisimai/issue-508-alias
Get the alias address from the Received header of the original message
- Loading branch information
Showing
30 changed files
with
376 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -151,7 +151,6 @@ sub inquire { | |
my $readcursor = 0; # (Integer) Points the current cursor position | ||
my $nextcursor = 0; | ||
my $recipients = 0; # (Integer) The number of 'Final-Recipient' header | ||
my $localhost0 = ''; # (String) Local MTA | ||
my $boundary00 = ''; # (String) Boundary string | ||
my $v = undef; | ||
|
||
|
@@ -338,18 +337,13 @@ sub inquire { | |
} | ||
return undef unless $recipients; | ||
|
||
if( scalar $mhead->{'received'}->@* ) { | ||
# Get the name of local MTA | ||
# Received: from marutamachi.example.org (c192128.example.net [192.0.2.128]) | ||
$p1 = index($mhead->{'received'}->[-1], 'from '); | ||
$p2 = index($mhead->{'received'}->[-1], ' ', $p1 + 5); | ||
$localhost0 = substr($mhead->{'received'}->[-1], $p1 + 5, $p2 - $p1 - 5) if $p1 > -1 && $p2 > $p1; | ||
} | ||
# Get the name of the local MTA | ||
# Received: from marutamachi.example.org (c192128.example.net [192.0.2.128]) | ||
my $receivedby = $mhead->{'received'} || []; | ||
my $recvdtoken = Sisimai::RFC5322->received($receivedby->[-1]); | ||
|
||
for my $e ( @$dscontents ) { | ||
# Set default values if each value is empty. | ||
$e->{'lhost'} ||= $localhost0; | ||
|
||
# Check the error message, the rhost, the lhost, and the smtp command. | ||
if( ! $e->{'diagnosis'} && length($boundary00) > 0 ) { | ||
# Empty Diagnostic-Code: or error message | ||
# --NNNNNNNNNN-eximdsn-MMMMMMMMMM | ||
|
@@ -396,14 +390,10 @@ sub inquire { | |
# host neko.example.jp [192.0.2.222]: 550 5.1.1 <[email protected]>... User Unknown | ||
$p1 = index($e->{'diagnosis'}, 'host '); | ||
$p2 = index($e->{'diagnosis'}, ' ', $p1 + 5); | ||
$e->{'rhost'} = substr($e->{'diagnosis'}, $p1 + 5, $p2 - $p1 - 5) if $p1 > -1; | ||
|
||
if( ! $e->{'rhost'} && scalar $mhead->{'received'}->@* ) { | ||
# Get localhost and remote host name from Received header. | ||
my $r0 = $mhead->{'received'}; | ||
$e->{'rhost'} = pop Sisimai::RFC5322->received($r0->[-1])->@*; | ||
} | ||
$e->{'rhost'} = substr($e->{'diagnosis'}, $p1 + 5, $p2 - $p1 - 5) if $p1 > -1; | ||
$e->{'rhost'} ||= $recvdtoken->[1]; | ||
} | ||
$e->{'lhost'} ||= $recvdtoken->[0]; | ||
|
||
unless( $e->{'command'} ) { | ||
# Get the SMTP command name for the session | ||
|
@@ -539,7 +529,7 @@ azumakuniyuki | |
=head1 COPYRIGHT | ||
Copyright (C) 2014-2023 azumakuniyuki, All rights reserved. | ||
Copyright (C) 2014-2024 azumakuniyuki, All rights reserved. | ||
=head1 LICENSE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,10 +56,9 @@ sub inquire { | |
my @entiremesg = split(/\n\n/, $emailparts->[0], 5); pop @entiremesg; | ||
my $issuedcode = join(' ', @entiremesg); $issuedcode =~ y/\n/ /; | ||
my $receivedby = $mhead->{'received'} || []; | ||
$recordwide->{'diagnosis'} = Sisimai::String->sweep($issuedcode); | ||
|
||
my $serverlist = Sisimai::RFC5322->received($mhead->{'received'}->[0]); | ||
$recordwide->{'rhost'} = shift @$serverlist; | ||
$recordwide->{'rhost'} = Sisimai::RFC5322->received($receivedby->[0])->[1]; | ||
|
||
for my $e ( split(',', $mhead->{'x-failed-recipients'}) ) { | ||
# X-Failed-Recipients: [email protected], [email protected], ... | ||
|
@@ -115,7 +114,7 @@ azumakuniyuki | |
=head1 COPYRIGHT | ||
Copyright (C) 2020-2023 azumakuniyuki, All rights reserved. | ||
Copyright (C) 2020-2024 azumakuniyuki, All rights reserved. | ||
=head1 LICENSE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,7 +80,6 @@ sub inquire { | |
my $emailparts = Sisimai::RFC5322->part($mbody, $boundaries); | ||
my $readcursor = 0; # (Integer) Points the current cursor position | ||
my $recipients = 0; # (Integer) The number of 'Final-Recipient' header | ||
my $localhost0 = ''; # (String) Local MTA | ||
my $v = undef; | ||
|
||
for my $e ( split("\n", $emailparts->[0]) ) { | ||
|
@@ -126,20 +125,13 @@ sub inquire { | |
} | ||
return undef unless $recipients; | ||
|
||
if( scalar $mhead->{'received'}->@* ) { | ||
# Get the name of local MTA | ||
my $p1 = index(lc $mhead->{'received'}->[-1], 'from '); | ||
my $p2 = index( $mhead->{'received'}->[-1], ' ', $p1 + 5); | ||
|
||
if( ($p1 + 1) * ($p2 + 1) > 0 ) { | ||
# Received: from marutamachi.example.org (c192128.example.net [192.0.2.128]) | ||
$localhost0 = substr($mhead->{'received'}->[-1], $p1 + 5, $p2 - $p1 - 5); | ||
} | ||
} | ||
# Get the name of the local MTA | ||
# Received: from marutamachi.example.org (c192128.example.net [192.0.2.128]) | ||
my $receivedby = $mhead->{'received'} || []; | ||
my $recvdtoken = Sisimai::RFC5322->received($receivedby->[-1]); | ||
|
||
for my $e ( @$dscontents ) { | ||
# Set default values if each value is empty. | ||
$e->{'lhost'} ||= $localhost0; | ||
# Check the error message, the rhost, the lhost, and the smtp command. | ||
$e->{'diagnosis'} =~ s/[-]{2}.*\z//g; | ||
$e->{'diagnosis'} = Sisimai::String->sweep($e->{'diagnosis'}); | ||
|
||
|
@@ -149,13 +141,11 @@ sub inquire { | |
my $p2 = index($e->{'diagnosis'}, ' ', $p1 + 5); | ||
|
||
# host neko.example.jp [192.0.2.222]: 550 5.1.1 <[email protected]>... User Unknown | ||
$e->{'rhost'} = substr($e->{'diagnosis'}, $p1 + 5, $p2 - $p1 - 5) if $p1 > -1; | ||
|
||
unless( $e->{'rhost'} ) { | ||
# Get localhost and remote host name from Received header. | ||
$e->{'rhost'} = pop Sisimai::RFC5322->received($mhead->{'received'}->[-1])->@* if scalar $mhead->{'received'}->@*; | ||
} | ||
# Get the remote host name from the error message or the Received header. | ||
$e->{'rhost'} = substr($e->{'diagnosis'}, $p1 + 5, $p2 - $p1 - 5) if $p1 > -1; | ||
$e->{'rhost'} ||= $recvdtoken->[1]; | ||
} | ||
$e->{'lhost'} ||= $recvdtoken->[0]; | ||
|
||
unless( $e->{'command'} ) { | ||
# Get the SMTP command name for the session | ||
|
@@ -232,7 +222,7 @@ azumakuniyuki | |
=head1 COPYRIGHT | ||
Copyright (C) 2014-2023 azumakuniyuki, All rights reserved. | ||
Copyright (C) 2014-2024 azumakuniyuki, All rights reserved. | ||
=head1 LICENSE | ||
|
Oops, something went wrong.