Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 812370e8e4f8ac698e01b21e53db774d > files > 29

maildrop-1.7.0-17mdv2010.0.i586.rpm

<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
                         
  <meta http-equiv="Content-Type"
 content="text/html; charset=iso-8859-1">
                         
  <meta name="Author" content="Robin Whittle">
                         
  <meta name="GENERATOR"
 content="Mozilla/4.78 [en] (Windows NT 5.0; U) [Netscape]">
  <title>Maildrop filtering, deltag mods and subjadd</title>
</head>
  <body text="#000000" bgcolor="#ffffff" link="#0000ee" vlink="#551a8b"
 alink="#ff0000">
   
<h2> Maildrop filtering and my two extensions to its capabilities</h2>
 
<p>This page discusses: </p>
   
<blockquote>
  <table cellspacing="0" cellpadding="8" width="60%">
      <tbody>
        <tr valign="top">
          <td valign="top"><a href="#DelTag">&gt;&gt;&gt;</a>        </td>
          <td valign="top">Source code changes to Courier Maildrop so a<font
 size="+1"> message can be delivered tagged for deletion</font>. (Also a
binary for Red Hat 9.0.)</td>
        </tr>
        <tr valign="top">
          <td valign="top"><a href="#subjadd">&gt;&gt;&gt;</a>        </td>
          <td valign="top">An external filter program called<font
 size="+1"><b><tt> subjadd</tt></b></font> which can add a label [Postfix]
 to the subject line of an email. It will also create a subject line if there
 was none.</td>
        </tr>
        <tr valign="top">
          <td><a href="#Filtering">&gt;&gt;&gt;</a>        </td>
          <td>My experiences with Maildrop's filtering language, and some 
simple example files.</td>
        </tr>
                          
    </tbody>              
  </table>
    </blockquote>
    Robin Whittle 29 May 2003<br>
<br>
Please see an earlier version of this directory if you are want to see how
I did this in 2001. <a href="../Maildrop-mods-filtering-2001">../Maildrop-mods-filtering-2001</a> 
.<br>
 <br>
 The material below is for version 1.5.3 of Maildrop, from about 2003 May 
2. <br>
 <br>
 <a href="../">To the web-mail directory</a> , from where you can reach such 
things as:         
<ul>
      <li> Survey of web-mail systems.</li>
      <li><b>mb2md</b> - a perl script for converting multiple Mbox mailboxes
 into Maildir format.</li>
      <li> "How-I-Did-It"s for installing:</li>
                  
  <ul>
        <li> Postfix</li>
        <li> Courier IMAP</li>
        <li> Courier Maildrop</li>
        <li> Courier SqWebMail</li>
        <li> Postman web-mail system form University of Valencia, in Spain.</li>
      <li><font color="#990000"><b>How I called Spam Assassin and Anomy Sanitizer
 from Maildrop to filter spam, viruses and other malware.</b></font><br>
      </li>
                  
  </ul>
      <li> My 71 foot long <i>Sliiiiiiinky</i> and many non-technical distractions.</li>
           
</ul>
      
<hr align="left" size="1" width="200"><br>
   &nbsp;         
<h2><a name="DelTag"></a> Maildrop extension: DELTAG - Tagged for Deletion</h2>
      
<blockquote>This is a modification to two?? files in the Maildrop source code.&nbsp;
So you need to recompile Maildrop to be able to use these.&nbsp; But you
probably need to be able to recompile it anyway to set it to work with your
preferred mailbox locations.&nbsp; Please see my discussion of Maildrop via
the parent web-mail directory.</blockquote>
        
<h4> Why I want to deliver messages to the Inbox tagged for deletion</h4>
        
<blockquote>I want to replicate the functionality of Netscape's (4.77 for
 Windows) mail filtering system (also, I guess, Mozilla's and Netscape 7's 
- but when I last did filtering in the client, it was with N4.77) - but to 
do it entirely at the server.&nbsp; I am on several dozen mailing lists and 
so filtering is vital.&nbsp; Before using Maildrop filtering, I had N4.77 
set up to copy messages to the particular mailbox for that mailing list, and
to leave the message in the Inbox, but flagged for deletion.&nbsp;&nbsp; This
client-based filtering happened when I "Alt-F M" Netscape to check for new
mail.&nbsp; The headers come to N4.77 and it sends commands back to the IMAP
server about where to put the messages and whether to set the "T" tagged for
deletion flag for messages which also remain in the Inbox. &nbsp;But client-based
filtering is a pain for a number of reasons. &nbsp;With Maildrop, I can achieve
all this and more on the server.                           
  <p>The great benefit of this approach to filtering - copying to the target
 mailbox and putting a copy in the Inbox, tagged for deletion - is that I
