Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have setup a working SMTP, IMAP and POP3 server using Postfix and Dovecot. I have setup virtual mailboxes using the format /home/vmail/%d/%u, where %d is the domain (e.g. camilstaps.nl) and %u is the 'user' (e.g. info) - thus info@camilstaps.nl has /home/vmail/camilstaps.nl/info. I now would like to setup Procmail to use filters.

I have read this wiki, for example, but I don't think it applies to my situation with virtual mailboxes. I have not enough knowledge of Procmail to do this all by myself.

Could anyone explain to me or give me a link where to start? I searched on google but only came across useless forum threads, no documentation or tutorial. That makes me wonder if it's even possible to do this.

share|improve this question
    
Are all virtual mailboces owned by single OS user/account? –  Andrzej A. Filip Jun 15 '13 at 9:48
    
@AndrzejA.Filip yes –  Camil Staps Jun 15 '13 at 9:49

1 Answer 1

up vote 2 down vote accepted

WARNING: It should work but I have not tested it myself.
RECOMMENDED IMPROVEMENT: I would advice making both postfix and dovecot use mysql (or another database) to store valid virtual user.

Discussion about procmail script in /etc/procmailrcs/

/etc/postfix/main.cf:

# list of valid/served virtual domains
virtual_mailbox_domains = example.com example.net
# verification of virtual recipient validity
virtual_mailbox_maps = hash:/etc/postfix/virtual
# transport for deliveries to virtual mailboxes
virtual_transport = virtualprocmail:dummy

virtualprocmail_destination_recipient_limit = 1

/etc/postfix/virtual (requires compilation with postmap):

janedoe@example.com Jane Doe
johndoe@example.net John Doe

/etc/postfix/master.cf (replace virtualuser with real OS account name owning the virtual mailboxes):

virtualprocmail unix - n n - - pipe flags=DRXhuq user=virtualuser 
  argv=/usr/bin/procmail -m E_SENDER=$sender E_RECIPIENT=$recipient ER_USER=$user ER_DOMAIN=$domain ER_DETAIL=$extension NEXTHOP=$nexthop /etc/procmail.d/default.rc

/etc/procmail.d/default.rc (must be readable by virtualuser):

# You should add some sanity chces of ${ER_DOMAIN} and ${ER_USER}

# Add tariling / if you want to use maildir directory instead of mailbox file
DEFAULT=/home/vmail/${ER_DOMAIN}/${ER_USER}
share|improve this answer
    
Thanks, but I'm getting an error in my mail.log: Denying special privileges for "/etc/procmailrcs/default.rc" - how to solve that? –  Camil Staps Jun 17 '13 at 18:15
    
/etc/procmailrcs directory is special for procmail (see "man procmail"). AFAIk it should not make difference for procmail invoked by no root user. You may keep the procmail script in another directory. –  Andrzej A. Filip Jun 17 '13 at 18:53
    
Should I move the file and would that solve the privilege error? –  Camil Staps Jun 17 '13 at 18:54
    
IMHO it is the cleanest option. I have mentioned another option in unix.stackexchange.com/questions/79741/… –  Andrzej A. Filip Jun 17 '13 at 19:48
    
I don't have enough knowledge to say that, but it looks good! :) let's continue the discussion there, shall we? (I posted a comment) –  Camil Staps Jun 17 '13 at 19:49

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.