Archive for the Multiple Domains Category

Virtual Domain Aliases

Posted by Filed Under Multiple Domains with Comments Off

Virtual aliases can map to addresses that do not terminate on the local system while regular aliases can only map to addresses which terminate on the local system.

Virtual Alias Domains
You will need to add these lines to the file.

virtual_alias_domains =

If you were going to add a number of domains you would want to create a map file.  Create the file /etc/postfix/virtual_alias_domains and enter one domain on each line and include the creation date on the right.  Postfix will ignore the creation date but remember map files must have two sides.             20070608                  20070801            20070803

Now create the db out of this file with this command:

postmap hash:/etc/postfix/virtual_alias_domains

If you use a database file as illustrated above you will need the parameter changed to this:

virtual_alias_domains = hash:/etc/postfix/virtual_alias_domains

If you set up a domain as virtual DO NOT put it in the mydestination parameter.

Now you need to create the recipient address map.  Create a file called:


The file will then create the mappings of the virtual address on the left and the address, local or remote that you want it to go to on the right column.  The names are separated by a TAB.

Save the file.

Execute the command to create the db file.
postmap hash:/etc/postfix/virtual_alias_maps

Add this line in the
virtual_alias_maps = hash:/etc/postfix/virtual_alias_maps

service postfix reload

Testing the Virtual Alias Settings
Enter a mail address that you have listed in your virtual_alias_maps file to test.
echo testing | /usr/sbin/sendmail

Create Virtual Ownership

Posted by Filed Under Multiple Domains with Comments Off

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.

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

Postfix With Multiple Domains

Posted by Filed Under Multiple Domains with Comments Off

Postfix Mail Server will allow you to set a base domain and add any number of virtual domains.  Virtual domains can either be virtual alias domains which are the domains that your server is the final destination for and also virtual mailbox domains which do not have local accounts and only pick up mail through IMAP or POP3.

The canonical name on a system refers to the local domain of the system; including localhost, $myhostname, $mydomain and the IP Address of the mail server. That means there are 4 possibilities for an entry as canonical domain.

Virtual domains are totally different domains than the localhost. When you set up virtual domains, you need to consider two important aspects in how the mail to the virtual domain will be delivered.

1. Shared Domain – Does each mail namespace such as mike go to each domain. In other words, if an email is sent to is it the same user as
2. Virtual Accounts – Does each user have a real account on the mail server? Users who pick up their mail locally may have an account on the mail server, but those on virtual domains do not need to log into a local account, they just need access to pick up their mail through POP3 or IMAP.

In order to use virtual mailbox domains the master daemon needs to be able to run the virtual daemon. Look for this like to verify it can do this in the Do not run this chrooted.
virtual unix – n n – - virtual

Separate Domains with Virtual Accounts

This type of setup allows you to configure domains and the users of those domains so they do not log into the local system. You do not need to maintain local accounts, the users on these domains may pick up their mail using POP3 or IMAP. In fact, this will add a level of security as users will not be logging into the system nor will accounts have access to the /etc/passwd file. The virtual delivery agent, which manages the accounts, depends entirely upon map types.

To set this up you need to configure a directive for virtual mailbox accounts.

virtual_mailbox_domains =,

If you had a great number of domains you may not want to list them here but create a file, so it would look like this:

virtual_mailbox_domains = /etc/postfix/virtual_domains

You would need to create the file virtual_domains with one domain listed per line.

# # /etc/postfix/virtual_domains #

These virtual accounts will be delivered to the virtual delivery agent.

One other aspect of setup is that you will need to create a directory system that will facilitate your virtual domains. There will need to be a directory for each virtual domain listed in the /var/spool/vhosts.

This is how the directory structure should look:


The must be edited to reflect this change. This line should be added:

virtual_mailbox_base = /var/spool/vhosts

Each user for these domains must have a email address mapping to mailbox. In order to set this up you must use the directive for virtual_mailbox_recipients in the

virtual_mailbox_recipients = hash:/etc/postfix/virtual_mailbox_recipients

Now if the /etc/postfix/virtual_mailbox_recipients file is not created you need to create it. The file has two entries which are separated by a TAB. Place the fully qualified email address in the left and the corresponding mailbox on the right.

Here you see two email addresses which are needed and mapped to their necessary mailboxes. Once this file is set up or if you make changes to the virtual file run this command:

postmap hash:/etc/postfix/virtual_mailbox_recipients

Create the necessary mail directories for domains.
mkdir /var/spool/vhosts/
mkdir /var/spool/vhosts/

Create the necessary mail directories for users.
mkdir /var/spool/vhosts/
mkdir /var/spool/vhosts/

Create the necessary mail directories for users boxes since this is the MailDir format.
mkdir /var/spool/vhosts/ new cur tmp
chmod 700 /var/spool/vhosts/ new cur tmp

Copyright CyberMontana Inc. and

All rights reserved. Cannot be reproduced without written permission. Box 1262 Trout Creek, MT 59874