[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Sort mail into "folders" by month
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 http://www.kanga.nu/archives/
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 Kanga.nu.
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):
~archiver/Mail/lists/<listname>/archive.YYYYQq
Where YYYY is the year and Qq is "Q" followed by the quarter number
(1-4).
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:
--<cut>--
$dirlist = array();
$base_dir = opendir(".");
while ($file1 = readdir ($base_dir)) {
if (ereg ("^[0-9]{4}", $file1)) {
if (!is_dir ($file1)) {
continue;
}
$dir_name = $file1;
$dir_handle = opendir ($dir_name);
$count = 0;
while ($tmp = readdir ($dir_handle)) {
if (ereg ("^msg[0-9]{5}", $tmp)) {
$count++;
}
}
closedir($dir_handle);
if ($count > 0) {
$dirlist += array ("$dir_name" => "$count");
}
}
}
closedir ($base_dir);
krsort ($dirlist);
$content = '
<table width="100%" border=2>
<tr>
<td align="center"><b>Period</b></td>
<td align="center"><b># Messages</b></td>
<td align="center" colspan=3><b>Indexes</b></td>
</tr>';
while (list ($period, $period_count) = each ($dirlist)) {
$content = $content . "
<tr>
<td align='center'>" . $period . "</td>
<td align='center'>" . $period_count . "</td>
<td align='center'><a href = '" . $period . "/author.php'>Author</a></td>
<td align='center'><a href = '" . $period . "/index.php'>Date</a></td>
<td align='center'><a href = '" . $period . "/thread.php'>Thread</a></td>
<tr>";
}
$content = $content . "
</tr>
</table>";
--<cut>--
CPU expensive, but workable.
You can find all the various scripts, RCs etc off at
ftp://ftp.kanga.nu/pub/Kanga.Nu/WebArchives[.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@kanga.nu He lived as a devil, eh?
http://www.kanga.nu/~claw/ Evil is a name of a foeman, as I live.
[Index of Archives]
[Bugtraq]
[Yosemite News]
[Mhonarc Home]