can see all the activity on my lists without having to look into their various
 mailboxes.&nbsp; When I have scanned the "tagged for deletion" messages,
(which I can read, print, reply to or untag with the Del key) then I use
"Alt-F F" (for Netscape 7)to expunge the mailbox.&nbsp;  Netscape tells the
IMAP server to delete them all. &nbsp; </p>
                    
  <p>This client-based filtering worked OK, with the following restrictions:
   </p>
                    
  <ol>
          <li> Netscape can only filter on particular types of header line.&nbsp;
 It is possible to specify other headers, but this is a drag and every time
 you install a new version of Netscape, it doesn't know about these extra
types.&nbsp; Also, I found it hard or impossible to make it filter reliably
on a certain header which are commonly the best ones to use for filtering
a mailing list.&nbsp; I don't remember which ones it was, but maybe it is
"Resent-by:" or similar.</li>
          <li> My entire email empire was dependent on using Netscape to
check  for all mail, and having that installation of Netscape loaded with
my most  up-to-date filtering rules.dat file.&nbsp; This makes remote access
from a laptop a pain.&nbsp; It also precludes using a web interface like
Postman  or IMP, because all emails first seen by Postman will not be first
seen by Netscape,  so they will not be subject to Netscape client-based mail
filter rules.&nbsp; (Actually Netscape  may be smarter than this - perhaps
the later versions recognise emails it  has not seen before, irrespective
of whether another client has seen them  so far.)&nbsp; I get several hundred
emails a day, mainly from mailing lists.&nbsp;  (An ISP sys-op I know was
getting 200 emails a day just for him, not counting  list traffic!)</li>
          <li> When connected by a slow link, such as a 9.6 kbps (supposedly
 - but it feels like this at half duplex) high latency (1.4 seconds ping
time  . . . Urrggh!!)  link involving a GSM phone, a laptop (IR link) and
the 56/33  kbps access-router modem at the ISP which  connects my server
to the Net,  email is really <i>painful</i> and was costing me lots of money
as well as driving me nuts.&nbsp; I takes ages to sort the emails, several
seconds for each one.&nbsp; Worse still, if the session drops out in the
middle of this, then the mail sorting is not done properly and there are
typically dozens of messages in the Inbox  which are not tagged for deletion.&nbsp;
Trying to tag them with Netscape  is even more painfully slow and error prone,
since if you take any action  before the now very slow IMAP exchange finishes,
then the message appears  to be tagged, but in fact is not tagged.&nbsp;
In practice, it is easier to telnet (now <a
 href="http://www.openssh.org/">OpenSSH</a>) to the server and delete them
with a text-mode email program!&nbsp;&nbsp;  I was spending an hour a day
at least when I was away recently just trying  to keep up with the email,
and this was mainly trying to get Netscape to filter correctly, and cleaning
up the mess when the link dropped out.&nbsp; I hardly read or responded to
any emails.&nbsp; Never again!</li>
                    
  </ol>
                    
  <p><br>
   The advantages of the Maildrop filtering approach include: </p>
                    
  <ol>
          <li> By filtering each email as it arrives with Maildrop, I remove
 all dependence on my email client.&nbsp; This means I can access my account
 with a web-mail program such as Postman, SqWebMail or IMP from any web browser,
 SSH to the machine and use Pine or Mutt, or&nbsp; use Netscape via IMAP.
(I think I will generally be using Netscape or Mozilla via IMAP over the
LAN - but perhaps also from far away.)</li>
          <li> There is no time spent filtering when I connect via a client.</li>
          <li> Filtering should be very reliable, since it is not affected
 by client communication problems.</li>
          <li> Maildrop's filtering language is extremely powerful.</li>
          <li> With my two modifications/extensions to Maildrop, I can add
 labels to the subject lines of messages from mailing lists which have no
