Posted by: arun on: December 7, 2008
Problem: I have my local mail setup with mutt, fetchmail and procmail. And I would need a way to run an arbitrary script when new mail arrives and _not_ loose the mail from my inbox.
Solution: Procmail supports a nice feature called nesting. With nested blocks a procmail recipe can be assigned more than action.
e.g: Here’s a recipe to filter all my email from gmail:
:0:
* ^To:.*gmail\.com
{
:0 c
$MAILDIR
:0 h
| grep “From:” | ~/src/_scripts/ratpoison/newmail.sh
}
And the newmail.sh script
#!/bin/bash
read from
ratpoison -c "echo Mail $from"
Discussion: Here’s the breakup
*^To:*gmail.com Catch all mails which have their To: field containing gmail.com:0 c - Copy the mail into $MAILDIR:0 h – Pipe the header into grep. And pipe the output (“From:*”) into newmail scriptIf your window manager has a notification tray, you may be interested in this. New to procmail, go here.
/me is having bit overdose of cookbooks these days
[...] a comment » Few months ago, we discussed about a mail notification method for fetchmail/procmail and mutt combo. As you can see in that post, the script we wrote to [...]