I have Postfix running on my Ubuntu server, and I'd like to configure it to run a command when it receives certain emails. For example, if I email myself from a gmail account with the subject "todo", I'd like Postfix to append the body of the message to /home/brian/todo.
From reading Postfix docs, I've only seen how to configure rules to reject emails with error codes. So maybe Postfix is not the tool for the job, in which case I'd appreciate feedback on a more appropriate tool.
[Update: 20090616] Expanding on the selected answer, here is my .procmailrc:
:0 * ^To.*email@example.com * ^Subject.*specialsubject | ~/bin/extract_email_body.py >> ~/todo
And here is ~/bin/extract_email_body.py:
#!/usr/bin/python import sys import email def print_plain_text_parts(msg): if msg.is_multipart(): for part in msg.get_payload(): print_plain_text_parts(part) elif msg.get_content_type() == 'text/plain': print(msg.get_payload().strip()) msg = email.message_from_file(sys.stdin) print_plain_text_parts(msg)