7.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))
nnimap-address

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

nnimap-user

Username to use for authentication to the IMAP server. This corresponds to the value of the ‘login’ token in your ~/.authinfo file. Set this variable if you want to access multiple accounts from the same IMAP server.

nnimap-server-port

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

nnimap-stream

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

undecided

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

ssl

This uses standard TLS/SSL connections.

network

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

starttls

Encrypted STARTTLS over the normal IMAP port.

shell

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.

plain

Non-encrypted and unsafe straight socket connection. STARTTLS will not be used even if it is available.

nnimap-authenticator

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, cram-md5 or xoauth2. (The latter method requires using the oauth2.el library.)

nnimap-expunge

When to expunge deleted messages. If never, deleted articles are marked with the IMAP \\Delete flag but not automatically expunged. If immediately, deleted articles are immediately expunged (this requires the server to support the UID EXPUNGE command). If on-exit, deleted articles are flagged, and all flagged articles are expunged when the group is closed.

For backwards compatibility, this variable may also be set to t or nil. If the server supports UID EXPUNGE, both t and nil are equivalent to immediately. If the server does not support UID EXPUNGE, nil is equivalent to never, while t will immediately expunge all articles that are currently flagged as deleted (i.e., potentially not only the article that was just deleted).

nnimap-streaming

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

nnimap-fetch-partial-articles

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.

nnimap-record-commands

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

nnimap-use-namespaces

If non-nil, omit the IMAP namespace prefix in nnimap group names. If your IMAP mailboxes are called something like ‘INBOX’ and ‘INBOX.Lists.emacs’, but you’d like the nnimap group names to be ‘INBOX’ and ‘Lists.emacs’, you should enable this option.

nnimap-keepalive-intervals

By default, nnimap will send occasional ‘NOOP’ (keepalive) commands to the server, to keep the connection alive. This option governs how often that happens. It is a cons of two integers, representing seconds: first how often to run the keepalive check, and the second how many seconds of user inactivity are required to actually send the command. The default, (900 . 300), means run the check every fifteen minutes and, if the user has been inactive for five minutes, send the keepalive command. Set to nil to disable keepalive commands altogether.