IMAP (Internet Message Access Protocol) is an email protocol. It differs from other commonly used email protocols such as POP3 in that it is much richer, which means the email client (aka Mail User Agent or MUA) can ask the server to perform more sophisticated operations, which usually saves time (or at least, that's the idea). IMAP also allows you to keep your emails on a central server and access those emails from varied locations and platforms (e.g. at home, at the office, on holiday, while visiting friends).

IMAP is currently at version 4, revision 1, which is commonly abbreviated to IMAP4rev1, and is described in RFC2060, written by Mark Crispin.

One of IMAP's characteristics is to minimise the load on the network link between client and server. More efficient use of the link is especially useful when the link has high latency and/or low bandwidth. To achieve this, IMAP has a relatively rich search/query language (compared to POP3), which enables much of the querying/searching to be done on the server-side - which obviously helps reduces the amount of data sent between client and server.

In the case where the connection is 'high' quality (e.g. a LAN), IMAP is still very useful because it is designed to allow the server to store the user's mailboxes permanently (this can be achieved with POP3, but it is not recommended, and is much less convenient or efficient than using IMAP). This means a user can access their email on a central IMAP server from a number of different MUAs on different platforms and geographical locations, and still be able to keep track of new messages, and access any or all of the email messages stored on the IMAP server.

Most IMAP-savvy MUAs will cache message contents in a local email database if the messages have ever been downloaded from the server, but it is perfectly possible to connect to an IMAP server from an IMAP client you have never used, and browse mailboxes, search for messages and read any message stored in your mailboxes on the IMAP server.

IMAP also provides specific access to individual components of a message, such as the body text, any MIME attachments, and so on. Again, this allows more efficient use of the server/client link.

A number of supplementary RFCs add various extensions to the IMAP4rev1 specification, such as stronger authentication methods, transparent server forwarding, access control lists, and so on.

Support for IMAP in MUAs has been historically a bit patchy, with varying levels of quality with respect to compatibility, efficiency, reliability and user interface, but this should improve with time.

I've recently started keeping all my mail (all 140MB worth of text!) on my web hosting provider's server, in order that I might switch easily between MUAs and client machines.

While I trust them to do backups, I don't trust them so much that I don't want my own backups to have my mail folders too. Therefore, a very simple script to backup IMAP folders to plain files. (This of course is only useful if you don't have access to the folders themselves...)


#!/usr/bin/perl

use Net::IMAP::Simple;
$| = 1;

$server = new Net::IMAP::Simple( 'your.imap.server' );
$server->login( 'username', 'password' );

@folders = $server->mailboxes();

foreach $folder ( @folders )
{
    open (FOLDOUT,">~/IMAPbk/$folder");
    $count = $server->select( $folder );
    print "$folder has $count messages, fetching";
    foreach $msg ( 1 .. $count )
    {
        print ".";
        $fh = $server->getfh( $msg );
        print FOLDOUT <$fh>;
        close $fh;
    }
    print "\n";
}

$server->quit();

IMAP, the Internet Message Access Protocol, was designed to transfer email over the internet. In particular, it allows a remote client to manipulate messages and mailboxes on a server. It doesn't, however, provide a method of posting new messages, a function usually handled by the complementary SMTP protocol; IMAP is for reading and managing mail only.

IMAP improves upon the other major email reading protocol, POP3. POP3 servers generally hold mail only until it is read by a client. It is then up to the mail client to store the messages on the client machine. POP3 was designed with short-lived dialup connections in mind, and so it only requires a short connection to the mail server to download the mail, after which the mail can be read offline. But after the transfer, the received mail is only available on the client computer. IMAP was designed with continuous online connections in mind. It permits the mail to reside on the server, and the client can download messages on demand. Usually, the messages are retained on the server, but there is no reason why an IMAP client can't download all the mail just like with POP3.

IMAP also knows about the structure of email messages. Server side searches of messages are possible, and if a message is MIME encoded, attachments can be downloaded separately from the message body.

An IMAP server will listen on TCP/IP port 143. The following RFCs define the IMAP protocol and it's extensions:

  • 1730 - The original IMAP4 RFC
  • 1731 - IMAP4 authentication mechanisms
  • 2060 - IMAP4rev1 updates
  • 2086 - Access control list extension
  • 2087 - Quota extension
  • 2088 - Literal+ extension (requires fewer transactions when reading mail)
  • 2177 - Idle extension (allows client to receive asynchronous change notifications, rather than polling)
  • 2192 - IMAP URL Scheme
  • 2193 - Mailbox referrals (allows servers to reference remote mailboxes via URL)
  • 2195 - CRAM-MD5 authentication (allows authentication with simple, cryptographically secure, challenge response protocol)
  • 2221 - Login referrals (allows servers to proxy)
  • 2342 - Namespace extension
  • 2359 - UID+ extension
  • 2595 - TLS (SSL) extension (IMAP over Secure Sockets Layer)

IMAP was originally implemented in the University of Washington IMAP server, but many other common mail servers support the IMAP protocol, including Microsoft Exchange Server, Cyrus IMAP, and Courier. The PINE email program, also developed at the University of Washington, was the first of many IMAP clients, like Netscape Messenger, Eudora, and Outlook.

Log in or register to write something here or to contact authors.