Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 example.com, I create a folder called example. Everything is fine, however, I want to automate the process.

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

share|improve this question

4 Answers 4

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:.*something@domain.com
example/
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: http://sieve.info/clients#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

 
discard

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.