such label.&nbsp; For instance, the Postfix mailing list is extremely busy,
but there is nothing distinctive in its subject lines.&nbsp; I will be able
to add labels like "[Postfix]" to each subject line of the emails in my Inbox
 so I know which mailing list they belong to.</li>
     <li>I can implement virus and spam filtering from Maildrop, as documented 
in a page you can find from the parent directory.</li>
     <li>I can do what I like with the mail filtering system, including cause 
the computer to run a program, make a beep etc. when particular messages arrive.<br>
     </li>
                    
  </ol>
    The potential disadvantages of the Maildrop filtering approach is:  
                       
  <ol>
          <li> Netscape (or any other IMAP based email client) does not know 
that new emails have been put in mailboxes.  (The Inbox is fine - just use 
the normal "Alt-F M" command - N4.77 - or Ctrl T for Netscape 7.02.)&nbsp;
 The workaround  is to close the window for that mailbox and re-open it.
&nbsp;The  best way to do this is to click on the "parent folder" of whatever
mailbox  is currently in this window. &nbsp;For the Inbox or other mailboxes
on the  "first level" this is a folder with the name of the mail server.
&nbsp;For  mailboxes in other folders, it is that folder itself. &nbsp;In
either case,  the current window becomes selected to a "non-mailbox" and
then clicking on the original mailbox causes Netscape to look at the mailbox
again, so it sees all new messages. &nbsp;</li>
          <li> I have to use SSH<strike>telnet</strike> to a shell account 
and use an editor there to edit a potentially tricky <tt>.mailfilter</tt> 
file, and then watch to see that it is working and has no syntax errors, typically
by sending myself a test message.&nbsp; However, each section of the file,
for each  mailing list, should have a pretty standardised form, and comments
are allowed,  so I can document what I am doing.</li>
                    
  </ol>
        </blockquote>
                 
<blockquote>                    
  <h4>Operational matters based on experience</h4>
  I have been using this mail filtering system for nearly 2 years and it
is a great success. &nbsp; <br>
       <br>
  I find that some mailing lists have a plethora of ways in which they can
 forward email, and so it is necessary to keep refining my filtering rules.
 &nbsp;I expected this. &nbsp;For instance a list which normally sets the
"Return-Path: " header reliably may not do this if the message it is forwarding
already contains some other "Return-Path: " and or was Cc:ed to the list,
rather than sent To: it.<br>
          <br>
  There is an important operational matter to consider. &nbsp;Since emails 
can arrive at any time (unless, I suppose, I manually halted Postfix for a
while) my plan of seeing every bit of list activity via the "Tagged for Deletion"
copies in the Inbox can only be reliable if (when using Netscape 7 Messenger,
for instance) :<br>
                      
  <ol>
            <li>I use Ctrl T to check for the latest received messages.</li>
            <li>I then look to see if any new ones have arrived which I want
 to read - and then read them (or I guess undelete them and read them in
the  Inbox later, or remember to read them in the mailing list box).</li>
            <li>I use Alt F, F to delete all messages which are tagged for
 deletion.</li>
            <li>No messages arrive in the Inbox tagged for deletion between
 steps 1 and 3.</li>
                      
  </ol>
          </blockquote>
            
<blockquote>I discovered this one morning. &nbsp;There were a few messages
 tagged for deletion which had arrived the night before, so I thought "OK.
 lets clear those (Alt F, F)&nbsp; and then Ctrl T to get the new messages.
 &nbsp;But the Alt F, F deletes all messages in the folder which were tagged
 for deletion, whether Netscape had seem them or not. &nbsp; So I was scratching
 my head wondering why there had been so little mailing list activity overnight!</blockquote>
              <br>
<br>
              
<h4> The changed code and what it does</h4>
          
<blockquote>The two new source files, and their original versions from ,Maildrop-1.5.3
 are here. &nbsp;Also a tarball with the source and the modified maildrop
binary, compiled for i386 (Pentium Pro) on Red Hat 9.0. &nbsp;&nbsp;    
                          
  <blockquote><tt><a href="maildir.C"></a></tt></blockquote>
  <tt>&nbsp; <a href="maildir.C.txt">maildir.C.txt</a> &nbsp; &nbsp; &nbsp;
