Procmail with Postfix and virtual mailboxes
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):
[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
DEFAULT=/home/vmail/${ER_DOMAIN}/${ER_USER}
Admin
Updated on September 18, 2022Comments
-
Admin over 1 year
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.
-
Admin almost 11 yearsThanks, but I'm getting an error in my mail.log:
Denying special privileges for "/etc/procmailrcs/default.rc"
- how to solve that? -
zizi0328 almost 11 years/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.
-
Admin almost 11 yearsShould I move the file and would that solve the privilege error?
-
zizi0328 almost 11 yearsIMHO it is the cleanest option. I have mentioned another option in unix.stackexchange.com/questions/79741/…
-
Admin almost 11 yearsI don't have enough knowledge to say that, but it looks good! :) let's continue the discussion there, shall we? (I posted a comment)