This is an old revision of the document!


KPTree - Email Server Setup

Email Server Notes

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 actually like to use netplan

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

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

  • sudo apt install nfs-common
    • The base client configurations options are given in: sudo vim /etc/default/nfs-common. However the current base options meet our needs and do not need to be modified.
      • NEED_STATD=no :(default) we do not need to change the standard port number used
      • NEED_GSSD=no :(default) we do not use kerebos security
      • NEED_IDMAPD=no:(default) we do not need to map gid and uid with names
      • To apply configuration changes sudo systemctl restart nfs-client.target
    • Mounting the nfs client manually:
      • sudo mount -t nfs -o rw,vers=4 192.168.1.10:/export/storage /mnt/storage to mount just the specific directory. The mount directory must already exist.
      • sudo mount -t nfs -o rw,vers=4 192.168.1.10:/export /mnt to mount all the defined exports. The mount directory must already exist, not necessarily the sub-directories.
      • sudo unmount /mnt/storage to unmount
    • Check status of clients:
      • findmnt to list file system in tree format or findmnt -l in flat list.
      • df -h to list all mounted drives
      • lsblk to list all drive
  • To allow automatic boot of nfs clients: sudo vim /etc/fstab
    • 192.168.1.10:/export /mnt nfs4 bg 0 0 this will mount all the drive defined on the server as sub-directories under
    • 192.168.1.10:/export/shared /mnt/shared nfs4 bg 0 0 to mount a single sub-directory

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)
  • /app/www/public/data/attic/home_server/email_server.1642210272.txt.gz
  • Last modified: 2023-04-30 Sun wk17 17:44
  • (external edit)