How to Enable and Disable the Dovecot Mail Log Plugin
Valid for versions 104 through the latest version
Version:
104
Last modified: February 19, 2024
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.
- The system now the
/var/cpanel/templates/dovecot/
directory.
Enable the Dovecot mail log plugin
To enable the Dovecot mail log plugin, perform the following steps:
-
Log in to your server via SSH as the
root
user. -
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}
- If a template file does not exist, run the following command:
-
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 2022-05-04 18:43:43.231310505 +0000 +++ main.local 2022-08-05 05:00:33.996931597 +0000 @@ -669,7 +669,7 @@ [%- ELSE %] #mail_plugins = acl quota imap_quota [%- 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 @@ -1251,10 +1251,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 }
-
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:
- Log in to your server via SSH as the
root
user. - Run the following commands:
1 2
mv -vi /var/cpanel/templates/dovecot/main.local{,.bak} /scripts/builddovecotconf && /scripts/restartsrv_dovecot