Create Virtual Ownership

December 9, 2008 Multiple Domains

Mailbox Ownership
The mailboxes must each be owned by a user and connected to a group on the system. There are two directives which determine the ownership of mailboxes for users and groups.
virtual_uid_maps
virtual_gid_maps

It is possible to set a static map which means that one user will own all of the mailboxes of one domain. If you were setting up a static map with an account called vmail which had a UID of 1023 and a GID of 1024 you would setup the static map like this in the main.cf:
virtual_uid_maps = static:1023
virtual_gid_maps = static:1024

In order to set up different UIDs for each mailbox you would have to create a lookup file that would map addresses to the UIDs. In main.cf you must add a line that would access this file.

virtual_uid_maps = hash:/etc/postifix/virtual_uids

If you need the majority of mailboxes to be set up with one UID but several need static maps it would look like this:

virtual_uid_maps = hash:/etc/postifix/virtual_uids static:1023
Groups work the same way as the UIDs.

It is easier to create the UID and GID that are static this way:
Create the user virtual and group.  Take note of the UID and GID.

useradd virtual -u 1000

groupadd virtual -g 1000

In this example if the UID and GID of virtual were 1000 this line in the main.cf would look like this.

virtual_uid_maps = static:1000
virtual_gid_maps = static:1000

Change the permissions on the vmail directory so virtual can read all mail.

chown -R virtual:virtual /var/spool/vhosts
chmod 700 /var/spool/vhosts

Permissions on Working Virtual Mailbox

drwx—— 8 virtual virtual  4096 Sep 17 13:14 .
drwxr-xr-x 8 virtual virtual  4096 Feb  9  2008 ..
drwxr-xr-x 2 virtual virtual  4096 Sep 17 13:14 cur
-rw——- 1 virtual virtual   168 Sep 17 13:13 dovecot.index
-rw——- 1 virtual virtual 20480 Sep 17 13:13 dovecot.index.cache
-rw——- 1 virtual virtual  1760 Sep 17 13:14 dovecot.index.log
-rw——- 1 virtual virtual   428 Sep 17 13:13 dovecot-uidlist
drwx—— 5 virtual virtual  4096 Sep 14 03:24 .Drafts
drwxr-xr-x 2 virtual virtual  4096 Sep 17 13:13 new
drwx—— 5 virtual virtual  4096 Sep 14 03:24 .Sent
-rw——- 1 virtual virtual    18 Feb  9  2008 subscriptions
drwxr-xr-x 2 virtual virtual  4096 Sep 17 13:13 tmp
drwx—— 5 virtual virtual  4096 Feb  9  2008 .Trash

Tags: , , ,

Comments are closed.