Warning: vibe-coded but works on my system. Temp fix until Virtualmin get Debian Trixie compability.
This script automatically fixes Dovecot configuration on systems where Virtualmin generates outdated settings for newer Dovecot versions, such as those found in Debian 13 "Trixie" and other modern Linux distributions.
When managing mail for a domain (e.g., creating a domain, updating an SSL certificate), Virtualmin may write a dovecot.conf file with deprecated parameters. This will cause the Dovecot service to fail to start or reload.
This script detects and fixes the following common issues:
mail_locationis corrected tomail_pathdisable_plaintext_auth = nois corrected toauth_allow_cleartext = yesssl_cert = </path/to/certis corrected tossl_server_cert_file = /path/to/certssl_key = </path/to/keyis corrected tossl_server_key_file = /path/to/key
Before automating the fix, you should perform one manual configuration change. Newer Dovecot versions have a different default pop3_uidl_format. If this is not updated, POP3 clients may re-download all emails after the Dovecot upgrade. This setting is not touched by Virtualmin, so you only need to fix it once.
-
Open the POP3 configuration file:
nano /etc/dovecot/conf.d/20-pop3.conf
-
Find the
pop3_uidl_formatline. If it is commented out or missing, add it with the new default value:pop3_uidl_format = %{uid | hex(8)}%{uidvalidity | hex(8)} -
Save the file and restart Dovecot to apply:
systemctl restart dovecot
This script should be run automatically after Virtualmin makes changes. Follow these steps to install the script.
-
Download the Script Download the
fix_dovecot_config.shscript to your server.wget https://raw.githubusercontent.com/panariga/virtualmin-dovecot-trixie-fix/main/fix_dovecot_config.sh
-
Move and Make Executable Place the script in a standard location for system binaries and make it executable.
sudo mv fix_dovecot_config.sh /usr/local/sbin/ sudo chmod +x /usr/local/sbin/fix_dovecot_config.sh
Select one of the following methods to trigger the script automatically.
This is the cleanest method, as it hooks directly into Virtualmin's workflow.
- Log into Virtualmin as
root. - Navigate to the Virtualmin tab, then go to System Settings -> Virtualmin Configuration.
- Click on the Actions upon server and user creation category.
- Find the field named Command to run after making changes to a server.
- Enter the full path to the script:
/usr/local/sbin/fix_dovecot_config.sh - Click Save.
This method watches the configuration file for any changes and runs the script instantly. It's a great failsafe.
-
Install
inotify-tools:# Debian/Ubuntu sudo apt-get update && sudo apt-get install inotify-tools # CentOS/RHEL/Fedora sudo yum install inotify-tools
-
Create a systemd service file:
sudo nano /etc/systemd/system/dovecot-config-watcher.service
Paste the following content:
[Unit] Description=Dovecot Config Watcher for Virtualmin Fixes After=network.target [Service] Type=simple ExecStart=/bin/sh -c 'while inotifywait -e modify,close_write /etc/dovecot/dovecot.conf; do /usr/local/sbin/fix_dovecot_config.sh; done' Restart=always User=root [Install] WantedBy=multi-user.target
-
Enable and start the service:
sudo systemctl daemon-reload sudo systemctl enable --now dovecot-config-watcher.service
A simple, time-based approach that runs the script every minute.
- Open the root crontab for editing:
sudo crontab -e
- Add the following line to run the script every minute:
* * * * * /usr/local/sbin/fix_dovecot_config.sh > /dev/null 2>&1
The script is designed to be safe and efficient:
- It uses
grepto quickly check if any of the outdated parameters exist in/etc/dovecot/dovecot.conf. - If an old parameter is found, it uses
sedto replace it with the modern equivalent. - If any changes were made, it runs
dovecot -nto test the new configuration syntax. - Only if the test is successful, it proceeds to restart the Dovecot service using
systemctl. - If no changes are needed, the script exits silently without doing anything.
This project is licensed under the MIT License. See the LICENSE file for details.