&nbsp;</tt><tt> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 6,031 bytes
  </tt><br>
  <tt> &nbsp; <a href="maildir.C-orig.txt">maildir.C-orig.txt</a> </tt><tt>&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;4,138</tt><tt> bytes<br>
   <br>
 &nbsp; <a href="maildircreate.c.txt">maildircreate.c.txt</a> &nbsp; </tt><tt>&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 6,393 bytes</tt><br>
  <tt> &nbsp; <a href="maildircreate.c-orig.txt">maildircreate.c-orig.txt</a>
  </tt><tt>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;4,670 bytes</tt><tt>
  <br>
   <br>
 &nbsp; <a href="maildrop-1.5.3-DELTAG-mods.tar.gz">maildrop-1.5.3-DELTAG-mods.tar.gz</a>
  </tt><tt>100,126 bytes </tt><br>
  <br>
  <font color="#000000"><br>
    </font><font color="#000000">I had previously done a full install  of
Maildrop, as documented in another page</font> on&nbsp; <a
 href="../RH90-Postfix-Courier-Maildrop-IMAP/">../RH90-Postfix-Courier-Maildrop-IMAP/</a><font
 color="#000000">. &nbsp;To get it to do what I wanted, I had to change one
 configuration option. &nbsp;The option is in <tt>maildrop/config.h</tt></font><font
 color="#000000"> &nbsp;- the line: </font>#define DEFAULT_DEF "./Maildir"
 . &nbsp;Please see the section <b><a href="#DelTag">Compiling Maildrop</a>
  </b>in that page.<br>
  <font color="#000000"><br>
    <br>
  By the filtering commands setting a variable "DELTAG"  to "1", any subsequent
 delivery, either "to" or "cc" which are to Maildir  format mailboxes will
 result in the message having the "T" flag set on its file name.&nbsp; IMAP
 servers recognise this as the "Tagged for deletion"  flag.&nbsp; At least
 with Courier IMAP and Netscape, the email will be moved from the /new/ directory
 of the Maildir to the /cur/ directory, with this tag intact.&nbsp; Then
it  will show up in the client as tagged for deletion, and a subsequent IMAP
expunge command will delete it.</font>                      
  <p><font color="#000000">The source is well commented, self-explanatory
  and all the changes are tagged "RW".&nbsp; Copyright public domain.</font></p>
                        
  <p><font color="#000000">See the filtering section below for some  examples.</font></p>
            </blockquote>
              
<p><br>
            </p>
              
<hr align="left" size="1" width="200"><br>
   &nbsp;                         
<h2><a name="subjadd"></a> subjadd - add a label like [XYZ] to the Subject:
 line of an email</h2>
              
<blockquote>Here is the source file, and a tar-gzip file with the source and
firstly a Red Hat 7.1 i386 executable  and secondly a Red Hat 9.0 i386 executable.:<br>
  <br>
Here is the source file, a Red Hat 7.1 i386 executable  and the two zipped:
                                   
  <blockquote><tt><a href="subjadd.c">subjadd.c</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
11,108 bytes</tt><br>
               <tt><a href="subjadd">subjadd</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
17,882 bytes</tt><br>
               <tt><a href="subjadd.tgz">subjadd.tgz</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
9,829 bytes</tt></blockquote>
  <tt>     </tt>                <b>subjadd</b> is a filter - working from
stdin to stdout.&nbsp;  Maybe it will be useful for other situations than
being called from Maildrop.&nbsp;   Please let me know if you have any such
uses.                                          
  <p>Here is the usage text for <b>subjadd</b>: </p>
                            
  <p><tt><font color="#000099">&nbsp; Adds a label such as [XYZ]  to the
subject line of an email on</font></tt><br>
                <tt><font color="#000099">&nbsp; stdin and sends it to stdout.&nbsp;
  The label is the only argument.</font></tt></p>
                            
  <p><tt><font color="#000099">&nbsp; subjadd [XYZ]&nbsp;&nbsp;&nbsp;&nbsp;
  results in:</font></tt></p>
                            
  <p><tt><font color="#000099">&nbsp;&nbsp;&nbsp; Subject: Foo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  Subject: Re: Bar</font></tt><br>
                <tt><font color="#000099">&nbsp;&nbsp;&nbsp; Subject: [XYZ]
 Foo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Subject: Re: [XYZ]
 Bar</font></tt></p>
                            
  <p><tt><font color="#000099">&nbsp; Always passes the file,  but only writes
 the label if it is the</font></tt><br>
                <tt><font color="#000099">&nbsp; sole argument.&nbsp; If
