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 main.cf file.

virtual_alias_domains = example.com

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.

myexample.com             20070608
example.com                  20070801
newexample.com            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

Warning!
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:

/etc/postfix/virtual_alias_maps

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.

test@myexample.com      test@example.com
mike@example.com         mike@another_example.com
joe@newexample.com     joe@last_example.com

Save the file.

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

Add this line in the main.cf.
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 test@myexample.com

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

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 mike@example.com is it the same user as mike@myexample.com?
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 master.cf. 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 = someexample.com, myexample.com

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 # someexample.com myexample.com

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:

/var/spool/vhosts/example.com
/var/spool/vhosts/myexample.com

The main.cf 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 main.cf.

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.

sales@example.com example.com/sales/
tech@myexample.com myexample.com/tech/

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/example.com
mkdir /var/spool/vhosts/myexample.com

Create the necessary mail directories for users.
mkdir /var/spool/vhosts/example.com/sales
mkdir /var/spool/vhosts/myexample.com/tech

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

Copyright CyberMontana Inc. and Postfixmail.com

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