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'm using Ubuntu 11.04 with PostFix and DoveCot for mail in a VPS. I have figured out how to run them and succeeded in sending/receiving emails.

So far, I'm using the following approach: I have lot of domains, and one main principal domain. I created an account where all the emails sent to these domains (catch-all) forward to that principal (and only) account.

I have decided to use Folders to manage my domains, so for domain, I create a folder called example. Everything is fine, however, I want to automate the process.

I want emails sent to, to be put automatically inside the domain folder. How to do that?

share|improve this question
up vote 1 down vote accepted

It is the responsiblity of the local delivery agent to do this. Common options are procmail and sieve. For instance, in procmail:

* ^To:.*
share|improve this answer

Sieve is the way to go.

Dovecot has built in filtering capabilities. You just have to put your rules to the right place.

I think newer versions of dovecot even have managesieve protocol built in so you can use desktop sieve rule editor.

This is a standard solution with wide support.

Sieve desktop clients:

share|improve this answer

IIRC, syntax is mainaddr+subfolder@ and mainaddr+subfolder.subsubfolder@.

share|improve this answer
Only if your LDA is setup to do that. – womble Jul 16 '11 at 23:31
No, it's not one's own LDA. It's actually Postfix itself that one sets up to do that, and it encompasses more than just local. – JdeBP Jul 25 '11 at 14:32

If your "catch-all forwarding" is post-delivery forwarding (where messages are injected anew after delivery to the forwarding mailbox) or pre-delivery forwarding that rewrites the envelope recipient, then you have little choice but what M. womble describes.

However, if your forwarding is such that mail arrives at your machine with the original envelope recipient mailbox unaltered, as would be the case were this machine listed as the mailhost for all of these various domains, then what you are looking for is essentially provided out of the box with Postfix, as its virtual mailbox domain mechanism. All mail for, say, OmarAbid@domain1.example and OmarAbid@domain2.example can be directed to individual maildir storage areas, using the virtual mailbox maps database.

Simply match that up with individual maildirs for separate folders within a single Dovecot user account, and you'll get mail for OmarAbid within each domain sorted into individual folders.

share|improve this answer

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.