Setting up postfix with virtual domains
- 1 Postfix on 1.9
Postfix on 1.9
The idea is to create a postfix config to host multiple maildomains.
I want to document both how it's set up and how it's maintained
When you are done with postfix installation you could proceed and install (depending on your needs)
- Other email related applications
Have a look at Hosting_services_on_Alpine#Mail for various alternatives
We need to create a user on this system that has rights to read/write mail on you system.
Let's call this user vmail (you can choose another name if you like).
You will get prompted for a password.
Now we need to know what gid/uid that user got.
Take notes on the numbers, you will need the in the upcoming configuration (in my case I got uid/gid '1001').
grep vmail /etc/passwd
This newly-created user will need permissions in the mail group.
Edit /etc/group and add vmail to the postdrop group. Se example below:
Create missing dirs
Seems we are missing /var/spool/mail and /var/mail so we need to create those
mkdir /var/spool/mail ln -s /var/spool/mail /var/mail
Create virtual maildir
In the upcoming configuration we are going to specify /var/mail/vhosts/ as the virtual_mailbox_base so we need to create it.
And we need to give permissions to our vmail user so he can read/write in this folder.
chown vmail:vmail /var/mail/vhosts
For now I just dump whatever I have. I will clean up these notes soon.
These are the variables that varies from the defaults
## These settings differers from the default config ## soft_bounce = yes # For testing myhostname = mail.example.net mydomain = example.net myorigin = $mydomain mydestination = localhost, mail.localdomain, localhost.localdomain, localdomain # See 'virtual_mailbox_domains' for more information mynetworks = 192.168.10.0/24, 127.0.0.0/8 relayhost = in_flow_delay = 1s home_mailbox = Maildir/ mail_spool_directory = /var/spool/mail smtpd_banner = $myhostname ESMTP $mail_name ($mail_version) ## The following is added to the config ## virtual_mailbox_domains = example.net virtual_mailbox_base = /var/mail/vhosts virtual_mailbox_maps = hash:/etc/postfix/vmailbox virtual_minimum_uid = 100 virtual_uid_maps = static:1001 virtual_gid_maps = static:1001 virtual_alias_maps = hash:/etc/postfix/valias
firstname.lastname@example.org email@example.com firstname.lastname@example.org email@example.com
firstname.lastname@example.org example.net/user1/ email@example.com example.net/user2/ @example.net example.net/catchall #everyone else doesn't match rule above
Once you created the above config-files, you need to make generate some DB's
postmap /etc/postfix/vmailbox postmap /etc/postfix/valias
I am not 100% if the next command is needed, but I think that you need to create the 'aliases' DB.
It's time to start. Hopefully it works!
In case something goes wrong you should have a look in your syslog.
Personally I use to tail the logfile while debugging
tail -f /var/log/messages