[net.mail] colons in mail addresses

avolio@decuac.UUCP (Frederick M. Avolio) (04/27/85)

I just spent an hour or two browsing the UCB Mail code.  My eyes are
tired, I am tired, and my wife is ticked off I've been ignoring her.
It dawns on me that someone might have fixed what I perceive as a
problem and so I share it with you.

If I receive a mail message from, say, systemA.domain!user which is
also addressed to grover and oscar on systemA and to user cookie on my
system (look, I have kids, okay?), the mail header I see looks
something like this:

  From systemA.domain!user Fri Apr 26 19:50:25 1985
  Date: Fri, 26 Apr 85 19:50:23 est
  Message-Id: <8504270050.AA00574@decuac.UUCP>
  Received: by decuac.UUCP (4.12/T1.2) id AA00574; Fri, 26 Apr 85 19:50:23 est
  From: systemA.domain!user
  To: grover, oscar, decuac!avolio, decuac!cookie
  Subject: Hello...

If I reply with the 'r' command, I get a To: line like this...

 To: systemA:domain!grover, systemA:domain!oscar, cookie, systemA.domain!user

Now, since really I wish it would just leave my little periods alone
all the time (as it does for the original poster -- note it doesn't
rewrite the originator -- just the other addressees who are relative
to user's site and domain) I've been trying to find where it does this
little bit of magic.  I grep-ed!  I browsed!  I read.  And I hope
someone else did the same with more luck.  I know one can fix this
(easily) in sendmail.cf, but one really shouldn't have to.  Ideas?
-- 
Fred Avolio      {decvax,seismo}!decuac!avolio      301/731-4100 x4227

chris@columbia.UUCP (Chris Maio) (04/27/85)

There are two problems here - when sending mail to recipients on multiple
hosts, the mailer should ensure that the addresses are rewritten properly
for each destination host; sendmail is good for this in general, but uucp
presents some difficulty here because sendmail assumes this only need be
done on a per-mailer basis.  To do things exactly right would probably
adding code to sendmail.cf proportional to the number of uucp neighbors you
have, or adding extra code to sendmail itself.

The other problem is that Berkeley Mail has all sorts of garbage in it
that is specific to Berkeley, including heuristics for rewriting addresses
and a hardwired table of Berkeley host names.  It also does the wrong thing
when the "r" command sees an address with no hostname delimiters (e.g. "!"
or "@") which I assume was meant to deal in a very poor way with dumb mailers.
Unfortunately, you can't get around all of these problems with sendmail; you
have to fix Mail (I thought the mail interface was one of the things DEC was
going to improve in 4.2bsd for Ultrix?).

- Chris

hedrick@topaz.ARPA (Chuck Hedrick) (04/28/85)

I believe you have fallen into a hack intended to support some obscure
syntax used only at UCB.  We discovered this when trying to fix Mail
so that replies didn't include my own name.  Let me clarify.  I
get a message
   from: foo!bar
   to: hedrick@topaz.arpa
I issue the "r" command, and get something like
   to: foo!bar, foo!hedrick@topaz.arpa
There is code that tries to eliminate your own name in this case.
However it looks only for "hedrick", not "hedrick@topaz".  Further
exploration shows that before doing this comparison a route-optimization
routine is called.  This is intended to turn foo!bar!baz!foo!user into
foo!user.  It is also supposed to turn hedrick@topaz into just plain
hedrick.  Unfortunately, it does not recognize topaz.arpa, just topaz.
It turns out that this is because our system name is set to topaz.
(If we set it to topaz.arpa, UUCP and other software do odd things.)
I did the obvious, which is to modify the routine that sets up the
internal host name to append .arpa *if there is no domain already*.
(Shortly we are going to be topaz.rutgers.edu, so we don't want .arpa
stuck on forever.)  At that point, I was shocked to see a reply go
to something like arpa:hedrick@topaz.  I looked a bit more into that
route optimization code, and concluded that I would never understand
it in finite time.  I replaced it with a simple version that understands
only normal RFC822 syntax, and everything works.  The only change
is in the module optim.c.  < is the new version, > the old.  The
majority of this code is in the routine arpafix, or something like
that, which is responsible for path optimization of addresses
involving Internet.  The idea is that anything@local-host should
be treated simply as anything.  It is then passed back through
the optimizer again.  This is so that foo!bar!baz!foo!user@local-host
will turn into foo!user.  We replace lots of complex tests with
the simple test for whether the host after the last @ or % is the
local host.  And when we recycle through the optimizer, we use
a local address of daemon, instead of host:LOCAL:daemon, or
whatever monstrosity was there before.  (This latter is what was
causing the stray colon.)  It is possible that our code does not
handle some odd case that the original code does handle, but it
seems to do the right thing in the cases that I understand.  I
believe that there are more horrors in optim.c just waiting to pounce
on you.  But I am reluctant to do anything to it until I see an
actual problem.

**** the following is a global declaration.  It can go anywhere before
**** the module arpafix
22,23d21
< char localhost[64];
< 
**** here is the main body of the change, in arpafix.
191c189,192
< 	if (!icequal(cp,localhost))
---
> 	arpamach = netlook(cp, '@');
> 	if (arpamach == 0) {
> 		if (debug)
> 			fprintf(stderr, "machine %s unknown, uses: %s\n", cp, name);
192a194,200
> 	}
> 	if (((nettype(arpamach) & nettype(LOCAL)) & ~AN) == 0) {
> 		if (debug)
> 			fprintf(stderr, "machine %s known but remote, uses: %s\n",
> 			    cp, name);
> 		return(name);
> 	}
198c206,214
< 	strcpy(fakepath, "daemon");
---
> 	fake[0] = arpamach;
> 	fake[1] = ':';
> 	fake[2] = LOCAL;
> 	fake[3] = ':';
> 	fake[4] = 0;
> 	prefer(fake);
> 	strcpy(fakepath, netname(fake[0]));
> 	stradd(fakepath, fake[1]);
> 	strcat(fakepath, "daemon");
**** the following is once-only code that sets up the internal host name.
695d710
< 
698a714
> 	static char host[64];
700,702c716
< 	gethostname(localhost, sizeof localhost);
< 	if (!any('.',localhost))
< 		strcat(localhost,".arpa");
---
> 	gethostname(host, sizeof host);
710c724
< 	np->nt_machine = localhost;
---
> 	np->nt_machine = host;

hedrick@topaz.ARPA (Chuck Hedrick) (04/28/85)

One more thing I forgot to mention:  in config.c, change metanet to not
include '.'.  I wonder if it wouldn't be a good idea to exclude ':' also,
but haven't had the courage to do so.

avolio@decuac.UUCP (Frederick M. Avolio) (05/12/85)

    The original articles were relating to UCB mail and how it is too
smart for its own good.  The problem, in summary, is that ucb/mail
tries to do address resolution based on assumptions which are probably
not valid for your site.  Chuck Hendrick <hedrick@topaz.ARPA> shared
some fixes he made.

    With domain addressing in mind, it becomes a big hassle when the
mailer you are using garbles the address.  I found this to be a very
big problem when we switched over to domain-based address mail
software.

The following shows what happens...

		Using /usr/ucb/mail, I read my mbox and look at
		message #5.  Please note the Mail heading fields
		From:, To:, and Cc:  I removed the "Received-by
		lines to save space

     % mail -f
     "/usr/users/avolio/mbox": 5 messages
     & 5
     Message  5:
     From mogwai!mogwai.UUCP!smith Fri May 10 18:01:09 1985
		~
     Date: Fri, 10 May 85 16:52:37 edt
     From: smith@mogwai.UUCP (Jane Smith)
     Message-Id: <8505102052.AA08546@mogwai.UUCP>
     To: gang
     Subject: SUBJECT1
     Cc: decuac!avolio, system, avolio@decuac.UUCP
     Status: RO

     Message follows...

		Note the local and non-local addresses and the
		"mixed notation" of paths in the Cc: line ABOVE
		Now I reply -- little r means to all on the list
		*except me*

& r 5
To: mogwai:gang@uucp smith@mogwai.UUCP
Subject: Re:  News NEWS software
Cc: avolio@decuac.UUCP mogwai:system@uucp

~q
Interrupt
& q

     Yuck, right? the "arpa-style" address for smith it got right.  The
local (on mogwai) addresses it screwed up.  Why?  Because  1) it
doesn't handle dots the way we want and 2) it doesn't say "with regard
to mogwai" the way we want.  It *does* recognize decuac!avolio as *me*
so it doesn't appear, but it does *not* recognize avolio@decuac.UUCP.

     Well I stayed up late and made changes to the code.  I made the
