How to Setup Your Own Procmail Filter Rules

This article provides the D-PHYS specific information needed to write proper procmail rules at the Department of Physics of the ETH Zurich.

Facts

  • We use the Maildir mailbox format, i.e. a mail folder is a real directory on the disk. procmail needs a trailing slash on the mailbox name to know it should handle the mailbox as Maildir format.
  • The path the to per-user directory is /var/imap/$U/$USER/ on the server imap.phys.ethz.ch where $U is the first letter of the user name and $USER is the user name.
  • IMAP uses the dot (".") as directory delimiter and this is used on the file system as well when it comes to folder names.

Path Example

The folder "Foobar/Gnarz" of the user "example" is located on disk at /var/imap/e/example/.Foobar.Gnarz/ on the server imap.phys.ethz.ch.

You can login via SSH there, too.

~/.procmailrc

If you want to write you own procmail rules, edit or create the file .procmailrc in your home directory.

.procmailrc Example

If you for example want to sort incoming mails from Alice and Bob in the subfolder Alice and Bob of the folder Friends, you can write a .procmailrc like this:

:0:
* ^From:.*alice@example.com
/var/imap/u/user/.Friends.Alice/

:0:
* ^From:.*bob@example.com
/var/imap/u/user/.Friends.Bob/

Further reading

Spamfilters

Every locally delivered mail must pass a spamfilter. Individual users can adjust their personal SpamAssassin configuration using the file $HOME/.spamassassin/user_prefs. (You have to create that file if it doesn't exist.) The most typical entries are

whitelist_from  friend@provider.example.com
blacklist_from  spammer@provider.example.com
blacklist_from  *@spamdomain.example.com

or required_score 5