Setting up postfix with virtual domains
- 1 Postfix on 1.9
- 1.1 General
- 1.2 Initial Setup
- 1.3 Postfix
Postfix on 1.9
The idea is to create a
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 and instructions.
Burn alpine-1.9.3-x86.iso (or higher) on a CD and boot the machine.
Suggestion: Follow notes on Setting_up_a_ssh-server to be able to remotely administer this box.
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 so we need to create it
Create virtual maildir
In the upcoming configuration we are going to specify /var/spool/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:postdrop /var/spool/mail/vhosts
FIXME: The following configuration needs some more work
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 ## local_transport = virtual virtual_mailbox_domains = example.net virtual_mailbox_base = /var/spool/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 smtpd_helo_required = yes disable_vrfy_command = yes smtpd_recipient_restrictions = reject_unauth_pipelining, permit_sasl_authenticated, permit_mynetworks, reject_invalid_hostname, reject_non_fqdn_hostname, reject_non_fqdn_sender, reject_non_fqdn_recipient, reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_unauth_destination, permit smtpd_data_restrictions = reject_unauth_pipelining, permit
email@example.com firstname.lastname@example.org email@example.com firstname.lastname@example.org
email@example.com example.net/user1/ firstname.lastname@example.org 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
In the above examples we used /etc/postfix/vmailbox to store our list of mailboxes.
To add/remove a mailbox, you need to edit this file and then rebuild the DB.
vi /etc/postfix/vmailbox postmap /etc/postfix/vmailbox
Now we have done our re-configuration and we want postfix to start using the new settings.