Subject: Elm/NeXTMail tricks

From: Robert Nicholson <[email-masked]>
Date: Wed, 9 Jun 1993 08:47:54 +0100

OK, I am one of the few people who doesn't like using NeXTMail for
ordinary mail.  So I have here a solution that allows you to only use
NeXTMail to receive mail that has attachments in it only.  All other
mail can be handled in a Unix mailer like Elm for instance.

The way NeXTMail works when it retrieves new mail it just
rips everything out of /usr/spool/mail/$LOGNAME and puts it into the
Active.mbox (a NeXTMAil format mailbox).  I like to store my news
(from trn) and mail in the same format hence I needed a solution that
allowed me to store mail in normal unix mailbox format.

Well here it is.  The trick is to only ever have waiting in
/usr/spool/mail/$LOGNAME mail with attatchments only.  So before hand
you must have retrieved all Text only mail and put it somewhere else.

Procmail lets you do this (and a lot of other things) nicely. Procmail
is a rule based filter.  In procmail you specify what you would like
done with your mail based on pattern matching with each itemss headers.
So for instance, I have this rule in procmail

::
^TOnext-prog
next-prog

This takes all messages addressed to the next-programmers mailing list
and puts them it their own mailbox.

Procmail is run from the .forward file for each mail item that arrives.  In
Procmail you can specify an alternative to /usr/spool/mail/$LOGNAME
ie. where you would like all incoming mail. What this means is that
for all messages that procmail doesn't match in a rule 
get left where you specify them.  Note:this is because I have told
procmail to not continue processing mail after it has found a match.
You can specify that procmail continue processing mail (ie. attempt to
match against further rules) even if it found a match and you will be able 
to duplicate your mail should you so desire.

-----------------

Side note:  I don't like biff writing to every terminal window so I
use as my first rule in procmail this. Note: the 'c' after ':' means
continue looking for other matches.

:c
^TO.*
| /usr/local/bin/newm "`date`" "`formail -rt -xTo:`" "`formail
-xSubject:`"

/usr/local/bin/newm looks like this

:
# Store a counter in /usr/tmp/nm

TMP=/usr/tmp/nm

COUNT=`cat $TMP` 
COUNT=`expr $COUNT + 1`
echo $COUNT >$TMP
echo $0 $1 $2 $3 $4 > /usr/tmp/robert
#echo [$COUNT] "$1" "$2" `echo "$3" | awk '{ print $5 }'` > /dev/console
echo [$COUNT] "`echo $1 | awk '{print $4}'`" "$2" "$3"  > /dev/console

The logic here was to put a counter beside each mail item as it
arrived.  This is because when I log into my host I am told how many
messages are waiting for me and I would like to know when I have
retrieve all my mail.

------------------

I have chosen to leave all messages that didn't match a rule in ~/Mail/mbox 
by specifying.

DEFAULT=$MAILDIR/mbox

in my .procmailrc file.

Now the key rule is this one.

::
^Next-Attachment
/usr/spool/mail/robert

This ensures that only mail with NeXTMail attachments is stored in the
folder where NeXTMail expects to find it all other mail has been
"shoved" somewhere else.

I wouldn't recommend configuring NeXTMail to automatically retrieve
mail with this solution since it's quite possible that NeXTMail could
grab the Text only mail before procmail has been run from .forward and
this would stuff up the whole scheme.  So I manually retrieve NeXTMail
with the "Get New Mail" from Utilities.

For somebody who doesn't like being forced into a proprietory mailbox
format this is a temporary workaround until MIME compatible NeXTMail
arrives :-).  I hope this is been clear and that you get some use out
of it.