Cosmic.voyage/Procmail

Procmail
Cosmic supports running Procmail to filter your emails and sort them into folders. For info about the program please use man procmail and for the config file use man procmailrc. The program has a large number of rules and config options. To set up a basic filter, do the following:

Create a file ~/.forward with the line
 * /usr/bin/procmail

Create a file ~/.procmailrc with filter rules for the mails you want to put into folders, e.g. my current file looks like this: LOGFILE=procmail.log MAILDIR=mail


 * 0

tildebot
 * ^From: tildebot@tilde.chat$


 * 0

tildegit
 * ^From:.*git@tildegit.org


 * 0

cronjobs
 * ^From: root@cosmic.voyage .Cron Daemon.$

This filters mails from the IRC bot into tildebot, the git mails into tildegit and mails from your local cronjobs into a folder cronjobs.

The folders are stored in ~/mail/name, which makes it possible to read them with alpine, also it is possible to use IMAP to subscribe. If you like normal mail, you can also do mail -f mail/foldername.

To write a filter recipe, it is useful to have a testmail to run each time to test the rule, you can simply use an example mail that you want to filter by saving it with alpine with the s key, the resulting file is a IMAP folder file, you can remove the first header that says don't delete and also remove the Delivered-To: line, otherwise the mail router will think the mail is looping, also you could remove the Date: header to give the mail a new date each time it is sent.

You can send the testmail with /usr/sbin/sendmail -t <mail.txt

Alternatively you can test .procmailrc without setting up the .forward first with procmail <mail.txt. This may be preferable if you receive a lot of mails.

The results of the filter operation are logged in ~/procmail.log