Subject: Q: Replacement, newbie, LONG

From: [email-masked] (Nadeem Ahmed)
Date: Sat, 25 Mar 95 13:18:24 EST

This is my first use of 'procmail'.  I have already read the FAQ [1],
and devoured the 'man' pages, but am still not too happy with my
solution.  This mail is long but I have give some background.  Here's
what I'm trying to do.

The company I work for relies heavily on SprintMail(TM) as its mailing
system.  Although acceptable in a lot of respects, it is horrifying as
far as user-friendliness is concerned.  Many of us would prefer 'mail'
and its derivatives.

SprintMail allows AUTO-FORWARDING.  Unlike what the name might indicate,
the feature is designed more for vacationing managers who wish to leave
others incharge.  So, for example, when I receive such a mail, it looks
to me as if my manager received it on his mailbox, read it, and
delegated it to me to take care of it.  The most recent originator,
then, is my manager, and the original mail (addressed to my manager by
another SprintMail'er), becomes an attachment to this mail.

I (and the others who prefer 'mail') use this feature to AUTO-FORWARD
all _my_ SprintMail to my UNIX account (via a local X400 gateway).

Works great, with one small problem.  The originator of all such mail is
(obviously) me, from behind the gateway.  The actual originator (of the
SprintMail) is buried in the body.  This causes some side-effects.  The
"From" string in the message window isn't of much use, 'Mail -H' or
'from' outputs are useless. There is no simple hit of the 'r' to reply.

This is where I need 'procmail'!  I need to extract the original
sender's name (M.SEDEHI in the SprintMail example below) first, replace
_all_ occurences of "[email-masked]" (me behind the
gateway) in the _header_ part of the mail, and regenerate the mail to
myself.

My '~/.procmailrc' looks something like (please jump in...)

------------------------------------------------------------------------
PATH=/home/hss/nahmed/bin:/bin:/usr/bin:/usr/local/bin		#1

:0 w								#2
* ^From.*NADEEM.AHMED
{
    SMAIL_X400FWD_MYID="[email-masked]"
    SMAIL_X400FWD_FROM="`smailgof`"				#3

    :0 fw							#2
    | smailrbf							#4
}

#1	procmail is in my $HOME/bin for now
#2	good (?) guesses
#3	my routine.  extracts original sender's name from the body.
#4	my routine.  replaces SMAIL_X400FWD_MYID strings with original
#	sender string in the header.  if my '.mailrc' aliases are set up
#	correctly, i can reply by doing a 'r'.
------------------------------------------------------------------------

Usually I am not too critical of the things I write (secret of my
perennial youth :-)  ), but I am horrified at my first attempt for a
solution (even though it seems to be working).  I think I should have
been able to better use the features of the 'procmail' package, rather
than re-inventing the wheel.

Any hints?
Nadeem.

[1]	Nancy, I think you _should_ do the full-fledged FAQ.  Your notes
	are a very good complement to the already helpful 'man' pages.

SAMPLE SPRINTMAIL (abridged for space reasons)
------------------------------------------------------------------------

>From [email-masked] Tue Sep  6 12:17:54 1994
From: [email-masked]
Date: Tue, 6 Sep 1994 12:08:39 -0400
To: [email-masked]
Subject: Hardware Segment Server "bach" and "curly" Outage 
Autoforwarded: TRUE
X400-Originator: [email-masked]
Status: O

Auto-forwarded message:

Posted: Tue, Sep  6, 1994  10:56 AM EDT              Msg: BGJE-6543-7900
From:   M.SEDEHI
To:     CADENCE.USERS
CC:     HD.DEPT, SUN.USERS
Subj:   Hardware Segment Server "bach" and "curly" Outage 

Both servers "curly" and hardware segment server "bach"
will be unavailable from 5:30 - 5:45 this evening
Tuesday 9/6/94. The outage on curly may last longer
depending on how well things go.

I do not expect "curly" to be down beyond 6:00 P.M. .
Please plan ahead.

Thnaks,

Mike Sedehi
Development Systems

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