Mailfilt

Mailfilt

Mailfilt is a perl script that filters incoming mail based upon a set of rules defined in a .rules file. The location of that file and the mail directory in which to put messages are specified at the beginning of Mailfilt itself. The default directory is $HOME/mail.

The best place to get mailfilt is right here.

The .rules file has a very rich syntax but is formatted like a makefile. The following shows a sample .rules file that illustrates many of the features:


PGP

Mailfilt has built-in support for PGP signatures. When it encounters a PGP signed message, it will attempt to run pgp to authenticate the message. For this to work properly, pgp must be in one of the directories in the PATH statement in the configuration section of the Mailfilt code and your public keyring must be in the directory pointed to by the PGPPATH statement.

The signature block will appear in the message as it was sent, but following the END SIGNATURE marker, a couple lines will be inserted showing whether pgp could authenticate the message.

Users without pgp can use mailfilt without problem, except that an error message will appear in the logfile each time a signed message is received.


Example .rules file:

/dev/null:
	Subject: this is junk

jimbob@the.farm:	#Forward this stuff to Jim Bob
	Subject: Farm report
	&!From: jimbob

|/usr/bin/handle-cronmail:
	From: root
	&Subject: ^cron		#Subject must start with cron

bulk:
	Rcpt: biglist@alma.matter #biglist must be in To: or Cc:

personal: 	#Stuff addressed to either of my mail aliases
	To: myname@big.fast.computer
	
	To: myothername@big.fast.computer

primary:	#Anything that hasn't already matched will go to this file

In this example, mail with this is junk in the subject will go to /dev/null. Mail with Farm report in the subject that doesn't come from jimbob will be mailed to jimbob@the.farm. Mail from root with cron in the subject line will be put in the file bulk in the mail directory. Mail that has biglist@alma.matter in the To: or Cc: lines will also be put in bulk. Anything that hasn't met the above criteria and that has myname@big.fast.computer in the To: line will be put in the file personal in the mail directory. Finally, everything else will be put in the file primary. This means that nothing will end up in /var/spool/mail.

Some general rules to remember:


Grammer for .rules file:

FILE	::=	{SET}

SET	::=	TARGET: {COMMENT} \n
			{RULESET}
		{SET}

TARGET	::=	FOLDER | ADDRESS | PIPE

RULESET	::=	WS RULE
		WS ANDRULE
		{SKIPLINE RULESET}

ANDRULE	::=	&RULE {ANDRULE}

RULE 	::= 	[!]HEADER: WS regex {COMMENT} \n

HEADER	::=	From | Subject | To | Rcpt | Date | ....

ADDRESS ::= 	user@machine

FOLDER 	::= 	filename
	|	/path/to/file

PIPE	::=	|/path/to/program

SKIPLINE::=	\n{COMMENT}\n

WS	::=	\t  {WS} 
	| 	` ' {WS}

COMMENT ::=	{WS}#string

Verision Update

New Features in Version 1.3

New Features in Version 1.21

New Features in Version 1.20

New Features in Version 1.11


HomeUp Free Speech on the InternetPrivacy on the InternetThe truth about MicrosoftLast Modified at 09:53:32 on 24 July 95
Mike Fisk (mfisk@nmt.edu)