IMAP is Easy

September 26, 2012

The IMAP protocol, like SMTP and POP3, is a text based protocol. This kind of protocol can be processed by hand using a telnet client or other similar interactive terminal.

I just modified the Auto Responder to use IMAP instead of POP3 as its mail retrieval protocol. The reason for this is to get a quicker response to email messages without risking internal code and operating system problems associated with opening large numbers of internet connections too quickly. The POP3 protocol handles one set of mail retrieval commands per session and the connection must be closed and then opened again to get any emails that show up while the connection was previously open. In fact, a server might even allow only one POP3 connection at a time to a given mail account.

IMAP is a protocol that works with a long standing connection. There is no need to disconnect from the server to see any change in status of the server mail system.

The only problem with IMAP is in its complexity. It is not quite as simple as POP3 and I am still learning some of the issues with it. One issue is that it is designed to keep main on the server instead of on the client. Although I plan on ignoring this feature and deleting all messages once they have been retrieved, keeping messages around might be handy in the future. But because messages are kept on the server, mailboxes must be managed as well as the individual messages in them. POP3 has no concept of a mailbox and messages are only ever seen when they are in the default inbox for the mail account.

Another interesting issue with IMAP is in how it handles message content. It is possible to get the entirety of an email message although it is not clear to me how to detect the end of the message.

Read about the Auto Responder for more information as to why I am working with email protocols.