Help Center

Exim: Exclude sender & receiver domains from routing through MailChannels Cloud

It might be necessary to exclude certain sender and receiver domains from being routed through MailChannels Cloud. This article lays down the procedure to implement this using a file that contains the list of domains. 

Excluding Specific Receiver Domains
(Exim version 4.89 instructions only - Click here)

1) Create a file /etc/excludereceiverdomains.

Include all the domains to exclude in this file in the following format

example.com:

2)Add the following line in Section: CONFIG configuration box:

domainlist exclude_receiver_domains = lsearch;/etc/excludereceiverdomains

3) Add the following lines in Section: ROUTERSTART configuration box:

domains = !+exclude_receiver_domains: !+local_domains

senders = !*@+exclude_sender_domains

Following is an example of how this will appear in the configuration file:

send_via_mailchannels:
driver = manualroute
domains = !+exclude_receiver_domains: !+local_domains
senders = !*@+exclude_sender_domains
transport = mailchannels_smtp
route_list = "* smtp.mailchannels.net::25 byname"
host_find_failed = defer
no_more

4) Once you have completed and saved all changes to Exim’s configuration files, you will need to restart it to activate those changes using the following command:

$ /etc/init.d/exim4 restart

Excluding Specific Sender Domains

1) Create a file /etc/excludesenderdomains.

Include all the domains to exclude in this file in the following format:

domain1.tld
domain2.tld
domain3.tld

2)Add the following line in Section: CONFIG configuration box:

domainlist exclude_sender_domains = lsearch;/etc/excludesenderdomains

3) Add the following line in Section: ROUTERSTART configuration box:

senders = !*@+exclude_sender_domains

Following is an example of how this will appear in the configuration file:

send_via_mailchannels:
driver = manualroute
domains = ! +local_domains
senders = !*@+exclude_sender_domains
transport = mailchannels_smtp
route_list = "* smtp.mailchannels.net::25 byname"
host_find_failed = defer
no_more

4) Once you have completed and saved all changes to Exim’s configuration files, you will need to restart it to activate those changes using the following command:

$ /etc/init.d/exim4 restart

Excluding Specific Sender Domains for Exim version 4.89

It has also come to our attention that the above method is not effective in the case of Exim version 4.89. For this version of Exim, please make use of the following option to exclude domains instead of using "/etc/excludesenderdomains" from step 1 and 2 above.
1) Add the following line in Section: ROUTERSTART configuration box:

senders = !: !*@domain1.tld : !*@domain2.tld

The following is an example of how this will appear in the configuration file:

send_via_mailchannels:
driver = manualroute
domains = ! +local_domains
senders = !: !*@domain1.tld : !*@domain2.tld
transport = mailchannels_smtp
route_list = "* smtp.mailchannels.net::25 byname"
host_find_failed = defer
no_more

2) Once you have completed and saved all changes to Exim’s configuration files, you will need to restart it to activate those changes using the following command:

$ /etc/init.d/exim4 restart

 

Excluding Mailer-Daemon mails from Relay

Update the following line in Section: ROUTERSTART configuration box:

senders = !: !^mailer-daemon@.* 

Was this article helpful?
1 out of 1 found this helpful
Have more questions? Submit a request

Comments

  • Avatar
    Eric Merkel

    I believe you have an error where you refer to "exclude_receivER_domains" and then reference "exclude_receivING_domains". They should both be the same.

    Secondly, I believe the "senders =" line is expect an address list and not a domain list. I get the following error in my exim log after trying this: "unknown named address list "+exclude_sender_domains""

    Eric

  • Avatar
    Sridhar Kakkillaya

    Hello Eric,

    Thanks for pointing out the error. It has been corrected.

    As for the second point, have you created the entry
    domainlist exclude_sender_domains = lsearch;/etc/excludesenderdomains

    Sender references this domain list.

  • Avatar
    Eric Merkel

    Yes, I did create the file /etc/excludesenderdomains and the domainlist exclude_sender_domains = lsearch;/etc/excludesenderdomains in the global config but from what I can read the error message is telling me that exim is looking for a sender list not a domain list.

    I have tried the following in the file.

    domain.com:

    or making it a sender I formatted it as follows:

    *@domain.com:

    Neither seemed to work but when I get more time I will attempt it again.

    Eric

  • Avatar
    Veeble Softtech

    excludesenderdomains is loaded as domainlist. So, it needs to be included in senders section as domainlist and not as addresslist which is done above.
    The correct code is

    sendviamailchannels:
    driver = manualroute
    domains = ! +localdomains
    senders = !@+exclude{underscore}sender{underscore}domains
    transport = mailchannelssmtp
    routelist = "
    smtp.mailchannels.net::25 byname"
    hostfindfailed = defer
    nomore

    Please replace {underscore} with its symbol. As this commenting system is removing underscore symbol, I have labelled it in this way. You need to enter the domains to be excluded in the file /etc/excludereceiverdomains in the following format

    domain1.tld
    domain2.tld
    domain3.tld

    Ashwin
    Veeble

  • Avatar
    Adam Paxton

    The syntax has been corrected under Excluding sender domains. Thank you for the correction in comments Ashwin!

  • Avatar
    Martins Jakubovics

    senders = !@+exclude_sender_domains

    Is not working for me. Exim version 4.86

  • Avatar
    Josh Loe

    There is an error in this.

    It should be:
    senders = !*@+exclude_sender_domains

    Tested and working now on Exim 4.87

Please sign in to leave a comment.

Powered by Zendesk