KPTree - Email Server Setup

Setting up the email server on my home server was probably the most difficult task. Email server setup is intricate, risky and involves significant commitment and effort to setup reliably and maintain.

My current email server is based upon workaround.org ISPmail tutorials for a Debian based server. I first got this up and running in later 2020 on Debian 10 (Buster). The most current is ISPmail guide for Debian 11 “Bullseye” that was release late 2021 a couple of months after the Bullseye release.

I setup my email server on a separate virtual machine (VM) on my home server that also acts as a NAS. The main mail files are stored on a drive outside the VM.
As the home server has only one external static IPv4 address the mail server subdomain needs to be shared on the common IP address with other subdomains and applications. We can use the web server's “virtual host” feature to differentiate between different subdomains.

Set network IP address, static IP

The mail server need to have a static IP address on the local area network.

I actually like to use netplan

Change Hostname

Change host name: sudo hostnamectl set-hostname hostname, may also need to change /etc/hosts to suit

Setup NFS Client

I store my main mail directory (/var/vmail) off the VM and on a shared server drives.

NFS Client setup details

This my old email server setup notes. This is for older Ubuntu servers and many of these links are no longer working or have not been updated for latest Ubuntu releases.
These setup notes are not compatible with my current email setup.

My Email Server History, really tl;dr:

My current email server is based upon Debian 10 (Buster) with setup following, ISPmail on Debian Buster – your mail server workshop.
The major change is that I place my mail directory on a separate network attached drive.
I had a problem with my DNS setup that made the server fail. Use of Telnet helped find this fault as most the other tool were silent on the exact error. Telnet in to the server showed the wrong server / IP address. The setup indicated that these types of faults are commonly DNS issues.

The dovecot configuration files are located at: /etc/dovecot/conf.d/. (This is mention in the setup discription.)
The “postconf” command conveniently adds configuration lines to your /etc/postfix/main.cf file. It also activates the new setting instantly so you do not have to reload the Postfix process.

Old Email Server Setup, Historical tl;dr:

My server usage is complicated by my infrequent usage. This is particularly true of email server setup which one of the more complex setup. The other one is the router set-up which includes firewater and vpn. I tend to use other peoples descriptions “formula” to assist with email server set up e.g. Workaround.org; Creating a TLS encryption key and certificate. Whereas for my router setup I have more fully created my own notes.

Unfortunately the certbot site instructions certbot instructions call up the use for snaps. I do not like using snaps. In Debian and presumably Ubuntu the certbot package can be used sudo apt install certbot.

Workaround uses the certonly option of certbot sudo certbot certonly --webroot --webroot-path /var/www/mail.kptree.net -d mail.kptree.net. This works straight away and well. Unfortunately later on in the Roundcube webmail the appache2 configuration file has the DocumentRoot changes to the roundcube location, that seems to stop the auto renew function of the certbot certonly setup from working, as it was originally set up with a different document root! To allow certbot to function with the new DocumentRoot I needed to add the following to the apach2 site configuration file sudo vim /etc/apache2/sites-available/mail.kptree.net-https.conf:

 Alias /.well-known /var/www/mail.kptree.net

Some other related handy commands

Some other online references

A quick and dirty description to help with the email client setup, SMTP and IMAP or POP3

A quick and dirty description to help with the email client setup, SMTP and IMAP or POP3 for Gmail and MSOutlook (Hotmail)

My current email server is based upon Debian 10 (Buster) with setup following, ISPmail on Debian Buster – your mail server workshop. These setup instructions include Roundcube Webmail server setup.

Old Webmail Setup, Historical tl;dr:

I never had much success with Horde, not sure how good it is and if it is worth the effort. Further to this I use Nextcloud, which probably provides a lot of the similar functionallity I need.

Install Horde 5 for Webmail tl;dr;

  • To confirm the status (start, stop and restart) mysql sudo systemctl status apache2
  • To login into mysql as root, with password prompt: sudo mysql -u root -p
  • Database commands:
    • To show databases: show databases;
    • To create database (where new database name is: dBase_NAME): create dBase_NAME
    • To list mySQL database sizes: SELECT table_schema “DB Name”, Round(Sum(data_length + index_length) / 1024 / 1024, 1) “DB Size in MB” FROM information_schema.tables GROUP BY table_schema;
    • To use a database: use databasename;
  • To show tables in a database: show tables;
  • Get external IP address wget http://ipinfo.io/ip -qO -
  • To check the current network hardware configuration ip a
  • To start (/stop /enable) the deluge daemon sudo systemctl start deluge
  • To start (/stop /enable) the deluge web interface daemon sudo systemctl start deluge-web
  • Systemd common commands (start / stop / restart / status) (enable / disable for boot control)
  • /mnt/shared/www/dokuwiki/data/pages/home_server/email_server.txt
  • Last modified: 2022-08-26 Fri wk34 10:43
  • by baumkp