Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!pasteur!ucbvax!decwrl!labrea!csli!gandalf
From: gandalf@csli.STANFORD.EDU (Juergen Wagner)
Newsgroups: comp.unix.questions
Subject: Re: Mail forwarding
Keywords: mail forwarding
Message-ID: <4210@csli.STANFORD.EDU>
Date: 7 Jun 88 16:55:46 GMT
References: <13426.1988May27.16:41:31@mill.me.toronto.edu> <2269@admin.mips.COM> <2270@admin.mips.COM> <2131@ur-tut.UUCP> <364@mipseast.mips.COM> <891@dsacg3.UUCP>
Reply-To: gandalf@csli.stanford.edu (Juergen Wagner)
Organization: Center for the Study of Language and Information, Stanford U.
Lines: 58

In article <891@dsacg3.UUCP> ntm1458@dsacg3.UUCP (John Darby) writes:
>
> My .forward file looks like this:
> hostname\!myid
...stuff deleted...
>John T. Darby, (DLA Systems Automation Center, DSAC-TMM, P.O. Box 1605

Ok. That's fine. I believe, the original question was how to redirect
incoming mail to both, a program and the mailbox. The above solution
only forwards mail to another machine. A few comments on that:

o  The syntax user@host is preferrable and should be understandable
   for all mailers.

o  You should even keep a .forward on the machine you're reading your
   mail on because if you have a couple of machines hooked up over
   NFS, your home directory may always be the same (i.e. also your
   .forward). Say, you have machines "foo" and "bar" sharing the NFS
   file system on which your common home directory resides. Sending
   mail to either one will stay on that machine. Having a "global"
   .forward will forward it to one machine. You could, of course, also
   use a pipe to store incoming mail in a file accessible from both
   machines.

o  The .forward actually contains a list of paths to forward mail to.
   It contains a comma-separated list of addresses or pipes. Using a
   .forward
	gandalf@csli.stanford.edu, gandalf@portia.stanford.edu
   will NOT cause mail looping on csli because when sending mail on
   host X to user Y, addresses Y@X' where X' is a name for X, are
   simply ignored.

o  To prevent alias expansion, you can precede the address by a backslash.
	\gandalf
   will directly send it to user gandalf on the local machine, and
   will not try alias expansions. Other backslashes are not needed.
   I believe, they are properly treated, though.

o  To pipe something into a program, use the following syntax:
	"|/a/gandalf/getmail gandalf"
   where /a/gandalf/getmail might be a short script like
	#! /bin/csh
	touch /a/gandalf/post
	echo "" >> /a/gandalf/post
	echo "This is a message received on `date`." >> /a/gandalf/post
	cat >> /a/gandalf/post
	echo "--------end of message----------(to $1)" >> /a/gandalf/post
	exit 0
   which collect all messages into a file /a/gandalf/post (quick and
   dirty). The message is read by reading standard input.

That's something about mail. If anybody has further questions, please
consult the man page "aliases, ...(4)" which describes all that in
detail. Flames to /dev/null, please.

-- 
Juergen "Gandalf" Wagner,		   gandalf@csli.stanford.edu
Center for the Study of Language and Information (CSLI), Stanford CA