Skip to main content.

Setting up Postfix with virtual domains support

This document shares a few ideas on configuring postfix to work with virtual domains -- in other words, allowing the use of the same username with different mail accounts. This information is useful with vm-pop3d, a POP3 server that supports multiple password files and mailbox locations to separate different virtual domains.

This information is not a substitute for the Postfix documentation. Consider also reading the Postfix Documentation and FAQs.

Also, a howto on using Postfix with vm-pop3d is available at

Another "HOW TO Setup Postfix and vm-pop3d with virtual mailboxes" is at

These ideas were submitted by users of a POP3 server that supported virtual domains.

      Idea #1
      Idea #2
      Idea #3

Idea #1

(Notes from Andreas Streichardt 25/Jul/2000)

In /etc/postfix/aliases, an entry like this:

mopalias:       /var/spool/virtual/
In /etc/postfix/virtual something like this:	#a comment or a text must exist here	mopalias
Afterwards do:
postalias /etc/postfix/aliases
postmap /etc/postfix/virtual
This will install the new virtual domain (for detailed virtual domain setup refer to the postfix documentation) and the alias mopalias. Whenever a mail to is sent, the mail is forwarded to mopalias. Postfix looks in its alias db and finds that every mail should be forwarded to /var/spool/virtual/

(This example appears to deliver all mail to one mailbox. But you can have separate mailboxes by creating /etc/postfix/aliases and /etc/postfix/virtual entries for each user. Be sure to read the postfix virtual manual page.)

Needed changes to vm-pop3d.h:

 MAIL_UID 	65534
This is SuSE's UID of nobody. You have to set this because postfix runs under nobody and not under mail.

Idea #2

(Notes from Marco Menegon 09/Aug/2000)

First step:

For every virtual domain (es. create n users in /etc/passwd:

These users can be DISABLED; only the entry in /etc/passwd is necessary.

Second Step:

In /etc/postfix/virtual define the apposite corrispondences, ad es: virtual domain definition	foo_1	foo_2
		...	...	foo_n
In this way postfix will save each user mail in the appropriate mailbox (/var/spool/mail/foo_x). The drawback is that the user name is lost (well, seems lost ;)).

Third step:

In /var/spool/virtual/ create appropriate links:

		mary -> /var/spool/mail/foo_1
		peter -> /var/spool/mail/foo_2
		...	...
		john -> /var/spool/mail/foo_n
In this way the POP server could access the mailboxes by way of links.

In this way we have:

- some accounts disabled in /etc/passwd and the POP passwords in another file (security ok)

- POP users can access the pop server with real, more intuitive, names (es.

- with some little effort (measured in Perl programming) it's possible to give every single virtual domain "master" user the possibility to change mailbox names, etc. ( I suppose to give n mailbox by default, and so n users in /etc/passwd; "master" users should buy another n accounts)

Idea #3

(Notes from Steve Weifenbach 25/Oct/2000)


virtual_maps = hash:/etc/postfix/virtusertable
alias_maps = hash:/etc/postfix/aliases
alias_database = hash:/etc/postfix/aliases
In virtusertable:
In aliases:     /var/spool/virtual/    /var/spool/virtual/    /var/spool/virtual/

#   /var/spool/virtual/ /var/spool/virtual/ /var/spool/virtual/

and so on for other domains.

The virtusertable db is created using postmap in the /etc/postfix directory. The aliases db is created using postalias in the /etc/postfix directory.

Directories defined:

/var/spool/postfix, where postfix manages the messages
and so on for the other domains where postfix deposits the messages for the pop3 users per the virtusertable and aliases files.
and so on for the other domains where the passwd file is kept for each domain.

Create the passwd files in each /etc/virtual/domainname directory.