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

Gathering packages

Once you've rebooted, you're almost ready to install the software we need. First, though, you should disable OpenSMTPD, which is OpenBSD's own mail system. That's easy to do. Built-in services like this are controlled on OpenBSD via the file /etc/rc.conf where a 'flags' variable for each one either turns it off (if flags are “NO”) or runs it otherwise. So, enter

vi /etc/rc.conf

at the command line, and change the value of smtpd_flags to NO. You can stop the current instance with the command

/etc/rc.d/smtpd stop

Packages on OpenBSD are installed using the pkg_add command. It's handy to keep an eye on screen output, as some will display extra instructions that you need to do yourself.

So, to get started, we can add Dovecot with the command

pkg_add dovecot
Adding packages in OpenBSD

Pay attention when adding packages – OpenBSD may display additional instructions

OpenBSD will fetch Dovecot and anything it requires, and explain how to create a self-signed certificate; you can do that now by following the instructions on screen or leave it till later. Similarly, you can install Postfix with the command

pkg_add postfix

in this case, it's ambiguous, and you'll see a list of the various versions available. Select one by entering the corresponding number.

We're going with Postfix 3, with MySQL/MariaDB support compiled in; all the options include Dovecot SASL - the SASL variants are for the Cyrus IMAP server. After installation is complete, run the command

/usr/local/sbin/postfix-enable

which points commands like mailq to the correct binaries.

Now we can crack on with installing other packages. You can request multiple packages at the same time, so type

pkg_add postgrey pflogsumm amavisd-new

You may also want to add MariaDB if you'd like to keep mail aliases in a database on the same system. The pkg_info command will show you what's been installed so far.

Use pkg_info to list installed packages

Use pkg_info to show packages installed – which will include pre-requisites for those you requests, such as Amavisd-new and Postgrey

For the sake of simplicity, we're going to create an OpenBSD account for each person who wants to receive mail. This won't have login privileges, but will allow them to use their name and password to send and receive email. So, to add an account called nwmail for myself, with a note of my address, and the “nologin” shell, this is the command:

useradd -m -c “nigel@nigelwhitfield.com” -s /sbin/nologin nwmail

Follow that up by setting a password with

passwd nwmail

and repeat for the other accounts you want to add – you can do more later, but at least one will be helpful for testing.

More about

More about

More about

TIP US OFF

Send us news


Other stories you might like