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
-
This will show who is currently logged into the Dovecot server
-
Tests authentication for a user
- This will fetch messages matching a given search query.
- Shows a lists of mailbox GUIDs and message UIDs matching a given search query.
Configuration Doc¶
- Get quota for email account
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
- Dovecot connections
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/
Dump all hibernate-related settings¶
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