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 firstname.lastname@example.org is it the same user as email@example.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:
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.
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:
Create the necessary mail directories for domains.
Create the necessary mail directories for users.
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