aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/Utils
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2017-03-08 14:13:48 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2017-03-14 15:36:27 +0000
commit74a7ed654369cb3ebd282c01d4a0de87a646c4ce (patch)
tree27e5e8090d8a1e3be4e69b9d5344e9fa67ee1b6a /perllib/Utils
parent7361516252a4d98620f66318cabe75acb3291efb (diff)
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
Diffstat (limited to 'perllib/Utils')
-rw-r--r--perllib/Utils/Email.pm12
1 files changed, 12 insertions, 0 deletions
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;