Take the 2-minute tour ×
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.

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
add comment

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.

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
add comment

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
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
add comment

Your Answer

 
discard

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.