I'd like to run a command (specifically imapfilter) whenever Mutt is checking for new email, to avoid getting "wrong" messages about email in =INBOX which hasn't been filtered yet.


There is no facility in mutt to run a user-defined command upon receiving new mail.

A workaround could be this one:

  • use imapfilter itself to copy the emails to a another IMAP mailbox (e.g., +INBOX2),
  • configure mutt to read new mail from =INBOX2 (e.g., set spoolfile="+INBOX2" in .muttrc)

You could run imapfilter from mutt (just bind its invocation to a key macro), or from a cron job.

  • The cron job is already in place, and I wanted specifically to avoid running it with a macro. But the idea of using a secondary inbox is great. +1 for lateral thinking.
    – l0b0
    Jun 30 '11 at 6:53

This might be possible by using one of the following hooks listed in the manual:

  • folder-hook
  • send-hook
  • message-hook
  • save-hook
  • mbox-hook
  • fcc-hook
  • fcc-save-hook

To execute an external program you may need to define a macro called from one of the hooks.

  • 3
    None of the hooks get called automatically when mutt retrieves new mail: they are all provided as a means of customizing/running commands in response to users' actions. (e.g., folder-hook is run when changing folder, message-hook when viewing a message, etc.) Jun 21 '11 at 14:29

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.