From 74a7ed654369cb3ebd282c01d4a0de87a646c4ce Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Wed, 8 Mar 2017 14:13:48 +0000 Subject: Use sender in From if From and To domains match. To deal with a recipient mail server not allowing inbound email using the same domain as an internal domain, e.g. https://community.mimecast.com/docs/DOC-1419 --- perllib/Utils/Email.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'perllib/Utils/Email.pm') diff --git a/perllib/Utils/Email.pm b/perllib/Utils/Email.pm index a30e41c61..5e3df0205 100644 --- a/perllib/Utils/Email.pm +++ b/perllib/Utils/Email.pm @@ -34,4 +34,16 @@ sub _send { return grep { $_->type eq $type } @answers; } +sub same_domain { + my ($email, $list) = @_; + my $addr = (Email::Address->parse($email->[0]))[0]; + return unless $addr; + my $domain = $addr->host; + foreach (@$list) { + my $addr = (Email::Address->parse($_->[0]))[0]; + next unless $addr; + return 1 if $domain eq $addr->host; + } +} + 1; -- cgit v1.2.3