How to: set up your own email server in 5 steps

Originally published on Bytemark’s forum

There are a load of guides to setting up email on a server, but many of them don’t cover the extra useful features that make hosting your own email a viable experience.

If you’re going to wean yourself off Gmail, then you need usable webmail, (push) IMAP, spam filtering, virus protection and all the extras like DKIM signing on outgoing messages.

Using Symbiosis + bigv.io, you can set up a mail server with all the above features in just five steps.

Symbiosis is free software that already powers thousands of mailboxes across Bytemark’s network. It’s easy to use for developers and seasoned sysadmins, being well documented and doesn’t need you to be using Bytemark or BigV at all – it’s free software.

There are five steps, but I’ve assumed two pre-requisites (which avoid having to configure DNS):

  • that you’ve registered your domain and pointed it at Bytemark’s name servers: [a-c].ns.bytemark.co.uk and
  • that you have an account on bigv.io. If you want to try before you buy, bigv.io is currently offering free credit to run a basic server for a month.

1. Create a server using Bytemark Symbiosis through the bigv.io client.

$ bigv vm new

Make sure you pick symbiosis as your distribution.

For the more visually inclined, try the beta BigV web manager: https://panel-beta.bytemark.co.uk/

You don’t need anything special – the basic configuration of 1 GiB RAM, 1 core and 25 GB of sata space will sort you out (sata:25).

At the end of the imaging process, you’ll get the root password and IP address. Take note of both!

2. Login to your newly created server using SSH.

$ ssh admin@example.default.group.uk0.bigv.io

Use admin as the user, rather than root. The password is the same by default. You’ll land in the home directory for admin, which is /srv. You can also connect to the IP address.

3. Create a domain and mailbox user in Symbiosis by creating subdirectories.

$ mkdir -p /srv/my-brilliant-site.com/mailboxes/bob

Symbiosis works by using subdirectories and files to configure domains, mailboxes and users. There’s no web interface, scripts to run or interpret. Just plain directories and files.

The Symbiosis documentation recommends use of SFTP through FileZilla. Personally I’m fine with SSH at the command-line, but pick whatever you like. Just remember to use the admin account rather than root.

4. Set a password for the user.

$ echo Passw0rd123 | symbiosis-encrypt-password > my-brilliant-site.com/mailboxes/bob/password

Passw0rd123 can be any text string. Essentially, this stores a hash of the password in the right place.

5. Test the email setup.

Open webmail (SquirrelMail) by visiting the following address in your web browser:

http://my-brilliant-site.com/webmail/

Login with the username you set at the full domain, e.g. bob@my-brilliant-site.com. Use the password you created above.

Webmail can be accessed over https which by default is secured with a self-signed certificate. You can also add your new mail account to your favourite mail client using IMAP or POP3. Symbiosis supports TLS for both protocols.

That’s it! In just 5 steps, you’ve setup a fully working email implementation, reasonably secured and in a well understood way.

You can easily extend your email setup by using SpamAssassin for spam filtering and ClamAV for antivirus. Have a read through the Symbiosis documentation for more. All the software is documented and open source.

Problems?

If nothing comes up when you visit the webmail URL, try waiting up to an hour, especially if your domain hasn’t previously been registered on Bytemark’s DNS servers. Your domain will be automatically configured to serve email (including SMTP) and webmail if it’s hosted within Bytemark’s network.

If it’s hosted elsewhere, you can check out the sample records to set up your DNS config.

Did you find this useful? Do you have any suggestions for improving this documentation? Please drop me a comment below.