Virtual mail setup

From Oxxus Wiki

Jump to: navigation, search

There are several ways of having email services for multiple domains at same server. It's done through virtual e-mail services setup.

Most common way, and the easiest one, is to have multiple domains but with shared system accounts.

All virtual domains will forward incoming emails to same system account, that's why it's named as shared.

For example, if there are two domains hosted as virtual domains, and set as virtual ones at Postfix configuration files, test.com and test .org, incoming emails to [email protected] and [email protected] will be forwarded to same system account, info.

So everyone who has login details for this system account will be able to access and read emails from inbox.

To set this up, add the domain to Postfix configuration file, at /etc/postfix/main.cf:

mydestination = $myhostname localhost.$mydomain ... test.com

This will be suitable for systems with several email accounts but when it comes to several hundred email accounts, it'll be really hard to maintain password file.

This is where three solutions are used:

  • Postfix virtual ALIAS example: separate domains, UNIX system accounts,
  • Postfix virtual MAILBOX example: separate domains, non-UNIX accounts
  • Non-Postfix mailbox store: separate domains, non-UNIX accounts

Postfix virtual ALIAS example: separate domains, UNIX system accounts

With this approach, every virtual domain will have its own email address, but will still use the same system account. Setup is simple;

Edit /etc/postfix/main.cf and set following lines:

virtual_alias_domains = test.com ...other hosted domains...
virtual_alias_maps = hash:/etc/postfix/virtual

Create file /etc/postfix/virtual with contents below:

[email protected] postmaster
[email protected]	dick
[email protected]	ann


..etc, add as many as needed, and make sure that accounts exist on the system and that you have executed "postmap /etc/postfix/virtual" after changing the virtual file to let postfix update virtual table. ..restart Postfix and you're on.

As mentioned above, this solves one problem and allows each domain to have its own email addresses. Still, each virtual address is aliased to a UNIX system account. If you have more virtual addresses you also need more UNIX system accounts.

With the next solution, you'll avoid this issue as well.

Postfix virtual MAILBOX example: separate domains, non-UNIX accounts

With growing number of domains and users, it's essential to give every user their own system account. With the Postfix virtual(8) mailbox delivery agent, every recipient address can have its own virtual mailbox. Using this service, upon incoming email to postfix, it'll look for the user mailbox pathname, uid and gid via separate tables that are searched with the recipient's mail address. To turn this on maildir delivery style, terminate mailbox entry with “/” Configuration goes like this, for test.com domain name

Edit /etc/postfix/main.cf and place lines as below:

virtual_mailbox_domains = test.com ...more domains...
virtual_mailbox_base = /var/mail/vhosts
virtual_mailbox_maps = hash:/etc/postfix/vmailbox
virtual_minimum_uid = 100
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
virtual_alias_maps = hash:/etc/postfix/virtual

..create file /etc/postfix/vmailbox with contents:

[email protected]    test.com/info
[email protected]	test.org/info

..again execute "postmap /etc/postfix/virtual" after changing the virtual file and make sure to restart Postfix services as well.

Contact About Us Support Network Servers Java Hosting Oxxus.net Order Now! Dedicated Servers VPS Hosting Tomcat Hosting Java Hosting Money Back Guarantee Privacy Policy Oxxus.net Terms of 
Service Contact About Us Servers Networks Support Domain Names SSL Certificates Java Wiki Tutorials E-learning 
Platforms