Local Mail Server

You have a server with web applications for training sessions, and you need a local mail server to keep all emails on this server. When the training session is done, delete this server, and also all emails are removed. Nothing remains.

I am running ubuntu server 20.04 lts.

Install postfix (SMTP), and also dovecot (IMAP), with one command. Choose localhost.

$ sudo tasksel install mail-server

We disable SSL since anything runs local. If you have chosen localhost, then our new mail server won’t listen to anything than localhost.

$ sudo vi /etc/dovecot/conf.d/10-ssl.conf

# SSL/TLS support: yes, no, required. <doc/wiki/SSL.txt>
#ssl = yes
ssl = no

We want SASL authentication delegated to dovecot. These parts need to be added. Read the related documentation for ubuntu server: https://ubuntu.com/server/docs/mail-postfix For your convenience, beneath all affected files.

Read the docs! My settings beneath does 99 percent. For the rest, read the docs!

# sudo vi /etc/postfix/main.cf

smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
# … you may want to configure a few more lines here
# /etc/dovecot/conf.d/10-master.conf

unix_listener auth-userdb {
  #mode = 0666
  #user = 
  #group = 

# Postfix smtp-auth
unix_listener /var/spool/postfix/private/auth {
  mode = 0666
  user = postfix
  group = postfix
# /etc/dovecot/conf.d/10-auth.conf

auth_mechanisms = plain

# to this:

auth_mechanisms = plain login

Restart postfix and dovecot. When you did anything well, you have your mail server listing on the related ports.

Install a pretty, and well working web client for emails.

$ sudo apt install php-pgsql
$ sudo apt install postgresql
$ sudo apt install apache2 # if you haven't done this already
$ sudo apt install roundcube

Roundcube settings. Read the docs!

# /etc/roundcube/config.inc.php

$config['default_host'] = 'localhost';
$config['smtp_server'] = 'localhost';
$config['smtp_port'] = 25;
$config['default_port'] = 143;
$config['mail_domain'] = 'mail.local';
# … and a few more things you may like to configure

Make /mail Roundcube alias. That means if you call something like


Roundcube will appear in your browser.

# /etc/roundcube/apache.conf

# Those aliases do not work properly with several hosts on your apache server
# Uncomment them to use it or adapt them to your configuration
#    Alias /roundcube /var/lib/roundcube
Alias /mail /var/lib/roundcube

Login with your Linux user. For example, if your Linux username is „firstlastname“ then use it for Roundcube, too. The same for your password.