[comp.mail.misc] rewriting to's & cc's

stewarte@sco.COM (Stewart Evans) (07/18/89)

As I understand it, it is proper for transfer agents
to rewrite from: fields so that they point back to 
the sender.  Is it "proper" to do the same with to:
and cc: fields?  

For example:  tom at host1 sends a message to host2!dick,
and cc's harry (who is also at host1).  How should that
cc: line look when host2!dick receives it?  If that line
is not rewritten, then it must be the responsility of
dick's UA to determine that harry's host must be the same
as tom's, which seems pretty messy (what if there's also
a user named harry at host2, for example?).

-- Stewart
-- 
"Don't ever use helium for decorative purposes."
				-- Hiram Clawson
/*  uunet!sco!stewarte  -or-  stewarte@sco.COM  -or-  Stewart Evans  */

moore@CYGNUSX1.CS.UTK.EDU (Keith Moore) (07/18/89)

In article <4291@viscous.sco.COM> stewarte@sco.COM (Stewart Evans) writes:
>As I understand it, it is proper for transfer agents
>to rewrite from: fields so that they point back to 
>the sender.  Is it "proper" to do the same with to:
>and cc: fields?  

It is proper for transfer agents to maintain "From " fields in message
"envelopes".  For UUCP, this means that every host that passes the
message should prepend a "From " line to the message before passing
it on to the next host or to the recipient.  It's especially handy
if the final delivery agent (the transfer agent that delivers the
mail to the recipient) collapses the "From " lines into a return
path to which replies can be sent.

On the other hand, it is NOT proper for MTAs to rewrite From:, To:, or
Cc: fields in message headers as long as the message remains within
the UUCP mail system.  One reason for this is backward compatibility:
ethnically pure UUCP systems do not have headers, just an envelope
and a body.  Any "message headers" that were present in the original
message are simply part of the message body as far as vanilla UUCP
is concerned, and they are delivered intact to the recipient's machine.
The addresses in the message headers of a UUCP message, if present,
should then be relative to the *sender*.  The address can be made
relative to the recipient by prepending the envelope return path to
the addresses in the message header, though this path may well be
sub-optimal.

The same rule is true for Internet mail systems: they should not
rewrite message headers.  In the Internet world, there is a different
reason: all header addresses should be of the form local-part@domain,
and are therefore absolute addresses.

Unfortunately, many UUCP mail transfer systems do update message headers.
Usually these are the ones based on sendmail.  The result of this is
that when someone receives a UUCP message, some of the hosts that 
carried the message have prepended their system names and some have
not.  Often this leaves the header addresses completely invalid.
Fortunately, the "From " envelope address is already correct, so
the final delivery agent can obtain the "From:" header from the 
envelope.  However, the To: and Cc: addresses may need to be cleaned
up if local UAs expect to be able to send replies to recipients of
the original message as well as to the sender.

The following idea might be useful to clean up header addresses
before delivery to the recipient: 

Say the return path (the "From " envelope address)
is a!b!c!d!tom .  This means that the message passed through hosts
d, c, b, and a, in that order.  One or more of these hosts may have
prepended its own system name to the To: and Cc: message headers.
Let's say that one of these looks like a!c!d!f!joe .  We can delete
the "a!c!d" portion of the latter address, since they appear in the
same order as the hosts in the envelope "From " address.  Now we have
the address "f!joe", which we cannot simply further.  To this we
prepend the "From " path to yield "a!b!c!d!f!joe" .  Now we have a
path to joe which is probably valid, and certainly closer to the
truth that the To: address before cleanup.

(Note: I never said this was easy to do with sendmail.)

This algorithm assumes, among other things, that no message header 
will contain an address like ...!a!b!... if the "From " address 
contains ...!b!a!..., that is, no two copies of the same message
pass through the same network link in opposite directions.  I hope
this is a reasonable assumption.  Also, all bets are off if the 
message passes through another network, or through an MTA that
tries to rewrite its headers in a more drastic fashion, before 
it arrives at its destination.  

>For example:  tom at host1 sends a message to host2!dick,
>and cc's harry (who is also at host1).  How should that
>cc: line look when host2!dick receives it?  

Exactly as tom typed it.

>If that line
>is not rewritten, then it must be the responsility of
>dick's UA to determine that harry's host must be the same
>as tom's, which seems pretty messy (what if there's also
>a user named harry at host2, for example?).

It's easier if dick's local delivery agent rewrites the headers for
him before giving it to his UA.  When the message is delivered locally
it is leaving the UUCP system, and does not have to stay strictly within
the conventions appropriate to that network.  It is sometimes appropriate 
to rewrite headers during final message delivery, if the rewriting is
necessary to adapt the header addresses to the conventions of the local
UAs.

