:: RootR ::  Hosting Order Map Login   Secure Inter-Network Operations  

Rootroute - Procmail questions



What is procmail ?

Procmail is an email tool to sort, redirect, copy, and do all sort of things to incoming email. its syntax is not too instinctive, but it is a powerful tool worth its effort. you can pretty much do anything you want to incoming email using procmail. Also many other programs such as spamassassin make use of procmail.


How to sort my incoming email into separate folders ?

On rootr.net servers, mailboxes are just directories, and each mail message is stored as a file. Here is an example .procmailrc how to do it, Note the / at the end of mailbox paths.

#-----------------------------------------------------------------------
# example - simple procmail receipes

# mail from the nasa about venus goes into own backup folder,
# as well as the main inbox, and a directory visible online.
# note: '*' lines are AND'ed.
:0
* ^From: .*@nasa\.gov
* ^Subject: .*venus
{
	:0c
	$HOME/mail/
	:0c
	$HOME/mail/nasa-backup/
	:0
	$HOME/web/example.com/nasa-mail/
}

# forward all mail sent to this subscribed list to another email
# (mailing lists often appear as if they are sent to themselves)
:0
* ^(To|Cc): .*list-ruby@ruby-lang.org
{
	# save me a copy in the main inbox as well
	:0c
	$HOME/mail/
	:0
	! some-other-email@example.com
}


# put all mail matching these keywords in the suspicious folder:
:0
* ^Subject: .*(VIAGRA|V.I.A.G.R.A|XANAX|X.A.N.A.X|VICODIN|V.I.C.O.D.I.N|ENLARGEMENT)
$HOME/mail/suspicious/
# note: don't ever reply to spam mail, it will increase to more spam,
# even if you strongly notify them they're not welcome.


#-----------------------------------------------------------------------
note: $HOME/mail/ is the main inbox, and is the incoming mail for POP3, POP3-SSL, and POP3-TLS. It is also the main inbox for the IMAP equivalents.


Using Procmail to sort incoming mail into IMAP sub-folders

The sub-directories in $HOME/mail/, that start with a dot, can be viewed as IMAP folders under the main inbox. IMAP sub-folders are separated with dots.

#-----------------------------------------------------------------------
# example - procmail with IMAP folders

# put all mail from that guy in its own folder, as he sends a lot of mail.
# we use a dot-folder, so we can view it under IMAP
:0
* ^From: .*dude@example.com
$HOME/mail/.dude/

# this will go into the IMAP sub-folder inbox/foo/bar
:0
* ^From: .*someone@example.com
$HOME/mail/.foo.bar

#-----------------------------------------------------------------------


More on procmail

Those docs can also be accessed from the command line with man or pinfo.
The first 2 links are the more important manual pages:

procmailrc - format and syntax
procmailex - example receipes
The procmail manual - command line
The formail manual - command line
procmailsc - weighted scoring technique (advanced)
re_format : Extended regular expressions, egrep-style

And of course the The procmail home page.
Also there are many examples online that can be found from popular search engines.

Procmail tips
A Procmail library

A good way to add a receipe, is to examine the full headers of 1 or 2 emails you have, look for: To: Cc: From: Subject: Reply-To: Date: etc.
Then use an example receipe as a started, and edit the new receipe accordingly.



 
::  Contact Information   ::   ©2024 ROOTR ::  


taintator@RootR.net