Skip to content

Dovecot commands

Dovecot is an open-source IMAP and POP3 email server

  • Config file /etc/dovecot/dovecot.conf

  • Locate, test, or reopen Dovecot's log files

    doveadm log
    
  • This will show who is currently logged into the Dovecot server

    doveadm who
    
  • Tests authentication for a user

doveadm auth
  • This will fetch messages matching a given search query.
doveadm fetch
  • Shows a lists of mailbox GUIDs and message UIDs matching a given search query.

doveadm search
- This will inspect or reset stats.
doveadm stats

Configuration Doc

Config

  • Get quota for email account
doveadm quota get -u email@account.com 
doveadm mailbox list -u test@newmaindomain.tld | while read i ; do echo "${i}" $(doveadm mailbox status -u test@newmaindomain.tld vsize "${i}" | cut -d \= -f2 | awk '{ byte =$1 /1024/1024; print byte " MB" }');done
  • Reindex users
    /usr/local/cpanel/3rdparty/scripts/cpanel_dovecot_solr_rebuild_index
    
doveadm fts rescan -u user@example.com
doveadm index -u user@example.com '*'
  • Dovecot connections
    journalctl -u dovecot --since "30 min ago" | grep auth_failed | awk {'print $19'} | cut -d \, -f1 | sort | uniq -c | sort -nr | head
    
ss -x -a | grep anvil

Dovecot / anvil / imap-hibernate Troubleshooting Commands

Check previous boot logs

journalctl -b -1 --no-pager


Show connected IMAP users/sessions

doveadm who

Count active sessions

doveadm who | wc -l


Extract IPs from doveadm who output

doveadm who | sed -n 's/.*(\(.*\))$/\1/p' | sort | uniq -c | sort -nr | head


Check total dovecot TCP connections

netstat -antp | grep dovecot | wc -l


View dovecot process tree

ps auxf | grep dovecot


Check Dovecot version

dovecot --version


Restart Dovecot

systemctl restart dovecot


Monitor anvil threads CPU usage

top -H -p $(pgrep anvil)

Alternative CPU monitoring

pidstat -p $(pgrep anvil) 1


Trace anvil system calls

strace -p $(pgrep anvil)

Trace with timestamps

strace -tt -p $(pgrep anvil)


Check IMAP hibernate timeout

doveconf imap_hibernate_timeout


Search for hibernate config in dovecot configs

grep -Ri imap_hibernate_timeout /etc/dovecot/


doveconf -a | grep -i hibernate


Show IMAP protocol-specific config

doveconf -P imap


Check if imap-hibernate service exists

doveconf -a | grep imap-hibernate


Check running imap-hibernate processes

ps aux | grep imap-hibernate


Disable IMAP hibernation

Add/change in dovecot.conf:

imap_hibernate_timeout = 0


Enable IMAP hibernation after 30 seconds idle

Add/change in dovecot.conf:

imap_hibernate_timeout = 30s


Verify no sessions are hibernated

doveadm who | grep imap-hibernate


Search mail logs for disconnect/auth issues

grep -Ei 'Disconnected|Aborted login|auth failed|Too many connections' /var/log/maillog | tail -200


Dump Dovecot stats

doveadm stats dump


Count hibernated sessions

doveadm who | grep imap-hibernate | wc -l


Disconnect all sessions (testing only)

doveadm kick '*'


imaptest (load testing)

Single client

imaptest host=mail.example.com user=user pass=pass

Multiple concurrent clients

imaptest -clients=200 host=mail.example.com user=user pass=pass