there  was no subject line, then an empty one</font></tt><br>
                <tt><font color="#000099">&nbsp; is added, preceded by an 
informative  header line:</font></tt></p>
                            
  <p><tt><font color="#000099">&nbsp;&nbsp;&nbsp; X-Subjadd: No subject line,
 so this one was added by subjadd.</font></tt></p>
                            
  <p><tt><font color="#000099">&nbsp; "subjadd" primarily means  "adding
to the subject line"</font></tt><br>
                <tt><font color="#000099">&nbsp; but if there was no subject
 line, then its function is to</font></tt><br>
                <tt><font color="#000099">&nbsp; "add a subject line" too.</font></tt></p>
                            
  <p><tt><font color="#000099">&nbsp; Always returns 0.&nbsp;  Intended to
 be used with the xfilter</font></tt><br>
                <tt><font color="#000099">&nbsp; command of Sam Varshavchik's
 Maildrop mail filtering program.</font></tt></p>
                            
  <p><tt><font color="#000099">&nbsp; Public domain.&nbsp;&nbsp;  Robin Whittle&nbsp;
 www.firstpr.com.au&nbsp; 8 July 2001</font></tt><br>
   &nbsp;</p>
                </blockquote>
                  
<p><br>
                </p>
                  
<hr align="left" size="1" width="200">                
<h2><a name="Filtering"></a> Exploring Maildrop's filtering</h2>
                                 
<blockquote>Note: see the <a href="../">parent directory</a> for another page,
begun in October 2002, with more Maildrop filtering examples and how I use
it to run Spam Assassin and Anomy Sanitizer.<br>
    <br>
  Maildrop has an extensive and well organised filtering  language.&nbsp; 
The typical arrangement is for each user to have a <tt>.mailfilter</tt>  file
in their home directory.&nbsp; This is a text file, using the commands  documented
in:                                               
  <blockquote>                  <li><a
 href="http://www.flounder.net/%7Emrsam/maildrop/maildropfilter.html"> http://www.flounder.net/~mrsam/maildrop/maildropfilter.html</a>
  &nbsp;<a name="maildropfilter"></a> Documents the filtering language.</li>
                    <li><a
 href="http://www.flounder.net/%7Emrsam/maildrop/maildroptips.html"> http://www.flounder.net/~mrsam/maildrop/maildroptips.html</a>
   Hints on using the filtering language.</li>
                    </blockquote>
    There is not much in the way of examples in this documentation.     
                                            
  <p>Patterns can be matched, typically in the email's header,  but also
in the body or in both, and actions taken.&nbsp; Actions include  delivering
 it to a mailbox, by default to the Inbox, or to any number of email address.&nbsp;
 An email can be copied to a local mailbox (and then perhaps to another)
before,  typically but not necessarily, being delivered to the Inbox. </p>
                                
  <p>The filtering "recipe" - as I will refer to the contents  of the <tt>.mailfilter</tt>
 file or any other files it includes - also has  the capability to pass the
 message through an external program, which processes  the message from stdin
 to stdout according to parameters in or generated by the filtering program.&nbsp;
 In this way, the message itself can be modified.                    </p>
                                
  <p><tt>.mailfilter</tt> must have its permissions set only  to be accessible
 to the user, otherwise Maildrop generates an error.&nbsp;  Maildrop compiles
 the contents of the file and exits with an error if there  is a syntax problem
 with it. An error to this effect will be written in <tt> /var/log/maillog</tt>
 .&nbsp; For instance: </p>
                                
  <blockquote><tt>postfix/local[23463]: 3CDCF3D9C: to=&lt;blah@firstpr.com.au&gt;,
  relay=local, delay=0, status=deferred (temporary failure. Command output:
                      <font color="#ff0000">.mailfilter(33): Syntax error 
after if </font>)</tt></blockquote>
    The <tt><font color="#ff0000">(33)</font></tt> refers to the line number
  where the syntax error occurs.                                        
            
  <p>The intention is that the calling program, the MTA  - Postfix in my
