Postfix and multiple domains

Currently I have Postfix configured to receive email for one domain name. I have bought another domain name, how do I configure Postfix to send/receive email correctly for the new domain?

I was having a look through some of the options for Postfix, is it called "Virtual Domains"?

If I have two email addresses:

1) test@domain.com

and

2) test@NEWdomain.com

Are these two totally separate mailboxes? Or is it like a mail alias?

I'm just trying to understand the relationship between the two domains being hosted on the mail server.

Appreciate any help. ;)
 
Many thanks for the help.

I have tried to do this in Webmin (yeah yeah I know its cheating! ;-)) but don't seem to be having much luck.

In Webmin I went into the Postfix module and selected Virtual Domains. I then selected "add a new mapping" and typed in my details as follows:

Description: My New Domain
Name: My New Domain
Maps to...: mynewdomain.com

but when I click save mapping it says:
Code:
Error while saving a mapping : No map file defined

What am I doing wrong?
 
sounds like you need to create the map file or define one in your config.

check to see if
virtual_mailbox_maps
or
virtual_alias_maps
exists in the main.cf file. if it's not there, then create the file if it is there then check to make sure it's been created on your file system.
 
I went through my main.cf file and I couldn't find any:
Code:
virtual_mailbox_maps 
virtual_alias_maps

I didn't quite follow your post. Where must I create this map file and what must I call it? What entries must I put in the main.cf file?

Thanks!
 
you need to edit your main.cf and add:

Code:
virtual_alias_domains = DomainOne.com DomainTwo.com
virtual_alias_maps = hash:/etc/postfix/virtual

you then need to run 'postmap' and you may need to restart postfix.

also, i think this is also in the webmin postfix module. you should be able to define the files through there.
 
I added:
Code:
virtual_alias_domains = bsdpanic.com privatesovereign.com
virtual_alias_maps = hash:/etc/postfix/virtual

to my main.cf file but when I run postmap it says:
Code:
postmap: fatal: usage: postmap [-Nfinoprsvw] [-c config_dir] [-d key] [-q key] [map_type:]file...

I'm not sure what options to use with postmap?
 
xy16644 said:
I added:
Code:
virtual_alias_domains = bsdpanic.com privatesovereign.com
virtual_alias_maps = hash:/etc/postfix/virtual

Only system configuration files should be under /etc. /usr/local/etc/postfix should be a better place for your configuration.

to my main.cf file but when I run postmap it says:
Code:
postmap: fatal: usage: postmap [-Nfinoprsvw] [-c config_dir] [-d key] [-q key] [map_type:]file...

I'm not sure what options to use with postmap?

Try # postmap hash:/path/to/file. Remember to run postmap every time the original file is updated.
 
Thanks Denny.

I created a virtual file in:
Code:
/usr/local/etc/postfix

I then added the following to my main.cf file:
Code:
virtual_alias_domains = privatesovereign.com
virtual_alias_maps = hash:/usr/local/etc/postfix/virtual

I then ran:
Code:
postmap hash:/usr/local/etc/postfix/virtual
postfix reload

Is this everything I need to do? Do I need to put anything in the virtual file?
 
An example configuration:
/usr/local/etc/postfix/main.cf:
Code:
virtual_mailbox_domains = example.com
virtual_mailbox_base = /var/vmail
virtual_mailbox_maps = hash:/usr/local/etc/postfix/virtual_mailbox_maps
virtual_uid_maps = static:1000
virtual_gid_maps = static:1000
virtual_alias_maps = hash:/usr/local/etc/postfix/virtual_alias_maps

This first line means that example.com is a virtual domain that Postfix will accept mail for.

In /usr/local/etc/postfix/virtual_mailbox_maps:
Code:
foo@example.com    example.com/foo/
bar@example.com    example.com/bar/

Mails sent to foo@example.com will be sent to /var/vmail/example.com/foo/. Note that the "/" at the end signifies that mail will be stored in the Maildir format.

The virtual mailboxes should have a UID and GID of 1000. Change this as necessary. I have a user called vmail for virtual mailboxes.

Last of all, the alias maps. This is quite similar to the alias file:
Code:
foo@example.com    bar@example.com

All mail sent to foo@example.com will be forwarded to bar@example.com.

If you're going to create over a hundred accounts, consider using SQL or LDAP as a backend.

The Postfix website has plenty of information. For a in depth view of Postfix, I recommend reading The Book of Postfix. The book is very informative and useful. The only drawback is that some configuration settings have been replaced by newer ones. However, all changes are documented in the Postfix configuration parameters.
 
How the mail server treats user@domain1 and user@domain2 is entirely defined by the setup of Postfix. I have a mail server with literally a dozen different domains on it, one for each department. No matter if you send an e-mail to me at domain1 or domain4, they all end up in the same mailbox. I intentionally made it this way so that when people move from department to department, there's no disruption from an e-mail point of view. Mail sent to user@olddepartment arrives in the mailbox set up at user@newdepartment without the employee or myself doing anything. :)

With this configuration, I believe all you have to do is add your new domain to the mydestination variable in main.cf and postmap this file.

If you want user@domain1 to be a different account than user@domain2, you'll need to read and modify your setup as already discussed above.
 
Old thread but still relevant. Isn't it easier to setup aliases for that?

1) edit main.cf and add the hosts to mydestination
2) edit/etc/aliases
3) then regenerate /etc/aliases.db

And voilà, all the mail goes to user test no matter the domain name.
 
Back
Top