Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to route all incoming emails for local domains only to a single account if an account is not setup for that user.

I would also like each email to be written in it's own file in user folder.

I have a catchall user with /home/catchall/ path where I have a mail folder made for this but so far emails wither fail to deliver (thus my rule did not work) or they do deliver to /etc/mail/catchall file.

I have been trying to put something together from the Exim configuration but so far nothing seem to work.

share|improve this question
OK thankfully I have found the exim -bt and thus found a way to test each atempt faster. I have figured out how to catchall now I just need to write each email to a separate file. – transilvlad Nov 13 '12 at 16:40
up vote 1 down vote accepted

Setting Exim to catch all email sent to local domains:


begin routers


  driver = redirect
  domains = +local_domains
  user = catchall
  data = catchall@localhost

This will enable a catch all for all local_domains. They are set like this:

domainlist local_domains = @ : localhost : localhost.localdomain :

Note: you can simply specify to catch a single domain and make multiple rules for multiple domains.

In order to configure Exim to create individual files for each email you just simply have to switch the local delivery to directory mode like this:


  driver = appendfile
  file = /var/mail/$local_part
  group = mail
  mode = 0660

Add in place of file = /var/mail/$local_part:

  directory = $home/mail

Note: This will automatically create a nice mail directory in user's home folder when he receives his first email. The structure is the well known cur/, new/, tmp/ one.

share|improve this answer

Not so clear what do you really want saying "each email to be written in it's own file"

If you've use maildir format, all messages stored in seperate files anyway. Just add special router AFTER all existent:

       driver          = redirect
       domains         = +local_domains
       data            = unknown@my.domain.tld

If you've use mailbox format and want messages for certain user be stored into his own mailbox file, use special transport:

# router
           driver          = accept
           domains         = +local_domains
           transport       = t_unknown

# transport
           driver          = appendfile
           file            = /var/mail/$domain/$local_part
           group           = mail
           user            = $local_part
           mode            = 0660
share|improve this answer
I already figured this part out. I posted a comment to my question. I now need to configure exim to write each email to an individual file. – transilvlad Nov 13 '12 at 17:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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