case - will queue the message for delivery later.&nbsp; Postfix  does do
this.&nbsp; The command: </p>
                                  
  <blockquote><tt>postfix flush</tt></blockquote>
    will cause all queued messages to be delivered immediately.         
                                                
  <p>It haven't figured out how to run Maildrop on the  command line to check
 the <tt>.mailfilter</tt> syntax, but I am sure it can  be done, or achieved
 by some script.&nbsp; Without such a test, the way to  test that he new
filtering  recipe does not have syntax errors is to send yourself a test
email and check  that it comes through. </p>
                                    
  <p><b>Setting the filter recipe by web or email?</b></p>
                                    
  <p>The filtering language is pretty fancy, and not the sort of thing a
non-technical user would want to mess with.&nbsp; A good project would be
a Web or email interface into this filtering capability.&nbsp; For instance
placing an email of a particular format into a particular mailbox  via IMAP,
where a program would crunch it, convert it to a <tt>.mailfilter</tt> &nbsp;
file or if there were any errors, annotate the original file with  pointers
to what needs to be fixed.&nbsp; Alternatively, Maildrop could have  a filter
recipe to pass an email with special flags that it contains a new  filter
recipe to an external program which will extract the recipe, install  it,
send a test mail, and if it gets through, leave the new recipe in place 
and send an acknowledgement email.&nbsp; If the new recipe had syntax errors,
 then the program would remove it, restore the old one and send something
helpful back to the user about whatever errors Maildrop reported (in <tt>/var/log/maillog</tt>
  ).&nbsp; The same system could also make a copy of the filter log available
  by some means, such as mailing it to the user.                       </p>
                                    
  <p>From the same stable as Courier, Courier IMAP and  Courier Maildrop,
 is a cgi-based web-mail system called SqWebMail.&nbsp; This has a web-based
 filtering interface for Courier Maildrop.&nbsp; <a
 href="http://www.inter7.com/sqwebmail/"> http://www.inter7.com/sqwebmail/</a>
   - but I haven't checked it out.&nbsp; See my page via the parent directory
  of my installation of it and my brief evaluation. </p>
                                    
  <p>When I get up to speed with mail filtering, I will  put some sample
