42

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?)

  • 1
    Why aren't you just using the mail_check settings in mutt? – jasonwryan Oct 05 '12 at 03:22
  • 2
    To be able to choose when I poll the server? – Robottinosino Oct 05 '12 at 03:25
  • man muttrc | less -p mail_check - configure if/when mutt looks for new mail... – jasonwryan Oct 05 '12 at 03:26
  • But I would like to issue the command manually, only: more conveniently than "pretending to switch IMAP folders". Most of the time, I don't need the polling at all.. – Robottinosino Oct 05 '12 at 03:28
  • 2
    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 05 '12 at 03:40
  • 1
    Really? keep hitting $? – Robottinosino Oct 05 '12 at 03:44
  • Well, hitting any key is sort of odd when mutt can be set up to do it automatically... – jasonwryan Oct 05 '12 at 04:00
  • No. I don't want to waste laptop battery, network bandwidth, etc to check for e-mail when I don't need to check for it. – Robottinosino Oct 05 '12 at 04:06
  • Its not polling the server; its just checking your maildir... Its all in the manual and FAQ I linked to. – jasonwryan Oct 05 '12 at 04:10
  • 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 (http://tools.ietf.org/html/rfc3501#section-6.1.2) Vs receiving untagged EXISTS and RECENT] anyway, I just need a "check mail" "button". – Robottinosino Oct 05 '12 at 04:22
  • Some imap servers have agressive timeout settings and will drop the connection if you spend more than a minute or so reading (or replying) to an email. I ran into this issue with the Exchange server at work and ended up giving up on using mutt as an imap client...used fetchmail (using procmail as mda) instead. – cas Oct 06 '12 at 02:43

2 Answers2

38

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)

cas
  • 78,579
  • 2
    Looks great... could I run this as a simple command, without the binding? How? (thanks a lot for your answer, BTW) – Robottinosino Oct 05 '12 at 04:12
  • sorry, i don't understand the question. what do you mean by "run this as a simple command"? – cas Oct 06 '12 at 02: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. – Gilles 'SO- stop being evil' Oct 06 '12 at 21:11
  • 4
    Both Meta_L+x and Alt_L+x give me: Key is not bound. Press '?' for help. – Robottinosino Oct 07 '12 at 02:01
  • Alright, I surrender to some sort of binding and will use: macro index,pager ,f "<imap-fetch-mail>" – Robottinosino Oct 07 '12 at 02:16
  • 8
    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 02 '17 at 00:53
17

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.

gypaetus
  • 921