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.
- 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
$Uis the first letter of the user name and
$USERis 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.
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.
If you want to write you own procmail rules, edit or create the file
.procmailrc in your home directory.
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:.*email@example.com /var/imap/u/user/.Friends.Alice/ :0: * ^From:.*firstname.lastname@example.org /var/imap/u/user/.Friends.Bob/
- File format documentation: man page procmailrc(5) (Online copy)
- .procmailrc examples: man page procmailex(5) (Online copy)
- Procmail Documentation Project's Documentation
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 email@example.com blacklist_from firstname.lastname@example.org blacklist_from *@spamdomain.example.com