From Indie IT Wiki
Jump to: navigation, search

Procmail, a mail delivery agent (MDA) able to sort incoming mail into various directories and filter out spam messages. While Procmail is available for installation and is stable it is no longer developed or maintained.

System Wide Settings


# Use maildir-style mailbox in user's home directory
# Log actions to file
# Log synopsis of messages
# Be verbose


All these RECIPES are based on your personal procmail file located in...



How to forward a message but still leave a copy on the server

:0c                     # That's colon, zero, lowercase cee
!  # That's exclamation mark, address to forward to

How to send just the body of a message to a program

:0 bc:   # archive things sent to junk mailing list
* ^To:.*junk
| gzip >> junk-archive.gz

Here we're using two flags. The b flag means that the action line will just take the body of the message, and not the header. The c line, again, means to just take a copy of the message for this recipe, and pass it along to the recipes after. We're using that because we want to archive the message, but we'd also like it to be filed in our mail inbox as usual.

How to match the sender and / or subject of a message

* ^From.*bob
* ^Subject:.*(joke|funny)

How to send a copy of a message which matches a subject

* ^Subject:.*appears to be wedged$

Auto Reply For Server

:0 h c
* ^From(.*james.*|.*steve.*)
* ^Subject:.*status$
* !^X-Loop:
| (formail -r -I"Precedence: junk" \
   -A"X-Loop:" ; \
   echo `/usr/bin/uptime`) | $SENDMAIL -t

Capture Correct Email Address Then Forward Rest To Spam

# basic settings

# capture correct email addresses
* ^TO_[0-9][0-9][0-9][0-9]@(this|that)domain[.]co[.]uk|\

# forward all the rest to spam@