changes suggested by Chuck and a couple more. (I will not reproduce
Chucks changes as they were previously posted.  See references.)

    1.  I made all the changes Chuck suggested *with the exception of*
tacking on a domain to the value of gethost after it is put into
localhost.  I left localhost with the value of gethost.  This because
I want "decuac!avolio", "avolio@decuac.UUCP", "avolio@decuac.DEC", all
to be recognized as "me" and to be left off the address list. (BTW,
Remember to take '.' off the list of metanet characters on line 59 of
config.c.)

     2.  The only addition I made was a function called hostpart
(takes a string and returns everything up to a NULL or a DOT).  Then I
replaced two strcmp's as follows

> 		if (strcmp(np->nt_machine, hostpart(nbuf)) == 0)

> 	if (!icequal(hostpart(cp), localhost))

Now, after these changes, I try the same example, this time with success.

     % mail -f
     "/usr/users/avolio/mbox": 5 messages
     & r 5
     To: gang@mogwai.uucp smith@mogwai.UUCP
     Subject: Re:  SUBJECT1
     Cc: system@mogwai.uucp

     ~q
     Interrupt
     & q

		Notice that it correctly expands all of the
		addresses local to mogwai and it correctly
		leaves both "decuac!avolio" and
		"avolio@decuac.UUCP" off of the list of
		addressees.

     It works.


