How to Enable and Disable the Dovecot Mail Log Plugin

Valid for versions 132 through the latest version

Version:

104

132

Last modified: 2026 February 19


Overview

This document explains how to enable and disable the Dovecot mail log plugin. The additional entries to the /var/log/maillog file can help you diagnose issues with mail delivery.

The plugin will add the following entries to the log file:

  • Setting and removing the \Deleted flag
  • Expunging (includes autoexpunge)
  • Copying mails to another mailbox
  • Mailbox creations
  • Mailbox deletions
  • Mailbox renames
  • Any flag changes
  • Saves
Important:
  • The mail log plugin is not configurable through the WHM interface. To enable or disable it, you must manually update the Dovecot configuration templates and rebuild the Dovecot configuration.
  • The additional log entries will increase the size of the log files and cause the system to archive them more frequently.
  • The system uses the /var/cpanel/templates/dovecot/ directory to generate Dovecot configuration. To make persistent changes, you must create and edit a local template in this directory.

Enable the Dovecot mail log plugin

To enable the Dovecot mail log plugin, perform the following steps:

  1. Log in to your server via SSH as the root user.

  2. Run the following command to determine if a local template file already exists:

    stat /var/cpanel/templates/dovecot/main.local
    • If a template file does not exist, create one by running the following command:
      cp -v /var/cpanel/templates/dovecot/main.{default,local}
  3. Open the local template file in a text editor:

    vi /var/cpanel/templates/dovecot/main.local
  4. Locate the mail_plugins {} block. Ensure that the mail_log and notify plugins are enabled in the appropriate mail_plugins configuration. For example:

    1
    2
    3
    4
    5
    6
    7
    8
    
    mail_plugins {
        quota = yes
        mail_compress = yes
        imap_quota = yes
        virtual = yes
        mail_log = yes
        notify = yes
    }
    Note:

    If the template already defines protocol_imap.mail_plugins, add the mail_log and notify plugins to that configuration instead of the default mail_plugins block.

  5. Locate an existing plugin {} block. If one does not exist, create it. Add or update the following settings:

    1
    2
    3
    4
    
    plugin {
        mail_log_events = delete undelete expunge copy mailbox_delete mailbox_rename
        mail_log_fields = uid box msgid size
    }
  6. Rebuild the Dovecot configuration and restart the service:

    /scripts/builddovecotconf && /scripts/restartsrv_dovecot

To verify that the plugin is logging events, run the following command and perform a mail action, such as moving or deleting a message:

tail -fn0 /var/log/maillog

Disable the Dovecot mail log plugin

To disable the Dovecot mail log plugin, perform the following steps:

  1. Log in to your server via SSH as the root user.

  2. Remove or rename the local Dovecot template file:

    mv -vi /var/cpanel/templates/dovecot/main.local{,.bak}
  3. Rebuild the Dovecot configuration and restart the service:

    /scripts/builddovecotconf && /scripts/restartsrv_dovecot

Additional Documentation