Reinstall email because it has been corrupted

I have the latest version of Hestia CP installed on a VPS running Ubuntu 24.04 with nginx. My email was working perfectly, but when I tried to install the Sieve plugin, that’s when the disaster started. Since it wasn’t working, I followed the instructions from a technician at my hosting company. After hours of making modifications, my email is now completely unusable. I had made a full backup before changing anything. I wanted to know if Hestia has a tool to completely remove everything related to email, so I can then reinstall everything, restoring it to its original state as when I installed the full control panel.

:warning: The Safest Approach: HestiaCP Community Script

The HestiaCP community has developed a dedicated script for purging, reinstalling, and reconfiguring Exim4 to use the correct HestiaCP templates. Use this only if Exim4 is genuinely broken and standard restarts/rebuilds have failed.

Step 1: Backup Exim Configuration (Always!)

Bash

mkdir -p /root/backup_etc_exim4/
cp -prf /etc/exim4/ /root/backup_etc_exim4/

Step 2: Execute the Reinstall Script

This script will attempt to fully purge, reinstall, and configure Exim4 correctly using the latest HestiaCP templates.

Bash

curl -fsSLm15 https://7j.gg/instexim | sudo bash -s --

Step 3: Check Status

After the script completes, check if Exim4 is running correctly:

Bash

systemctl status exim4 --no-pager -l

If the status is active (running), the service has been successfully reinstalled and reconfigured.


:gear: If Exim4 is Installed but Broken (Rebuild Config)

If Exim4 is installed but has configuration errors (e.g., mail is stuck in the queue or ports aren’t listening), you might only need to rebuild the HestiaCP mail configurations without purging and reinstalling the entire package.

1. Rebuild Mail Domains

This command regenerates the Exim and Dovecot configuration files based on the HestiaCP control panel settings for a specific domain. Run this for every mail domain you have.

Bash

# Syntax: v-rebuild-mail-domains <user> <domain>
v-rebuild-mail-domains admin example.com

2. Restart Services

Always restart the services after rebuilding configurations:

Bash

v-restart-service exim4
v-restart-service dovecot

Bash

systemctl status exim4 --no-pager -l
dpkg -l | grep exim4