[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.3 Using IMAP

The most popular mail backend is probably nnimap, which provides access to IMAP servers. IMAP servers store mail remotely, so the client doesn’t store anything locally. This means that it’s a convenient choice when you’re reading your mail from different locations, or with different user agents.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.3.1 Connecting to an IMAP Server

Connecting to an IMAP can be very easy. Type B in the group buffer, or (if your primary interest is reading email), say something like:

(setq gnus-select-method
      '(nnimap "imap.gmail.com"))

You’ll be prompted for a user name and password. If you grow tired of that, then add the following to your ‘~/.authinfo’ file:

machine imap.gmail.com login <username> password <password> port imap

That should basically be it for most users.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.3.2 Customizing the IMAP Connection

Here’s an example method that’s more complex:

(nnimap "imap.gmail.com"
        (nnimap-inbox "INBOX")
        (nnimap-split-methods default)
        (nnimap-expunge t)
        (nnimap-stream ssl))

The address of the server, like ‘imap.gmail.com’.


If the server uses a non-standard port, that can be specified here. A typical port would be "imap" or "imaps".


How nnimap should connect to the server. Possible values are:


This is the default, and this first tries the ssl setting, and then tries the network setting.


This uses standard TLS/SSL connections.


Non-encrypted and unsafe straight socket connection, but will upgrade to encrypted STARTTLS if both Emacs and the server supports it.


Encrypted STARTTLS over the normal IMAP port.


If you need to tunnel via other systems to connect to the server, you can use this option, and customize nnimap-shell-program to be what you need.


Some IMAP servers allow anonymous logins. In that case, this should be set to anonymous. If this variable isn’t set, the normal login methods will be used. If you wish to specify a specific login method to be used, you can set this variable to either login (the traditional IMAP login method), plain or cram-md5.


If non-nil, expunge articles after deleting them. This is always done if the server supports UID EXPUNGE, but it’s not done by default on servers that doesn’t support that command.


Virtually all IMAP server support fast streaming of data. If you have problems connecting to the server, try setting this to nil.


If non-nil, fetch partial articles from the server. If set to a string, then it’s interpreted as a regexp, and parts that have matching types will be fetched. For instance, ‘"text/"’ will fetch all textual parts, while leaving the rest on the server.


If non-nil, record all IMAP commands in the ‘"*imap log*"’ buffer.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.3.3 Client-Side IMAP Splitting

Many people prefer to do the sorting/splitting of mail into their mail boxes on the IMAP server. That way they don’t have to download the mail they’re not all that interested in.

If you do want to do client-side mail splitting, then the following variables are relevant:


This is the IMAP mail box that will be scanned for new mail. This can also be a list of mail box names.


Uses the same syntax as nnmail-split-methods (see section Splitting Mail), except the symbol default, which means that it should use the value of the nnmail-split-methods variable.


Uses the same syntax as nnmail-split-fancy.


List of flag symbols to ignore when doing splitting. That is, articles that have these flags won’t be considered when splitting. The default is ‘(%Deleted %Seen)’.

Here’s a complete example nnimap backend with a client-side “fancy” splitting method:

(nnimap "imap.example.com"
        (nnimap-inbox "INBOX")
         (| ("MailScanner-SpamCheck" "spam" "spam.detected")
            (to "foo@bar.com" "foo")

[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated on January 25, 2015 using texi2html 1.82.