Sometimes your might need to check for detailed logging in email. One of my friends was developing an email application and he wanted to check what was happening behind the screen when he received an email, moves it to another folder, deletes it etc.
Hence, we decided to enable detailed logging in imap. It was a cpanel server and we used the option imapdebug. Always keep a backup of the file you edit.
root@abc# cp -pv /usr/lib/courier-imap/etc/imapd /usr/lib/courier-imap/etc/imapd.bak.$(date +%F)
root@abc# vi /usr/lib/courier-imap/etc/imapd
Now uncomment the following line.
Now touch a file named imaplog.txt at the root of the account where you want to enable logging. Restart the courier service. Suppose I need to enable logging for firstname.lastname@example.org.