files here.&nbsp; The documentation of the filtering language  is clear,
but has very few examples. </p>
                                    
  <p><b>Brief examples of a filtering "recipe"</b></p>
                                    
  <p>Here is a simple .mailfilter file: </p>
                                    
  <blockquote><tt><font color="#cc33cc">logfile "maildrop-filter-log"</font></tt>
                                             
    <p><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   # Search the message body for distinctive SirCam virus/worm text.</tt><br>
                          <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   #</tt><br>
                          <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   # ":b" means search the body.</tt></p>
                                              
    <p><tt><font color="#3366ff">if(&nbsp;&nbsp;&nbsp;  ( /I send you this
 file in order/:b)&nbsp;&nbsp; \</font></tt><br>
                          <tt><font color="#3366ff">&nbsp;&nbsp;&nbsp; || 
( /Te mando este archivo para que/:b)&nbsp; \</font></tt><br>
                          <tt><font color="#3366ff">&nbsp; )</font></tt><br>
                          <tt><font color="#3366ff">{</font></tt><br>
                          <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   # Copy it to a mailbox. Then add a label</tt><br>
                          <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   # deliver it to the Inbox.</tt><br>
                          <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   # The "to" command terminates filtering.</tt><br>
                          <tt>&nbsp;&nbsp;&nbsp;<font color="#3366ff"> cc 
"Maildir/.yyy.xxx"</font></tt><br>
                          <tt><font color="#3366ff">&nbsp;&nbsp;&nbsp; DELTAG=1</font></tt><br>
                          <tt><font color="#3366ff">&nbsp;&nbsp;&nbsp; xfilter
 "subjadd [SirCam]"</font></tt><br>
                          <tt><font color="#3366ff">&nbsp;&nbsp;&nbsp; to 
"Maildir"</font></tt><br>
                          <tt><font color="#3366ff">}</font></tt><br>
   &nbsp; <br>
   &nbsp; </p>
                                              
    <p><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   # Now look in the headers only, for a particular line.</tt><br>
                          <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   # Absence of ":b" means search in the headers only.</tt><br>
                          <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   # The "^" means look for this text at the start of the</tt><br>
                          <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   # line only.</tt></p>
                                              
    <p><tt><font color="#009900">if ( /^Delivered-To:  postfix-users@cloud9.net/
 )</font></tt><br>
                          <tt><font color="#009900">{</font></tt><br>
                          <tt><font color="#009900">&nbsp;&nbsp;&nbsp; cc 
"Maildir/.Lists.Postfix"</font></tt><br>
                          <tt><font color="#009900">&nbsp;&nbsp;&nbsp; DELTAG=1</font></tt><br>
                          <tt><font color="#009900">&nbsp;&nbsp;&nbsp; xfilter
 "subjadd [PF]"</font></tt><br>
                          <tt><font color="#009900">&nbsp;&nbsp;&nbsp; to 
"Maildir"</font></tt><br>
                          <tt><font color="#009900">}</font></tt></p>
                          </blockquote>
                                      
  <p><br>
   If statements are supposed to be on a single line - so use trailing backslashes
 to continue them (or any other statement) over mulitple lines. </p>
                                      
  <p>Be especially careful not to have a blank line  after an if (. . . )
 line!!!&nbsp; If the example had been: </p>
                                      
  <blockquote><tt><font color="#3366ff">if(&nbsp;&nbsp;&nbsp;  ( /I send
you this file in order/:b)&nbsp;&nbsp; \</font></tt><br>
                            <tt><font color="#3366ff">&nbsp;&nbsp;&nbsp;
||  ( /Te mando este archivo para que/:b)&nbsp; \</font></tt><br>
                            <tt><font color="#3366ff">&nbsp; )</font></tt>
                                            
    <p><tt><font color="#3366ff">{</font></tt><br>
                            <tt><font color="#3366ff">&nbsp;&nbsp;&nbsp;&nbsp;
 .....</font></tt></p>
                            </blockquote>
    then the if statement would have not had any effect and control would 
fall  through to whatever was in the braces. <br>
   &nbsp; <br>
   &nbsp;                                                               
   
  <p>Note that the two mailboxes mentioned here are  specified by their exact
 directory name, relative to the user directory.&nbsp;  This is how it works
 with Courier IMAP, but Maildrop does not rely on Courier  IMAP and can deliver
 to Maildir mailboxes no matter what the IMAP/POP server  is: </p>
                                        
  <blockquote><tt><font color="#3366ff">Maildir/.yyy.xxx/</font></tt></blockquote>
    is a mailbox in the <tt>yyy</tt> folder (of the INBOX, as are all folders
  with Courier IMAP) of name xxx                                        
                             
  <blockquote>              
    <p>(Note: &nbsp;See the mb2md page from the parent directory to read more
about Courier IMAPD's Maildir mailbox naming and directory structures, and
how to convert from Mbox format to Maildir.)<br>
      </p>
    </blockquote>
          
  <p>Likewise: </p>
                                          
  <blockquote><tt><font color="#009900">Maildir/.Lists.Postfix</font></tt></blockquote>
    appears to the user as:                                             
                            
  <blockquote><tt>Inbox -----------------------</tt><br>
                                  <tt>&nbsp;&nbsp;&nbsp; |</tt><br>
                                  <tt>&nbsp;&nbsp;&nbsp; | --- Lists</tt><br>
                                  <tt>&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 |</tt><br>
                                  <tt>&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 | --- Postfix ---</tt><br>
                                  <tt>&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 |</tt></blockquote>
    In the Maildrop' log file, as specified at the start of the <tt>.mailfilter</tt>
   file, the two sections above generate results like this when they successfully
  handle a message:                                                     
                        
  <blockquote><tt><font color="#3366ff">Date:  Thu Aug&nbsp; 2 00:10:52 2001</font></tt><br>
                                    <tt><font color="#3366ff">From: Foo &lt;foo@example.org&gt;</font></tt><br>
                                    <tt><font color="#3366ff">Subj: [SirCam]
 Fantasies for Mistress.doc</font></tt><br>
                                    <tt><font color="#3366ff">File: Maildir/.yyy.xxx&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   (243295)</font></tt>                                                  
   
    <p><tt><font color="#009900">Date: Thu Aug&nbsp; 2 00:17:13 2001</font></tt><br>
                                    <tt><font color="#009900">From: Foo &lt;foo@example.org&gt;</font></tt><br>
                                    <tt><font color="#009900">Subj: [PF]
Postfix  rocks!</font></tt><br>
                                    <tt><font color="#009900">File: Maildir/.Lists.Postfix&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   (2474)</font></tt></p>
                                    </blockquote>
                                                
  <p><br>
   If the filtering recipe specifies sending the message to a mailbox which
 does not exist as a proper Maildir mailbox, then Maildrop will create an
ordinary Mbox format mailbox file of that name instead. </p>
                                                
  <p>The Maildrop filtering language is rich:                           
       </p>
                                                
  <ul>
                                      <li> Extra log file entries can be
generated  as desired: simply use the "log" command followed by text.</li>
                                      <li> Files can be conditionally included
 - which saves long, rarely needed sets of filtering instructions from needing
 to be compiled except when needed.</li>
                                      <li> There are text and numeric variables.</li>
                                      <li> There are if, for and while constructs.</li>
                                      <li> There are ways of trapping exceptions
 within a section which would normally be fatal to Maildrop!</li>
                                      <li> "Although Maildrop evaluates expressions
 numerically, results of expressions are stored as text literals. When necessary,
 text literals are converted to numbers, then the results of a mathematical
 operation is converted back into a text literal."</li>
                                                
  </ul>
    So I don't see much reason to be concerned about the language being inadequate
  for any mail filtering operation.                                     
                                            
  <p>Here are some advanced examples I can  think of: </p>
                                                
  <p>Lets say I get a bunch of emails all  the time from Telstra Internet
 about outages all over the country - but in  fact I never look at them because
 the Subject: lines are all the same, and  very few concern me.&nbsp; A filtering
 rule could find these messages, and  then scan the body to identify those
 which concern my neck of the woods.&nbsp;  Then, those messages could be
given distinctive labels and perhaps copied  or delivered to the Inbox in
ways which are different from the rest of these  messages. </p>
                                                
  <p>It is possible to use an external programs  or scripts to send email
 to any destination - including to an SMS message  gateway.&nbsp; So the
filtering  system could alert me via my mobile bone to particular incoming
emails. <br>
   &nbsp;<br>
    </p>
                                                    
  <h4>Which headers to look for in mailing lists?</h4>
                                                    
  <p> </p>
                                                    
  <p>Generally, for mailing lists I find that the "Return-Path: " header
# is the most distinctive and stable for all the ways that messages can be
sent to a mailing list. &nbsp;Yahoo Groups lists (and others which run from
elzm) are different - the "Return-Path: " is customised for every message.&nbsp;
 So the "Reply-To: " seems to be the best header. &nbsp;But list servers
can  do all sorts of things! &nbsp;</p>
                                                    
  <p>Sometimes the "Delivered-To: " header can be distinctive, such as to
   <tt>xxxxx-outgoing@example.org</tt> .<br>
                                        <br>
                                        </p>
                                                    
  <h4>Examples<br>
                                        </h4>
                                                    
  <p> Here is a slightly shortened copy of my original operational .mailfilter
 file:<br>
                                    </p>
                                                
  <blockquote><big><a href="my.mailfilter.txt"> my.mailfilter.txt</a></big>
                                     <br>
                                      </blockquote>
                                                  
  <p>In fact, as time goes on, it gets more elaborate rules to cope with
every possible way some list servers might relay mailing list messages.<br>
    </p>
                                                      
  <p>Here is a section of the log file it generates:</p>
                                                  
  <blockquote>                                                          
    <p><big><a href="mailfilter-log.txt">mailfilter-log.txt</a></big>&nbsp;</p>
                                                            
    <p>                                      </p>
    </blockquote>
  </blockquote>
                                              
<p><br>
                                            </p>
                                              
<h3>Update history</h3>
                                              
<ul>
                                              <li>2003 May 29 Page established, 
based on August 2001 version.</li>
 
</ul>
 <br>
                                              
<p><br>
                                            </p>
                                              
<blockquote>                                                        
  <p><br>
                                        </p>
                                                          
  <blockquote>                                                          
    <p>                                      </p>
                                        </blockquote>
                                        </blockquote>
                                                                        
 <br>
  <br>
  <br>
  <br>
 <br>
</body>
</html>