exim

create ACL in exim deny senders but exclude localdomains


reading material on the internet, I found a way to block extensions (TLD) or e-mail accounts, it's an excellent option since I make the mail never get the antispam, so I save resources.

discard senders = /opt/exim/deny_senders message = your are blacklisted

Into the file deny_senders contain this:

*.ru *.online *.bid

In to the file /opt/exim/localdomains are the local domains of the server.

One of the local domains ends with the extension "bla.online" is it possible to create a rule to exclude the local?


Solution

  • You need to ensure that you have the line in your exim's config like that:
    acl_smtp_rcpt = acl_rcpt That directive declare that you want to filter out the messages on the RCPT stage. Then you have to find the exact part of config defined the ACL for RCPT and add this two rules:

    acl_rcpt:
    . . . . . 
    accept condition = ${lookup{\$sender_address}nwildlsearch{/path/to/white.list}{yes}}
    reject condition = ${lookup{\$sender_address}nwildlsearch{/path/to/black.list}{yes}}
           message = Go mail yourself you unsolicited sender!
    . . . . . 
    

    Those two conditions checks the sender address in the files containing regular expressions one per line like that:

    ## WHITE.LIST
    ^.*\.bla\.online
    

    and

    ## BLACK.LIST
    ^.*\.ru
    ^.*\.online
    ^.*\.bid
    

    Regular expressions should conform the PCRE syntax:
    ^ mean the beginning of line
    .* mean any sequence of any symbols
    \. mean the dot itself
    You have to place the whitelist above the blacklist because the ACL terminates on the first match. So more specific white regexps should be tested first. Also this two rules should be placed before any other rules that can accept messages for delivery.