I am using Exim version 4.91. How do I configure it to block outbound emails except for few domains?

Basically, the mail server should only send emails to users on example.com, example.net & example.org. Emails to any other domains have to be blocked.


Add a stanza to the beginning of the routers section (order is important, as the first router to match is used):

  driver = redirect
  domains = ! example.com : ! example.net : ! example.org
  data = :fail: Mailing is only allowed to example.com, example.net and example.org

This router will match other domains than those listed due to the negation exclamation marks, the data :fail: tag indicates that this is a failure.

The no_more directive stops exim trying other routers for the matched domains.

| improve this answer | |
  • 1
    The slightly better approach is to place the restriction into the ACL like acl_rcpt to prevent any further proceeding. Also negation by exclamation mark can be moved to the left like !domains = a : b : c. – Kondybas Sep 10 '18 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.