I hate etc/ and everything in it, but I realize it might not be etc/’s fault. The fault might lie with Google and Bing: most of the results I get are people asking the same question on some forum. These threads often end without any answer. Or worse, wrong information. About half the threads eventually end up with the members discussing a complete different issue. Anyway, I figured it out. The following example assumes you’re using the maildir format for your mailbox.
- Create a file called .procmailrc in your home folder and add the following contents:
- Tell postfix to use procmail for mail filtering/processing by adding/changing the following line to /etc/postfix/main.cf:
- Restart postfix
As you can see, the rules in .procmailrc use regular expressions to find the right mail. Each rule starts with colon-zero-colon (see man procmailrc for more options), followed by a line with the regular expression. Here, ^ means beginning of the line. Note that dots must be escaped with a backslash. A wildcard would be written as .* The next line describes what to do when the regular expression is matched. In this case we want procmail to deliver the mail to a folder called SomeFolder. (If you’re using mbox instead of maildir this would be a filename rather than a folder name.)
Add as many rules as you want, separating them with an empty line.