3. Thou shalt remember the 30 minute inactivity timeout, and remember to speak to the IMAP server before that timeout expires. If thou useth the IDLE command, thou shalt send DONE from the IDLE before 29 minutes hath passed, and issue a new IDLE. If thou maketh no use of IDLE, then thou shalt send NOOP every few minutes, and the server shalt tell you about new mail, and there will be much rejoicing in the

Mark Crispin: Ten Commandments of How to Write an IMAP client (UW IMAP Server Documentation)