Cosmic.voyage/Procmail: Difference between revisions

From Tildeverse Wiki
(draft version)
 
No edit summary
 
(5 intermediate revisions by one other user not shown)
Line 1: Line 1:
[[Cosmic.voyage|<- Back to 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.
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
Create a file ~/.forward with the line
    | /usr/bin/procmail
<pre>
| /usr/bin/procmail
</pre>


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


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


Line 23: Line 26:
*^From: root@cosmic.voyage .Cron Daemon.$
*^From: root@cosmic.voyage .Cron Daemon.$
cronjobs
cronjobs
````
</pre>


This filters mails from the IRC bot into tildebot, the git mails into tildegit and mails from your local cronjobs into a folder cronjobs.
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, but for some reason that does not work immediately, there seems to be some kind of cache on that.
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.
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
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
The results of the filter operation are logged in ~/procmail.log

Latest revision as of 16:13, 6 August 2024

<- Back to cosmic.voyage

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
*^From: tildebot@tilde.chat$
tildebot

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

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

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