Re: Sort mail into "folders" by month

2002-06-14 04:30:04
On Wed, 12 Jun 2002 14:37:16 -0700 (PDT) 
unixsysadm  <Don> wrote:

Hello, I've got an archive with literally thousands of emails in it
and it is growing rapidly.  I would like to organize it by having a
main page of archives by month/year.  When a particular month is
selected I'd like to have a link for each separate email.  The layout
I'd like is very similar to

The easy way is to split your mail up into the sections you want, either
by MH folder (what I do) or as mboxes, and then invoke MHonArc on each
mail collection individually, shoving the resulting HTML in a separate
directory.  This is exactly what I do at

The setup here, loosely:

  Mail comes into procmail and is delivered to MH folders (you can use
  mboxes -- I use MH folders as I like MH):

  Where YYYY is the year and Qq is "Q" followed by the quarter number
  A cronjob runs against ~archiver/public-html/lists/<listname>/YYYQq
  reading the mail in ~archiver/Mail/lists/<listname>/archive.YYYYQq.

  The following PHP is the basis of the index.php in
  ~archiver/public-html/lists><listname> to create the table of periods
  and the number of messages in each etc:

$dirlist = array(); 
$base_dir = opendir("."); 

while ($file1 = readdir ($base_dir)) { 
  if (ereg ("^[0-9]{4}", $file1)) { 
    if (!is_dir ($file1)) {
    $dir_name = $file1;
    $dir_handle = opendir ($dir_name); 
    $count = 0; 
    while ($tmp = readdir ($dir_handle)) {
      if (ereg ("^msg[0-9]{5}", $tmp)) { 
    if ($count > 0) { 
      $dirlist += array ("$dir_name" => "$count"); 
closedir ($base_dir); 
krsort ($dirlist);

$content = '
                    <table width="100%" border=2> 
                        <td align="center"><b>Period</b></td>
                        <td align="center"><b># Messages</b></td>
                        <td align="center" colspan=3><b>Indexes</b></td>      

while (list ($period, $period_count) = each ($dirlist)) {
  $content = $content . "
                        <td align='center'>" . $period . "</td>
                        <td align='center'>" . $period_count . "</td>
                        <td align='center'><a href = '" . $period . 
                        <td align='center'><a href = '" . $period . 
                        <td align='center'><a href = '" . $period . 

$content = $content . "

CPU expensive, but workable.

You can find all the various scripts, RCs etc off at[.old].  Vague instructions
and details on their use have been posted to this list (see the
archives), or more compleatly (which isn't very compleat) to the Mailman
user FAQ.

J C Lawrence                
---------(*)                Satan, oscillate my metallic sonatas. 
claw(_at_)kanga(_dot_)nu               He lived as a devil, eh?    Evil is a name of a foeman, as I live.