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.

link|improve this question

75% accept rate
feedback

2 Answers

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.

link|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
feedback

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.

link|improve this answer
2  
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
feedback

Your Answer

 
or
required, but never shown

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