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 [email protected] 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.

  • Are all virtual mailboces owned by single OS user/account?
    – AnFi
    Jun 15, 2013 at 9:48
  • @AndrzejA.Filip yes
    – user125111
    Jun 15, 2013 at 9:49

1 Answer 1


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/


# 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):

[email protected] Jane Doe
[email protected] 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 trailing / if you want to use maildir directory instead of mailbox file
  • Thanks, but I'm getting an error in my mail.log: Denying special privileges for "/etc/procmailrcs/default.rc" - how to solve that?
    – user125111
    Jun 17, 2013 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.
    – AnFi
    Jun 17, 2013 at 18:53
  • Should I move the file and would that solve the privilege error?
    – user125111
    Jun 17, 2013 at 18:54
  • IMHO it is the cleanest option. I have mentioned another option in unix.stackexchange.com/questions/79741/…
    – AnFi
    Jun 17, 2013 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)
    – user125111
    Jun 17, 2013 at 19:49

You must log in to answer this question.