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 http://cagelink.com/~tjr/postfix/.

Another "HOW TO Setup Postfix and vm-pop3d with virtual mailboxes" is at http://sonicresolutions.com/tech/howto_postfix_vmpop3d.html.

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/zschopau.globalpark.de/mopalias
In /etc/postfix/virtual something like this:
bogus.de	#a comment or a text must exist here
@bogus.de	mopalias
Afterwards do:
postalias /etc/postfix/aliases
postmap /etc/postfix/virtual
This will install the new virtual domain bogus.de (for detailed virtual domain setup refer to the postfix documentation) and the alias mopalias. Whenever a mail to XYZ@bogus.de 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/zschopau.globalpark.de.

(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. foo.com) create n users in /etc/passwd:

		foo_1
		foo_2
		...
		foo_n
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:

		@foo.com	foo.com virtual domain definition
		mary@foo.com	foo_1
		peter@foo.com	foo_2
		...	...
		john@foo.com	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/foo.com/ 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. mary:foo.com)

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

In main.cf:

virtual_maps = hash:/etc/postfix/virtusertable
alias_maps = hash:/etc/postfix/aliases
alias_database = hash:/etc/postfix/aliases
In virtusertable:
user.name1@domainname1.com	user.name1.dn1.com
user.name2@domainname1.com	user.name2.dn1.com
user.name3@domainname1.com	user.name3.dn1.com
#
user.name4@domainname2.com	user.name4.dn2.com
user.name5@domainname2.com	user.name5.dn2.com
user.name6@domainname2.com	user.name6.dn2.com
In aliases:
user.name1.dn1.com:     /var/spool/virtual/domainname1.com/user.name1

user.name2.dn1.com:    /var/spool/virtual/domainname1.com/user.name2

user.name3.dn1.com:    /var/spool/virtual/domainname1.com/user.name3

#

user.name4.dn2.com:   /var/spool/virtual/domainname2.com/user.name4

user.name5.dn2.com: /var/spool/virtual/domainnam2.com/user.name5

user.name6.dn2.com: /var/spool/virtual/domainname2.com/user.name6

#
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
/var/spool/virtual/domainname1.com,
/var/spool/virtual/domainname2.com
and so on for the other domains where postfix deposits the messages for the pop3 users per the virtusertable and aliases files.
/etc/virtual/domainname1,
/etc/virtual/domainname2
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.