web analytics

Enabling detailed debug log in imap

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.

IMAPDEBUGFILE=”imaplog.txt”

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 greproot@abc.com.

root@abc# cd /home/abc/mail/abc.com/greproot/

root@abc# touch imaplog.txt

root@abc# chown abc:abc imaplog.txt

root@abc# /scripts/restartsrv_courier

root@abc# /etc/rc.d/init.d/exim restart

The logging will not be enabled for existing sessions. Re-login to the account via imap, and tail the log.

root@abc# tail -f /home/abc/mail/abc.com/greproot/imaplog.txt

WRITE: 3 OK LOGIN Ok.^M
READ: NUMBER: 4
READ: ATOM: CAPABILITY
READ: EOL
WRITE: * CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE AUTH=PLAIN ACL ACL2=UNION^M
4 OK CAPABILITY completed^M
WRITE: 3 OK LOGIN Ok.^M
READ: NUMBER: 4
READ: ATOM: CAPABILITY
READ: EOL
WRITE: * CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE AUTH=PLAIN ACL ACL2=UNION^M
4 OK CAPABILITY completed^M
READ: NUMBER: 5
READ: ATOM: LOGOUT
READ: EOL
WRITE: * BYE Courier-IMAP server shutting down^M
5 OK LOGOUT completed^M
READ: NUMBER: 5
READ: ATOM: LOGOUT
READ: EOL
WRITE: * BYE Courier-IMAP server shutting down^M
5 OK LOGOUT completed^M
WRITE: 2 OK LOGIN Ok.^M
READ: NUMBER: 3
READ: ATOM: NAMESPACE
READ: EOL
WRITE: * NAMESPACE ((“INBOX.” “.”)) NIL ((“#shared.” “.”)(“shared.” “.”))^M
3 OK NAMESPACE completed.^M
READ: NUMBER: 4
READ: ATOM: LSUB
READ: QUOTED_STRING:
READ: ATOM: INBOX.*
READ: EOL
WRITE: * LSUB (\HasNoChildren) “.” “INBOX.Shift”^M
* LSUB (\HasNoChildren) “.” “INBOX.Archives.2014″^M
* LSUB (\HasNoChildren) “.” “INBOX.Archives.2012″^M
* LSUB (\HasNoChildren) “.” “INBOX.Archives.2013″^M
* LSUB (\HasChildren) “.” “INBOX.Archives”^M
* LSUB (\HasNoChildren) “.” “INBOX.Cron”^M
* LSUB (\HasNoChildren) “.” “INBOX.Disk Space”^M
* LSUB (\HasNoChildren) “.” “INBOX.Nagios”^M
* LSUB (\HasNoChildren) “.” “INBOX.Junk”^M
* LSUB (\HasNoChildren) “.” “INBOX.Drafts”^M
* LSUB (\HasNoChildren) “.” “INBOX.Trash”^M
* LSUB (\HasNoChildren) “.” “INBOX.Sent”^M
4 OK LSUB completed^M
READ: NUMBER: 5
READ: ATOM: LSUB
READ: QUOTED_STRING:
READ: ATOM: #shared.*
READ: EOL
WRITE: 5 OK LSUB completed^M
READ: NUMBER: 6
READ: ATOM: LSUB
READ: QUOTED_STRING:
READ: ATOM: shared.*
READ: EOL
WRITE: 6 OK LSUB completed^M
READ: NUMBER: 7
READ: ATOM: LIST
READ: QUOTED_STRING:
READ: ATOM: INBOX.*
READ: EOL

 

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>