Adding messages to an archive is done via the -add option. If no mailbox/folder
arguments are given, MHonArc assumes that a single message is being added to
the archive via standard input. Otherwise, MHonArc adds the messages contained
in the mail folders specified.
MHonArc will skip any messages that already exist in an archive. If a message to be added has a message-ID that equals a message-ID of an archived message, the message is skipped.
Here is example session adding an mail folder to an existing archive:
% mhonarc -add test/www
Requiring MIME filter libraries ...
mhexternal.pl
mhtxthtml.pl
mhtxtplain.pl
mhtxtsetext.pl
Adding messages to ./maillist.html
Reading test/www/ ........................................
Writing HTML ...
49 messages
MHonArc can be used to add new messages as they are received by using the
".forward" file in your home directory. Here is how I would set up my
.forward file to invoke MHonArc on incoming mail:
\ehood, "|/mnt/ehood/bin/webnewmail #ehood"
.forward entry:
The "\ehood" tells sendmail to still deposit the incoming message to my
mail spool file. The "#ehood" Bourne shell comment is needed to insure
the command is unique from another user. Otherwise, sendmail may not
invoke the program for you or the other user.
"webnewmail" is a Perl program that calls MHonArc with the appropriate
arguments. A wrapper program is used instead of calling MHonArc directly to
keep the .forward file simple. Here is the code to the webnewmail program:
#!/usr/local/bin/perl $cmd = "/mnt/ehood/bin/mhonarc -add -quiet " . "-outdir /mnt/ehood/public_html/newmail"; open(M2H, "|$cmd"); print M2H <STDIN>; close(M2H);
The webnewmail can be modified to check the mail header before calling
MHonArc to perform selective archiving of messages. For example, webnewmail
can check the To: field and only archive messages that come from a specific
mailing list.
This example uses cron(1) to update some mail archives from MH mail folders.
The following entry is in my crontab file:
0 0 * * * webmail
webmail is a script executed every night that calls MHonArc to perform the
update:
#! /bin/csh -f
umask 022
setenv M2H_RCFILE $HOME/.mhonarc.rc
## WWW messages
mhonarc -add \
-outdir $HOME/public_html/doc/wwwmail \
$HOME/mail/www
folder +www >& /dev/null
refile first-last +www.ar >& /dev/null # Archive original messages
## Tools messages
mhonarc -add \
-outdir $HOME/public_html/doc/toolsmail \
$HOME/mail/tools $HOME/mail/dtd
folder +tools >& /dev/null
refile first-last +tools.ar >& /dev/null # Archive original messages
folder +dtd >& /dev/null
refile first-last +dtd.ar >& /dev/null # Archive original messages
folder +inbox >& /dev/null # Set current folder to inbox
To avoid mail everynight from cron due to output from MHonArc, the -quiet
option can be used for each call to MHonArc, or use the following line in your
crontab file:
0 0 * * * webmail > /dev/null
Standard error is not redirected to /dev/null so mail is still received if errors
occured during MHonArc execution.