This article is more than 1 year old
The last post: Building your own mail server, part 2
Getting the basics of your box up and running
Dovecot
Now, let's get Dovecot up and running. At its simplest, just edit /etc/dovecot/dovecot.conf and ensure there's a line saying
protocols = imap pop3
Then, in /etc/dovecot/conf.d/10-master.conf find the Postfix smtp-auth section and change it to look like this
#Postfix smtp-auth unix_listener /var/spool/postfix/private/auth { mode = 0660 user = _postfix group = _postfix }
It's also necessary to edit /etc/login.conf, to give Dovecot permission to open all the files it needs, otherwise it won't be able to start up properly, at least on OpenBSD. Add these lines at the bottom, to ensure it runs with appropriate settings:
dovecot:\ :openfiles-cur=2048:\ :openfiles-max=4096:\ :tc=daemon:
For more details, check out the Quick Configuration guide.

Brush up on your SMTP – you're going to need it to test Postfix
Setting up Postfix
Now, we'll get Postfix running without all the filtering; this way we can check messages are correctly delivered, and we know problems later are down to our filtering setup. If you want to tinker, there are lots of helpful How-Tos on the Postfix site.
Postfix keeps its config files in /etc/postfix: main.cf defines the config, and master.cf the processes that run. One big exception: the aliases file for local users is in /etc/mail/aliases in our OpenBSD setup.
For a basic setup, start by editing master.cf; change the mynetworks setting to include hosts you want to trust, such as your home LAN, for instance, and tell Postfix to use Maildir folders for local recipients. If you've set up DNS, you likely won't need the myhostname entry.
Don't make holes in your firewall to access the mail server just yet! You can put these config settings anywhere in main.cf, either inline with the examples, or at the end. The latest definition of a setting overrides earlier ones.
myhostname = gate.nigelwhitfield.com mynetworks = 10.0.1.1/24 home_mailbox = Maildir/
These lines set up SASL to use Dovecot for authentication:
smtpd_sasl_auth_enable = yes smtpd_sasl_type = dovecot smtpd_sasl_path = private/auth smtpd_sasl_authenticated_header = yes
For virtual alias support add a line like this:
virtual_alias_maps = hash:/etc/postfix/virtual_alias
In /etc/mail/aliases, add an alias for root to the user you created during setup, for example root: nigel. Rebuild the aliases file with the newaliases command. Create a new virtual_alias file as /etc/postfix/virtual_alias and add lines like these:
nigelwhitfield.com anything nigel@nigelwhitfield.com nwmail fancynewdomain.com anything test@fancynewdomain.com nwmail
Build the virtual user database by typing
postmap virtual_alias
Now, start Dovecot with the command
/etc/rc.d/dovecot start
and Postfix with
/etc/rc.d/postfix start
You should now be able to telnet to port 25 on your system and submit a message via SMTP, as in the screenshot. Use the command line mail program to try local submissions too.
If all is well, the Maildir for the target user (here /home/nwmail/Maildir) will have your test messages in the “new” subdirectory. Check Dovecot is working ok with a quick POP 3 connection to localhost port 110. The LIST command should show you how many messages have been delivered to the Maildir.

Connect to localhost port 110 for your POP3 test with cleartext password
At this stage, you'll have a working configuration which will accept mail for a variety of domains, and deliver it to your users in Maildirs, accessible via Dovecot. So, now let's add some more functionality.