[comp.unix.questions] BSD mail .forward question

haynes@ucscc.UCSC.EDU (Jim Haynes) (02/03/89)

I have a user with accounts on two different machines here.  He would
like to have it so that when he receives mail addressed to either machine
a copy is delivered to both machines.

What he naively was to have a .forward file on both machines saying
to deliver to the local machine and also to the other.  This of course
resulted in the mail bouncing between the two machines until the maximum
hop count hit, then delivering it to MAILER-DAEMON.

Can anybody think of a clever way to achieve what he wants?

haynes@ucscc.ucsc.edu
haynes@ucscc.bitnet
..ucbvax!ucscc!haynes

"Any clod can have the facts, but having opinions is an Art."
        Charles McCabe, San Francisco Chronicle

mende@athos.rutgers.edu (Bob Mende Pie) (02/03/89)

In article <6218@saturn.ucsc.edu> haynes@ucscc.UCSC.EDU (Jim Haynes) writes:

> I have a user with accounts on two different machines here.  He would
> like to have it so that when he receives mail addressed to either machine
> a copy is delivered to both machines.

yes ... but it is a hack...

on machine1 have a .forward that looks like:
user@machine2

on machine2 have a .forward that looks like:
\user
user-local@machine1

on machine1 have an entry in /usr/lib/aliases that looks like
user-local: \user

I dont there is there is an easy way to avoid a mail loop without doing it
this way.

					/Bob...
-- 

gandalf@csli.STANFORD.EDU (Juergen Wagner) (02/04/89)

Hmm... give the user the login name MAILER-DAEMON, and everything will be
fine... No, serious, there is a simple solution:

hosta:/etc/aliases
	the-user:	the-user-copy, the-user-copy@hostb
	the-user-copy:	\the-user

hostb:/etc/aliases
	the-user:	the-user-copy, the-user-copy@hosta
	the-user-copy:	\the-user

This uses indirection to a -copy alias to avoid loops. The \ avoids further
aliasing done on the mailbox name.

-- 
Juergen Wagner		   			gandalf@csli.stanford.edu
						 wagner@arisia.xerox.com

merlyn@intelob.intel.com (Randal L. Schwartz @ Stonehenge) (02/05/89)

In article <Feb.3.09.50.22.1989.25618@athos.rutgers.edu>, mende@athos (Bob Mende Pie) writes:
| In article <6218@saturn.ucsc.edu> haynes@ucscc.UCSC.EDU (Jim Haynes) writes:
| 
| > I have a user with accounts on two different machines here.  He would
| > like to have it so that when he receives mail addressed to either machine
| > a copy is delivered to both machines.
| 
| yes ... but it is a hack...
| 
| on machine1 have a .forward that looks like:
| user@machine2
| 
| on machine2 have a .forward that looks like:
| \user
| user-local@machine1
| 
| on machine1 have an entry in /usr/lib/aliases that looks like
| user-local: \user
| 
| I dont there is there is an easy way to avoid a mail loop without doing it
| this way.

How about...

$HOME/.forward:
	"\user,|$HOME/.forwarder"

$HOME/.forwarder: (mode 755)
	if tee /tmp/forw.$$ | grep -s "From: $USER@othermachine"
	then :
	else mail $USER@othermachine </tmp/forw.$$
	fi
	rm /tmp/forw.$$

The "grep" would have to be adjusted to discover mail from the other
machine.  And yes, it is a bit of a kluge, because mail cc:'ed this
way from the other machine has a bad 'from' line until you have
adjusted it, but hey, at least it doesn't require adding new aliases
in /usr/lib/aliases (which some of us do not have access to).
-- 
Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095
on contract to BiiN (for now :-), Hillsboro, Oregon, USA.
ARPA: <@iwarp.intel.com:merlyn@intelob.intel.com> (fastest!)
MX-Internet: <merlyn@intelob.intel.com> UUCP: ...[!uunet]!tektronix!biin!merlyn
Standard disclaimer: I *am* my employer!
Cute quote: "Welcome to Oregon... home of the California Raisins!"