Last active
February 15, 2020 23:09
-
-
Save mallardduck/2daa41ce6c591aa898de10c947c80c1e to your computer and use it in GitHub Desktop.
An Exim System Filter to create a Domain Jail for Emails
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
# Block example.com from sending to any other domain | |
if first_delivery | |
and ("$h_from:" contains "@example.com") | |
and ("$h_to:" matches "@(?!example.com)[a-z0-9_.]+") | |
or ("$h_cc:" matches "@(?!example.com)[a-z0-9_.]+") | |
or ("$h_bcc:" matches "@(?!example.com)[a-z0-9_.]+") | |
then | |
headers add "X-Org-Subject: $h_subject" | |
headers remove Subject | |
headers add "Subject: EmailJail'd: $h_x-org-subject" | |
headers add "X-EmailJail: This domain is under an Email Jail and cannot send mail to external domains." | |
seen fail "Your domain is under an Email Jail. This means you cannot send emails to external domains." | |
endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
UPDATE: Fixed in Rev 3.
This has a flaw when sending to multiple to addresses - if a single address has our domain, then it will send to all TO addresses.
Not sure how to fix or improve this...
https://gist.github.com/mallardduck/2daa41ce6c591aa898de10c947c80c1e#file-email_jail-L6