This application manages domains, users and aliases of a mail server.
This has been tested with dovecot, using either mysql or postgresql database.
The main goal was to enhance/replace Jeffrey Boehm’s PHP mailserver-admin application because I didn’t want to have a mail server administration application in PHP and I wanted to have administration account per domain.
Required:
DJANGO_SECRET_KEY
: at least 40 characters. Should be specified for production.DJANGO_DB_TYPE
:postgres
ormysql
, default tomysql
.DJANGO_DB_HOST
: database hostname, default todb
(for use in docker-compose).DJANGO_DB_PORT
: database port, default to empty (default port).DJANGO_DB_NAME
: database name, default tomailserver
.DJANGO_DB_USER
: database user, default tomailserver
.DJANGO_DB_PASSWORD
: database password, default tochangeme
.
Optional:
DJANGO_DEBUG
: defaultFalse
. Set toTrue
to enable debug toolbar, more logs and static files served.DJANGO_LOG_LEVEL
: default toWARNING
(INFO
ifDJANGO_DEBUG
).DJANGO_RUNSERVER_LOG_LEVEL
: default toINFO
(DEBUG
ifDJANGO_DEBUG
). Used only when run withrunserver
orrunserver_plus
.DJANGO_TZ
: timezone, defaut toUTC
.DJANGO_DKIM_PATH
: directory path to store dkim private key and selectors. To be used byrspamd-dkim
. Default to/etc/dkim
.DJANGO_WEBMAIL_URL
: webmail url to show in the footer, default to no link.DJANGO_VENDOR_NAME
: any vendor name you want to appear on the footer, default to Sources.DJANGO_VENDOR_URL
: any url you want to be linked to your vendor name, default to this repository url. Set to empty to disable the link.DJANGO_HIDE_VERSION
: defaultFalse
ifDJANGO_DEBUG
elseTrue
. Set toTrue
to hide themailserver-admin
version.
Using docker
directly:
docker run --name msa \
-p 80:80 \
-e DJANGO_SECRET_KEY=12345678901234567890abcdefghijklmnopqrstuvwxyz \
-e DJANGO_DB_TYPE=mysql \
-e DJANGO_DB_PASSWORD=pwd \
--link yourmariadb:db \
jrdasm/mailserver-admin:<version>
docker exec -ti msa pipenv run ./manage.py createsuperuser
Of course this is simple using docker-compose
:
...
services:
db:
image: mariadb
environment:
- "MYSQL_RANDOM_ROOT_PASSWORD=yes"
- "MYSQL_DATABASE=mailserver"
- "MYSQL_USER=mailserver"
- "MYSQL_PASSWORD=pwd"
...
msa:
image: jrdasm/mailserver-admin:<version>
environment:
- "DJANGO_SECRET_KEY=12345678901234567890abcdefghijklmnopqrstuvwxyz"
- "DJANGO_DB_TYPE=mysql"
- "DJANGO_DB_NAME=mailserver"
- "DJANGO_DB_USER=mailserver"
- "DJANGO_DB_PASSWORD=pwd"
ports:
- "80:80"
...
docker-compose exec msa pipenv run ./manage.py createsuperuser
Minium python version is 3.9.
Use:
pipenv install mailserver-admin
to install it without any database backend.
If you want to install the mysql
or postgresql
database backend alongside, use for instance:
pipenv install mailserver-admin[mysql]
Define the required environment variables then:
export DJANGO_SETTINGS_MODULE=mailserveradmin.config.settings
pipenv run django migrate
pipenv run django createsuperuser
You can use pipenv run django migrate --fake-initial
if you already have a mysql or postgresql database with existing schema/data.
You can now server the application using any WSGI server pointing to $(VISUAL='readlink -f' pipenv open mailserveradmin|tail -n1)/config/wsgi.py
.
Don’t forget to also serve static ressources located at $(VISUAL='readlink -f' pipenv open mailserveradmin|tail -n1)/to_serve
folder.
You can of course make symlinks to those locations to simplify configuration.
Use:
pipenv sync -d
to install dependencies. Default python version is 3.9.
You should also install a database driver, either mysqlclient
or psycopg2-binary
:
pipenv run pip install mysqlclient
Define the required environment variables then:
pipenv run ./manage.py migrate
pipenv run ./manage.py createsuperuser
pipenv run ./manage.py collectstatic
You can now server the application using any WSGI server pointing to the config/wsgi.py
file.
Don’t forget to also serve the static/
folder.
Alternatively, you can test the application with pipenv run ./manage.py runserver_plus
but this should only be used for testing/development.