How to Enable and Disable the Dovecot Mail Log Plugin

Valid for versions 100 through the latest version

Version:

98

100


Last modified: January 20, 2022

Overview

This document explains how to enable and disable the Dovecot mail log plugin. The additional entries to the /var/log/maillog log file can help you to 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 additional log entries will increase the size of the log files and cause the system to archive them more frequently.
  • In previous versions of cPanel & WHM, the system used the /var/cpanel/templates/dovecot2.3/ directory. In cPanel & WHM version 100 and later, the system now uses the /var/cpanel/templates/dovecot/ directory. If the /var/cpanel/templates/dovecot2.3/main.local file exists, the system will use that Dovecot configuration file until you create the /var/cpanel/templates/dovecot/main.local file.

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.default

    • If a template file does not exist, run the following command:
      cp -v /var/cpanel/templates/dovecot/main.{default,local}
  3. Create the /root/dovecot.patch file and add the following code to it:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    
    --- main.default    2019-06-21 22:05:20.149674248 -0500
    +++ main.local  2019-08-06 22:11:51.530089808 -0500
    @@ -767,7 +767,7 @@
     [% IF expire_trash %]
       mail_plugins = $mail_plugins expire
     [% END %]
    -  mail_plugins = $mail_plugins zlib imap_zlib quota_clone virtual [% IF xaps_topic %]imap_xaps[% END %] [% IF fts_support %]fts fts_solr[% END %]
    +  mail_plugins = $mail_plugins mail_log notify zlib imap_zlib quota_clone virtual [% IF xaps_topic %]imap_xaps[% END %] [% IF fts_support %]fts fts_solr[% END %]
       #mail_plugin_dir = /usr/lib/dovecot/imap
    
    
    @@ -1338,10 +1338,10 @@
     # mail_log plugin provides more event logging for mail processes.
     plugin {
       # Events to log. Also available: flag_change append
    -  #mail_log_events = delete undelete expunge copy mailbox_delete mailbox_rename
    +  mail_log_events = delete undelete expunge copy mailbox_delete mailbox_rename
       # Available fields: uid, box, msgid, from, subject, size, vsize, flags
       # size and vsize are available only for expunge and copy events.
    -  #mail_log_fields = uid box msgid size
    +  mail_log_fields = uid box msgid size
     }

  4. Run the following commands:

    1
    2
    
    patch -p1 /var/cpanel/templates/dovecot/main.local < /root/dovecot.patch
    /scripts/builddovecotconf && /scripts/restartsrv_dovecot

To view the log file, run the following command:

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. Run the following commands:

    1
    2
    
    mv -vi /var/cpanel/templates/dovecot/main.local{,.bak}
    /scripts/builddovecotconf && /scripts/restartsrv_dovecot

Additional Documentation