Send a link

Procmail

Table of contents


Install

From FreeBSD ports
cd /usr/ports/mail/procmail
make install

Configure

With Sendmail in FreeBSD (inserted at the end of the FEATURE section in /etc/mail/hostname.mc)
FEATURE(local_procmail)

NOTE: If you don't have the file /etc/mail/hostname.mc just run "make all" inside /etc/mail and it will be generated.

Remember to execute this in /etc/mail after saving above change
make all
make install

And restart sendmail:
/etc/rc.d/sendmail restart

Hints

Things to put in file /usr/local/etc/procmailrc:
VERBOSE=on
LOGFILE=/var/log/procmail.log


How to use $MATCH

This variable is assigned to by procmail whenever it is told to extract text from a matching regular expression. It will contain all text matching the regular expression past the "\/" (backslash, slash) token.

Example:
:0 f
* ^Subject: Something, \/([a-zA-Z_\-]+)
| formail -I "Subject: Found $MATCH"

:0 f
* ^From:.*longass@domain.tld.*
| formail -I "From: root@relay.dk"


  • + : A leading plus sign indicates that this word must be present in every object returned.
  • - : A leading minus sign indicates that this word must not be present in any row returned.
  • By default (when neither plus nor minus is specified) the word is optional, but the object that contain it will be rated higher.
  • < > : These two operators are used to change a word's contribution to the relevance value that is assigned to a row.
  • ( ) : Parentheses are used to group words into subexpressions.
  • ~ : A leading tilde acts as a negation operator, causing the word's contribution to the object relevance to be negative. It's useful for marking noise words. An object that contains such a word will be rated lower than others, but will not be excluded altogether, as it would be with the - operator.
  • * : An asterisk is the truncation operator. Unlike the other operators, it should be appended to the word, not prepended.
  • " : The phrase, that is enclosed in double quotes ", matches only objects that contain this phrase literally, as it was typed.

Menu