[Home]MuttGuide/UseIMAP

MuttWiki | MuttGuide | RecentChanges | Preferences | EDITwiki

To use IMAP with mutt, here's a sample ~/.muttrc file:
 # Automatically log in to this mailbox at startup
 set spoolfile="imap[s]://[<username>[:<optional_password>]@]<server>/INBOX"
 # Define the = shortcut, and the entry point for the folder browser (c?)
 set folder="imap[s]://[<username>@]<server>/INBOX"
 set record="=Sent"
 set postponed="=Drafts"

The above config works for people who have subfolders below (inside/nested) the INBOX folder. If you have folders at the same level (flat) as your INBOX folder, remove the trailing INBOX from the spoolfile and folder directives:

 # Automatically log in to this mailbox at startup
 set spoolfile="imap(s)://[<username>[:<optional_password>]@]<server>/"
 # Define the = shortcut, and the entry point for the folder browser (c?)
 set folder="imap(s)://[<username>@]<server>/"
 set record="=Sent"
 set postponed="=Drafts"

Once you have started mutt, you may press c? to change between your IMAP folders. If this shows a list of filesystem folders, instead of expected IMAP folders, then you probably need to remove the trailing INBOX from the spoolfile and folder directives as per the second example above.

Other useful ~/.muttrc settings:

If you applied the so useful for us IMAP users [trash_folder patch], also add:

 set trash="=Trash"

Also, some other settings that might depend on the servers configuration:

 # activate TLS if available on the server
 set ssl_starttls=yes
 # always use SSL when connecting to a server
 set ssl_force_tls=yes
 # Don't wait to enter mailbox manually 
 unset imap_passive        
 # Automatically poll subscribed mailboxes for new mail (new in 1.5.11)
 set imap_check_subscribed
 # Reduce polling frequency to a sane level
 set mail_check=60
 # And poll the current mailbox more often (not needed with IDLE in post 1.5.11)
 set timeout=10
 # keep a cache of headers for faster loading (1.5.9+?)
 set header_cache=~/.hcache
 # Display download progress every 5K
 set net_inc=5

Multiple accounts

If you have more than one IMAP account, you'll probably want to set up some convenience hooks. account-hook is used to set up connection parameters (username, password, ssl options etc), and folder hook for everything else. For example, if I have an account user1 at server1.com and user2 at server2.com:

 # Base hook to reset account variables to known state before activating new ones
 account-hook . 'unset preconnect imap_user imap_pass imap_authenticators; set ssl_starttls=ask-yes'

 account-hook imap://server1.com/ 'set imap_user=user1 imap_pass=pass1'
 folder-hook imap://server1.com/ 'set folder=imap://server1.com/INBOX record=+Sent from="Angel <user1@server1.com>"'

 account-hook imap://server2.com/ 'set imap_user=user2 imap_pass=pass2 imap_authenticators=digest-md5'
 folder-hook imap://server2.com/ 'set folder=imap://server2.com/mail record=+Sent from="Devil <user2@server2.com>"'

You might also want to add some mailboxes lines, or alternatively add mailboxes/unmailboxes commands to your folder-hooks:

 set folder=imap://server1.com/INBOX
 mailboxes = =Lists.mutt-dev =Lists.mutt-users

 set folder=imap://server2.com/INBOX
 mailboxes = =Lists.pine-dev =Lists.pine-users

And feel free to set other things in your folder-hooks, like spoolfile. You could also put the account-hook/folder-hook lines for each server into separate files and source them all. For example if you had .mutt/accounts/server1 and .mutt/accounts/server2 containing the hooks for server1 and server2 respectively, you could source them with a line like:

 source 'cat ~/.mutt/accounts/*|'

Very recently mutt gained the ability to tab-complete imap URLs based on currently-opened connections and defined mailboxes, so switching between them should be as simple as

 cimap://<tab>1<tab><enter>
to go to server 1, or
 cimap://<tab>2<tab><enter>
to go to server 2 in this example. If your servers don't start with the same prefix you can shave off another couple of keystrokes.

See also /Folders and /Actions.

Tuning Imap

Caching

There're several starting points to tune mutt and increase IMAP performance with local caching reducing network usage: mutt can be made to fetch every item (header, message) just once and work with local copies after that.

If local caching is not desired for good reasons, mutt features such as attachment counting or spam detection should be avoided as they likely will cause mutt to fetch either headers or even complete messages over and over again.

See /Caching for more information.

Searching

~patterns which work on body and/or header require that every message (part) has to be fetched so it can be checked for a match. If you want to avoid prefetch, work with =h and =b instead: this leaves the search on the server (if it supports it), but notice that it's literal string only, no regular expression. Note that this feature is not available before version 1.5.11.

When body caching is used, regular expression searches may not be that expensive as they'll use the local message cache fetching only missing messages first.


MuttWiki | MuttGuide | RecentChanges | Preferences | EDITwiki
Read EDITwiki in nav-bar!!! | View other revisions
Last edited June 23, 2008 8:02 am by Pdmef (diff)
Search: