This repo is a work-in-progress for pymailadmin, a Dovecot-based mail server web admin for users and admins. It is a Python3/gunicorn systemd-compliant app, listening on 127.0.0.1:8686 by default.
It aims at being compatible with any mail server setups, given they are based on Dovecot interfaced with MySQL lookups and using a functional mail-crypt plugin setup.
NOT TO USE IN PRODUCTION
- Administrate your Dovecot-based encrypted mail server
- Uses your Dovecot database without altering it.
- Uses the Dovecot HTTP API.
- Supports registering as a new mailbox user.
- Users manage their mailboxes and aliases on their own.
- Supplies a moderation interface for new registrations.
- Supports maximum mailboxes number and maximum aliases number per mailbox.
- When password change for a mailbox, a rekey occurs and mailbox is disabled for storage to be reencrypted.
- Supports a web frontend admin server separated from you Dovecot mail server.
System:
- A Debian-based system (tested on Debian 13 "trixie" only).
- A fully functional mail server running Dovecot 2.4.1+ for auth and mail management.
- A fully functional Dovecot installation, talking to a MySQL/MariaDB database.
- A fully functional Dovecot
mail-cryptplugin setup for mail storage encryption. - An acceptable hash algorithm for mail passwords. pymailadmin supports the following algorithms ONLY:
argon2idargon2ibcryptsha512-cryptsha256-cryptpbkdf2
Dovecot database:
- A special field in your users' table for enabled/disabled mailboxes (values: 0|1).
And a bit of patience and easy-going on the Python code quality.
Change 3 foreign keys references in schema.sql.
Replace "users(id)" with your own table and column names, those storing the actual users IDs:
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
FOREIGN KEY (`user_id`) REFERENCES users(id) ON DELETE CASCADE
Replace "domain(id)" with your own table and column names, those storing the actual domains IDs:
FOREIGN KEY (`domain_id`) REFERENCES `domain`(`id`) ON DELETE CASCADE
mysql -udbuser -p dbname < schema.sql
apt update
apt install python3 python3-pip python3-venv python3-dev
adduser --system --group --no-create-home --disabled-login pymailadmin
Copy/clone repository somewhere, e.g. /var/www/pymailadmin, then:
python3 -m venv /var/www/pymailadmin/venv
source /var/www/pymailadmin/venv/bin/activate
cd /var/www/pymailadmin && pip3 install -r requirements.txt
cp pymailadmin.service /etc/systemd/system/
You will mostly have to pay attention when customizing the tables and fields names for Dovecot.
cd /var/www/pymailadmin && cp .env.example .env
vim .env
mkdir /var/log/pymailadmin
chown -R pymailadmin: /var/log/pymailadmin
chmod -R 755 /var/log/pymailadmin
chown -R pymailadmin:pymailadmin /var/www/pymailadmin
chmod -R 750 /var/www/pymailadmin
Allow your web server user (www-data, httpd, etc.) to reach static dir:
setfacl -R -m u:www-data:rx /var/www/pymailadmin/static
setfacl -m u:www-data:rx /var/www/pymailadmin
mkdir /var/log/pymailadmin
chown -R pymailadmin: /var/log/pymailadmin
chmod -R 755 /var/log/pymailadmin
chown -R pymailadmin:pymailadmin /var/www/pymailadmin
chmod -R 750 /var/www/pymailadmin
vim /etc/systemd/system/pymailadmin.service
systemctl daemon-reload
cp pymailadmin.nginx.conf /etc/nginx/sites-available/pymailadmin.conf
ln -s /etc/nginx/sites-available/pymailadmin.conf /etc/nginx/sites-enabled/
vim /etc/nginx/sites-enabled/pymailadmin.conf
systemctl reload nginx
Make sure you have a TLS certificate (with certbot or another tool).
systemctl enable --now pymailadmin.service
- Create a salted hash of your password, here's an example for an Argon2ID hash:
echo -n 'My@Pass*word!' | argon2 "$(pwgen -Ans 16 1)" -id -t 3 -p 2 -m 16 -e
- Create a superadmin in your database:
INSERT INTO pymailadmin_admin_users (email, password_hash, role, active) VALUES ('email@example.org', '$argon2id$v=19$m=65536,t=3,p=2$XXXXXXXXXXXXIXX', 'super_admin', '1');
- Go to
https://mydopemailadmin.domain.tld - Enjoy new incoming bugs and problems.
Ce dépôt est un travail en cours pour pymailadmin, une interface web d'admin de serveur mail Dovecot pour les utilisateur⋅ices et admins. C'est une application Python3/gunicorn compatible systemd, écoutant sur 127.0.0.1:8686 par défaut.
Le but est d'être compatible avec toute installation de serveur mail, basée sur Dovecot interfacé à MySQL et avec le plugin mail-crypt fonctionnel.
A NE PAS UTILISER EN PRODUCTION
- Administrez votre serveur de mail chiffré basé sur Dovecot.
- Utilise votre base de données Dovecot sans l'altérer.
- Utilise l'API HTTP de Dovecot.
- Prend en charge l'inscription utilisateur⋅ice.
- Les utilisateur⋅ices gèrent leurs boites et leur alias en autonomie.
- Fournit une interface de modération pour les admins.
- Les utilisateur⋅ices gèrent leurs boites mails et leur alias.
- Prend en charge un nombre maximum de boites mail et d'alias par boite.
- Quand le mot de passe de la boite mail change, un rechiffrement est créé et la boite est désactivée pour le rechiffrement.
- Prend en charge un serveur web frontal séparé de votre serveur mail Dovecot.
Système :
- Un seveur basé sur Debian (testé uniquement sur Debian 13 "trixie").
- Un serveur mail fonctionnel basé sur Dovecot 2.4.1+ pour l'authentification et la gestion des boites mail.
- Dovecot fonctionnel, interfacé à une base de données MySQL/MariaDB.
- Le greffon
mail-cryptfonctionnel pour le chiffrement du stockage des mails. - Un algorithme de hashage acceptable pour les mots de passe mail. pymailadmin prend en charge UNIQUEMENT :
argon2idargon2ibcryptsha512-cryptsha256-cryptpbkdf2
Base de données pour Dovecot:
- Un champ spécial dans la tables des boites mail pour les boites actives/inactives (valeurs: 0|1).
Et un peu de patience et d'indulgence sur la qualité du code Python.
Changez les 3 références des clefs étrangères dans schema.sql.
Remplacez "users(id)" avec vos propres noms de table et de colonne, ceux qui stockent les ID des utilisateurs :
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
FOREIGN KEY (`user_id`) REFERENCES users(id) ON DELETE CASCADE
Remplacez "domain(id)" avec vos propres noms de table et de colonne, ceux qui stockent les ID des domaines :
FOREIGN KEY (`domain_id`) REFERENCES `domain`(`id`) ON DELETE CASCADE
mysql -udbuser -p dbname < schema.sql
apt update
apt install python3 python3-pip python3-venv python3-dev
adduser --system --group --no-create-home --disabled-login pymailadmin
Copier/clonez le dépôt quelque part, par ex. : /var/www/pymailadmin, puis :
python3 -m venv /var/www/pymailadmin/venv
source /var/www/pymailadmin/venv/bin/activate
cd /var/www/pymailadmin && pip3 install -r requirements.txt
cp pymailadmin.service /etc/systemd/system/
Vous aurez notamment à bien faire attention en personnalisant les noms des tables et des champs pour Dovecot.
cd /var/www/pymailadmin && cp .env.example .env
vim .env
mkdir /var/log/pymailadmin
chown -R pymailadmin: /var/log/pymailadmin
chmod -R 755 /var/log/pymailadmin
chown -R pymailadmin:pymailadmin /var/www/pymailadmin
chmod -R 750 /var/www/pymailadmin
Autorisez votre serveur HTTP (www-data, httpd, etc.) à atteindre le répertoire static :
setfacl -R -m u:www-data:rx /var/www/pymailadmin/static
setfacl -m u:www-data:rx /var/www/pymailadmin
vim /etc/systemd/system/pymailadmin.service
systemctl daemon-reload
cp pymailadmin.nginx.conf /etc/nginx/sites-available/pymailadmin.conf
ln -s /etc/nginx/sites-available/pymailadmin.conf /etc/nginx/sites-enabled/
vim /etc/nginx/sites-enabled/pymailadmin.conf
systemctl reload nginx
Assurez-vous d'avoir un certificat TLS (via certbot ou autre).
systemctl enable --now pymailadmin.service
- Créez un hash salé de votre mot de passe, ici par exemple pour Argon2ID :
echo -n 'My@Pass*word!' | argon2 "$(pwgen -Ans 16 1)" -id -t 3 -p 2 -m 16 -e
- Créez un⋅e superadmin dans la base de données :
INSERT INTO pymailadmin_admin_users (email, password_hash, role, active) VALUES ('email@example.org', '$argon2id$v=19$m=65536,t=3,p=2$XXXXXXXXXXXXIXX', 'super_admin', '1');
- Allez sur
https://mydopemailadmin.domain.tld - Appréciez les nouveaux bogues et problèmes qui s'annoncent.