39

Using mutt with Gmail I "check for e-mail updates" sometimes through the $ binding (sync-mailbox), sometimes just by using c (change folder) and just supplying = (defaults to MAILBOX) as the IMAP folder path to change to.

Is there a better (in particular: faster) way of doing the same? A solution would be something that is more direct than "pretending to switch folders", as I do, for example. Also something that does not "miss" some updates, as $ seems to do at times (perhaps $ is not meant to check for e-mails at all but just to expunge messages marked as deleted, etc?)

11
  • Why aren't you just using the mail_check settings in mutt?
    – jasonwryan
    Oct 5, 2012 at 3:22
  • 2
    To be able to choose when I poll the server? Oct 5, 2012 at 3:25
  • 1
    mutt updates the folder status after every keyboard input; either keep hitting $ or bind a specific key of your choice... Personally, I'm happy with letting mutt handle it.
    – jasonwryan
    Oct 5, 2012 at 3:40
  • 1
    Really? keep hitting $? Oct 5, 2012 at 3:44
  • 1
    I am confused. I thought in IMAP a connection with the server is kept open so that the server may send unsolicited commands to clients over it... [compare/contrast NOOP (tools.ietf.org/html/rfc3501#section-6.1.2) Vs receiving untagged EXISTS and RECENT] anyway, I just need a "check mail" "button". Oct 5, 2012 at 4:22

2 Answers 2

35

Bind a key (G for "Get" is recommended) to imap-fetch-mail in your ~/.muttrc.

 bind index G imap-fetch-mail

Pressing G while in the index will now fetch new mail from the imap server.

(for POP users, the fetch-mail function fetches mail from a POP server)

6
  • 1
    Looks great... could I run this as a simple command, without the binding? How? (thanks a lot for your answer, BTW) Oct 5, 2012 at 4:12
  • sorry, i don't understand the question. what do you mean by "run this as a simple command"?
    – cas
    Oct 6, 2012 at 2:38
  • 1
    @Robottinosino You can run the command without binding it to a key with M-x (i.e. Alt+X or ESC x): M-x imap-fetch-mail RET. Oct 6, 2012 at 21:11
  • 3
    Both Meta_L+x and Alt_L+x give me: Key is not bound. Press '?' for help. Oct 7, 2012 at 2:01
  • 6
    To do it unbound, just type :exec imap-fetch-mail. But that won’t refresh anything when mutt thinks it’s in sync with the server but really is not (this seems to happen if you use another client to edit the mailbox and after editing the count of messages in the mailbox has not changed (e.g., delete+receive new mail)).
    – binki
    Jan 2, 2017 at 0:53
14

You can set the timeout variable to something like:

set timeout=10

This will poll the current mailbox every 10 seconds at most when mutt is idle waiting for user input, more often than the default 600 seconds. This is not needed in post v1.5.11 when IDLE is enabled.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.