Yet Another Mail Processing Language.

What is it?

Yample is a processing language for email. It sorts for email based on criteria you define. It can deliver email to Unix mailboxes (MBOX), Maildirs (used by Courier IMAP and others) or pipes.

Project Page.

Why was it written

I discovered the Perl module Mail::Audit some time ago. It is very powerful and makes sorting email very easy. But I did not feel comfortable writing my filtering rules in Perl. One misplaced comma and your mail bounces. Besides, when you have more then 30 rules a Perl-script might not be as lucid as you could wish for.

Procmails syntax is ugly and incomprehensible.

Exim Filter is quite nice, but endless if/then/else-constructs makes it a bit unclear. if/then/else should really be implied by putting things in a certain order.

What does it look like?

        
# example rules

# this rule need spamassassin or spamc to work
spam():                                maildir(.junk.spam)

# if the mail is SA-tagged already
head(^X-Spam-Flag: YES):               maildir(.junk.spam)
head(^X-Infected:):                    maildir(.junk.virii)


# get rid of duplicates
dup():                                 maildir(.junk.duplicates)


# put the lists in a folder, auto-create subfolders for each list
list((.*)):                            maildir(.lists.$1) 

# these lists are not detected by Mail::ListDetect
subject(\[SDLperl\]):                  maildir(.lists.SDLperl)
subject(\[mytop\]):                    maildir(.lists.mytop)

# archive all mail which is not spam/virus/listmail in a mbox for "deep
# storage". requires yample 0.21
# we use perl(1) because this condition /always/ evaluates to "true"

perl(1):                               unseen mbox(/home/perbu/mailarchive/mbox)


# sort mail to perbu@foo.com info folder "foo" and mail
# to perbu@bar.com into folder "bar"

rcpt(perbu@(\w+).com):                 maildir(.$1)


# send mail too webmaster@quux.net into .webmaster.quux
rcpt(webmaster@(\w+).(com|net|org)):   maildir(.webmaster.$1)


# we don't like these guys

sender(@bongo.net):                    ignore()

# we like these guys even less:

sender(@bongo.com) and subject((.*)): reject(You message with subject '$1' was rejected)

# composite rule

sender(foo@bar.com) and rcpt(perbu@quux.com): reject(Message rejected - invalid foo)

#

( rcpt(@bongo.com) or sender(@bongo.com) and subject(bingo) ): maildir(.bingo.bongo)


# catch-all (if you dont catch all your mail it will end up in the
# "PANIC MBOX". perl(1) is the easiest way of getting a rule which
# /always/ matches

perl(1):                               maildir(.junk.unknown)

        
      
As you can see - the syntax is pretty straight forward. On each line there is a set of conditions and an action which will be executed if the conditions match.

What does '$1' mean?

Yample uses Perl regular expressions. A regaular expressions is a powerful pattern language which can match a text. Yample can rembemer parts of what matched and this can be used to simplify you rules. The postmaster-rule above matches all message sent to "postmaster@domain.something". If you are the postmaster of foo.com and yample hits this rule the message will be stored in .postmaster.domain.someting.

More on regular expressions can be found here: http://etext.lib.virginia.edu/helpsheets/regex.html;

Cool! Where can I get this?

The software is licensed under the GNU GPL license.

Download here.

CVS access described here

Project data

Yample is written by Per Andreas Buer. The logo is made by Geir Isene. The project is hosted by sourceforge.net. You can find the project page here. Yample is partly written in time paid by my excellent employer Linpro AS - the number one Linux-something in Norway.

prerequisites

Yample need Mail::Internet.

Text::Balanced is used to balance parenthesis.

The list-rules rely on Mail::ListDetect.

If use invoke yample with --spamassassin you will of course need to install Mail::Spamassassin.

The other modules are optional and if they are missing they will not cause fatal errors.


Yample draws most of its power from Perl and the Mail-modules (Mail::Internet, Mail::Spamassassin). Yample is possible only because these guys have made these modules available.

Sourceforge Logo

            $Id: index.html,v 1.23 2004/01/13 23:04:13 perbu Exp $