[comp.unix.questions] Mail forwarding

cwwj@ur-tut (Clarence Wilkerson) (05/31/88)

 How do I set up a .forward file to send incoming messages to as local file
and to forward the messages to a remote machine.

ntm1458@dsacg3.UUCP (John Darby) (06/07/88)

 My .forward file looks like this:
 hostname\!myid
 where hostname is where you want your mail forwarded and myid is the
 id you use on that system. The \ is to escape the ! when you use csh.
 On the dsacg1 system (the system that handles our news and mail, my
 .forward file is dsacg3\!jdarby.
-- 
John T. Darby, (DLA Systems Automation Center, DSAC-TMM, P.O. Box 1605
Columbus, OH, ntm1458, 614 238-9174)
UUCP: {...cbosgd!osu-cis}!dsacg1!jdarby
Any opinions expressed are my own, not those of my employer.

gandalf@csli.STANFORD.EDU (Juergen Wagner) (06/07/88)

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