--
Keith Moore			Internet: moore@utkcs2.cs.utk.edu
University of Tenn. CS Dept.	BITNET: moore@utkvx
107 Ayres Hall, UT Campus	UT Decnet: utkcs2::moore
Knoxville Tennessee 37996-1301	Telephone: +1 615 974 0822

huitema@mirsa.inria.fr (Christian Huitema) (07/18/89)

From article <4291@viscous.sco.COM>, by stewarte@sco.COM (Stewart Evans):
> As I understand it, it is proper for transfer agents
> to rewrite from: fields so that they point back to 
> the sender.  Is it "proper" to do the same with to:
> and cc: fields?  

It is improper to rewrite any field, except perhaps the "envelope". Just
pass the message as it is: if the originating MUA used proper domain
addresses, everything will work nicely; any other combination is bound to
fail anyhow.

The recipient fields in the envelope should only be rewritten if they
contain source routes: one should indeed remove references to the local site.

Christian Huitema

david@ms.uky.edu (David Herron -- One of the vertebrae) (07/21/89)

In article <203@mirsa.inria.fr> huitema@mirsa.inria.fr (Christian Huitema) writes:
>From article <4291@viscous.sco.COM>, by stewarte@sco.COM (Stewart Evans):
>> As I understand it, it is proper for transfer agents
>> to rewrite from: fields so that they point back to 
>> the sender.  Is it "proper" to do the same with to:
>> and cc: fields?  
>
>It is improper to rewrite any field, except perhaps the "envelope". Just
>pass the message as it is: if the originating MUA used proper domain


Wrong, wrong, wrong, wrong, 1,000,000 times wrong

For instance, mail going from UUCP-land to RFC-land must have
the ! type addresses translated to @ type addresses before they'll
be understood by RFC-land mailers.

In general gateway machines MUST rewrite headers

I will submit that my favorite mailer, MMDF, perhaps does this too
much.  But recent changes allow this to be tailored down quite a bit.
-- 
<- David Herron; an MMDF guy                              <david@ms.uky.edu>
<- ska: David le casse\*'      {rutgers,uunet}!ukma!david, david@UKMA.BITNET
<-
<- WARNING: Hunting season is now open in West Virginia!

lindberg@cs.chalmers.se (Gunnar Lindberg) (07/21/89)

>><4291@viscous.sco.COM>, stewarte@sco.COM (Stewart Evans):
>>As I understand it, it is proper for transfer agents
>>to rewrite...
>>For example:  tom at host1 sends a message to host2!dick,
>>and cc's harry (who is also at host1).  How should that
>>cc: line look when host2!dick receives it?  

><1005@utkcs2.cs.utk.edu>, moore@CYGNUSX1.CS.UTK.EDU (Keith Moore):
>Exactly as tom typed it.

Now, I'm not sure of what you mean by "rewriting", but at least the
local mail delivery agent *must* add itself to "To:" and "Cc:" fields
that do not have any host/domain on it. Otherwise it will be impossible
for somebody else to reply.

If host1!tom sends

    To: host2!dick
    Cc: harry

then host2!dick *must* receive this with

    From: host1!tom
    To: host2!dick
    Cc: host1!harry

which is *not* as Tom typed it(!), but makes it possible for Dick to
reply both to Tom and Harry instead of trying to reach "Local Harry".

	Gunnar Lindberg

pim@ctisbv.UUCP (Pim Zandbergen) (07/27/89)

lindberg@cs.chalmers.se (Gunnar Lindberg) writes:

>Now, I'm not sure of what you mean by "rewriting", but at least the
>local mail delivery agent *must* add itself to "To:" and "Cc:" fields
>that do not have any host/domain on it. Otherwise it will be impossible
>for somebody else to reply.

This discussion comes at exactly the right time for me:
I am in the middle of getting our site registered in the .nl domain.
The only obstacle now is the *required* use of an MTA that will
assure that "To:", "From:" anc "Cc:" fields contain fully qualified
domain addresses only.

We currently use smail 2.5, which will take care of "To:" and "From:"
but not "Cc:". 

Has anybody out there hacked smail to rewrite the "Cc:" field?
If so, please mail me the diffs!
-- 
--------------------+----------------------+-----------------------------------
Pim Zandbergen      | phone: +31 70 542302 | CTI Software BV
pim@ctisbv.UUCP     | fax  : +31 70 512837 | Laan Copes van Cattenburch 70
...!uunet!mcvax!hp4nl!ctisbv!pim           | 2585 GD The Hague, The Netherlands