-- 
Fred Avolio      {decvax,seismo}!decuac!avolio      301/731-4100 x4227

pag@hao.UUCP (Peter Gross) (05/13/85)

> 
>     The original articles were relating to UCB mail and how it is too
> smart for its own good.  The problem, in summary, is that ucb/mail
> tries to do address resolution based on assumptions which are probably
> not valid for your site.  Chuck Hendrick <hedrick@topaz.ARPA> shared
> some fixes he made.
> 
>     With domain addressing in mind, it becomes a big hassle when the
> mailer you are using garbles the address.  I found this to be a very
> big problem when we switched over to domain-based address mail
> software.
> 
> The following shows what happens...
> 
> 		Using /usr/ucb/mail, I read my mbox and look at
> 		message #5.  Please note the Mail heading fields
> 		From:, To:, and Cc:  I removed the "Received-by
> 		lines to save space
> 
>      % mail -f
>      "/usr/users/avolio/mbox": 5 messages
>      & 5
>      Message  5:
>      From mogwai!mogwai.UUCP!smith Fri May 10 18:01:09 1985
> 		~
>      Date: Fri, 10 May 85 16:52:37 edt
>      From: smith@mogwai.UUCP (Jane Smith)
>      Message-Id: <8505102052.AA08546@mogwai.UUCP>
>      To: gang
>      Subject: SUBJECT1
>      Cc: decuac!avolio, system, avolio@decuac.UUCP
>      Status: RO
> 
>      Message follows...
> 
> 		Note the local and non-local addresses and the
> 		"mixed notation" of paths in the Cc: line ABOVE
> 		Now I reply -- little r means to all on the list
> 		*except me*
> 
> & r 5
> To: mogwai:gang@uucp smith@mogwai.UUCP
> Subject: Re:  News NEWS software
> Cc: avolio@decuac.UUCP mogwai:system@uucp
> 
> ~q
> Interrupt
> & q
> 
>      Yuck, right? the "arpa-style" address for smith it got right.  The
> local (on mogwai) addresses it screwed up.  Why?  Because  1) it
> doesn't handle dots the way we want and 2) it doesn't say "with regard
> to mogwai" the way we want.  It *does* recognize decuac!avolio as *me*
> so it doesn't appear, but it does *not* recognize avolio@decuac.UUCP.

When I first looked into this problem in my early sendmail days, it appeared
nearly impossible to do right.  UCB Mail, however, has a nice hack to keep
all the permutations of your own mail address out of responses.  Just put
alt avolio@decuac.UUCP
in your .mailrc file.  My alt line looks like this:
alt pag@hw pag@hv pag@haovax pag@hao-hw pag@NCAR.CSNET pag%ncar@csnet-relay.arpa

An admitted kludge, but it works, and keeps you from needing a straightjacket
from staring at sendmail configuration files.
-- 
--peter gross
UUCP:	{hplabs,seismo}!hao!pag
CSNET:	pag@ncar.csnet
ARPA:	pag%ncar@csnet-relay.arpa