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.
VM Setup
Set network IP address, static IP
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 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 orfindmnt -l
in flat list.df -h
to list all mounted driveslsblk
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 under192.168.1.10:/export/shared /mnt/shared nfs4 bg 0 0
to mount a single sub-directory
Old Email Setup Notes
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.
Email Server Setup
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.
Certificate Notes
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
Email Client Setup Hint
Email Client Setup Hints (Gmail and Outlook)
Webmail Installation
Install Roundcube for Webmail
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.
Install Horde 5 for Webmail
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.
The following is a list of related commonly used SQL commands:
- 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;
The following is a list of related commonly used commands and scripts:
- 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)