Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 3 down vote accepted

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.

share|improve this answer
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.

share|improve this answer
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.) – Riccardo Murri Jun 21 '11 at 14:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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