[comp.mail.sendmail] From: and From_ lines

ivan@anucsd.anu.oz.au (Ivan Dean) (09/28/90)

This is a summary of the responses I received from my original posting, and
the results I have found since. The original posting asked what the
difference was between the two From lines in mail headers, how one can
chage the 'From ' header, and why some mailers reply to the 'From ' line
rather than the 'From:' line. Sorry, but it's a long summary.

Neil Rickert (rickert@cs.niu.edu) makes some interesting points :

0. The 'From ' line is more commonly called the From_ line. (Gotta keep up
with the right jargon, folks !)

1. Make sure that you are using the sendmail.main.cf, and not the
sendmail.subsidiary.cf. (I am)

2. Check carefully the definitions of $j and $w in the configfile.

3. It is always possible that part of the problem is caused by the relay
host's mailer, in which case you will have to find a different relay host or
get them to correct the problem.

4. The From_ line is more correctly called the envelope sender address. It is
used by the mail transport system. In particular this is the address to which
mail error reports are sent.

5. The From: line is intended for user and mail user agents. Reply macros
should use this address.

Jim Richardson (jimr@maths.su.oz.au) asked whether I had tried putting the
rules I want applied in to ruleset 1. I tried that, and it has no effect on
the From_ line, although it does of course affect the From: line.  (He notes
that he is using sendmail 5.61+IDA, which may be making all the difference)

Piet Berteena (piet@cwi.nl) mailed in a nice advertisement for sendmail
5.64+IDA, and also said

> The 'From ' line is called the "UUCP From line", which already
> indicates it function: it is used by dumb uucp sites that don't
> have a mailer that looks at the header line (From: To: Cc:).
> The UUCP From line requires the 'U' flag in the mailer; it is
> based on the uucp style (path!user) which is why you should
> rewrite sender and recipient addresses for that mailer to that
> style. The problem is that with the normal sendmail envelope
> and header are rewritten with the same rules. With sendmail
> plus IDA enhancements you can rewrite envelope and header
> separately; then for the uucp mailer you would rewrite the
> envelope to !-style and the header to @-style.

Craig Everhart ((Craig_Everhart@transarc.com) said that the From_ line is
recorded only at final delivery time. Automatic messages about delivery
errors go to the envelope-from (or From_line) address.

Nick Sayer (mrapple@quack.sac.ca.us) suggests I use Mail, ELM or mush. I
guess these include mail agents of the same type as sendmail ? Otherwise,
it's hard to see how they would have any effect on the problem.

So, my summary of all this information, after having done some experimenting
of my own, is as follows - I'd like anybody who disagrees with me to correct
me here please.

Firstly, the From_ line is indeed generated at final delivery time. It seems
to be the case that the _receiving_ machine makes it part of the mail
message, and takes it's value from the SMTP exchange, where my machine says

MAIL From: <ivan@woop-woop.anu.oz.au>

Essentially, if I can make my machine say something different at that point,
my From_ line will change accordingly. Try it - just use mconnect(1), or if
that's not available, use 'telnet host 25'.

My machine seems to always say that the mail is from user@$w.  IF YOU CHANGE
THE DEFINITION OF $w, THE From_ LINE WILL BE CHANGED. 

Just use

Dwnew-machine-name

to alter the definition of $w.

Caution : You may generate unwanted side-effects. For instance, I altered my
workstation to pretend to be anucsd.anu.oz.au, rather than castor.anu.oz.au.
That way my From_ line always has the name of our main machine in it, rather
than that of my personal workstation. This allows the mail server to do the
work of receiving replies, rather than my poor little machine. Unfortunately,
this meant that all my incoming mail started bouncing, because I had a
.forward file to send it on to my workstation. When the mail server (anucsd)
connected to my workstation, it cheerily announced itself as anucsd, which
wasn't expected. Unfortunately, I'm the postmaster here, so the bounces
bounced as well, and so on. Not a good experiment.

In my case, I wanted to make the mail server announce itself as something
other than it's usual host name (in fact by one of it's MXes) so I should be
able to safely achieve this. If I can furthermore guarantee that the server
will never try to forward mail on to the clients, I can make the clients
announce themselves the same way, and thereby allow them to generate the
From_ line that I want to see even if they connect directly to the recipient
host to deliver the mail.

Mostly, it's easier to do this by making sure that the mail goes through the
mail server with the mailboxes NFS mounted and the remote option (OR) on in
the sendmail.cf. But for the server, changing $w is the way to go.

Why is it worth the bother ? Well, obviously since error messages need to go
to the From_ line, it has to be valid.  Not all Internet style addresses can
be replied to from some places in Australia, but anybody can get mail to my
mail server (anucsd), even if they can't get it to my machine castor. So
ivan@anucsd.anu.oz.au is a much better address to be sending out on both
From: and From_ lines. Especially since, to answer the second question in my
posting, although everybody seems to agree that only brain-damaged mailers
reply to the From_ line, I've noticed that quite a few people are using
brain-damaged mailers (dare I say it - ELM seems to have exactly this
problem). 

My thanks to all who replied, and I hope this helps to clear up some
mysteries. It sounds like you need to move to sendmail 5.64+IDA if you really
want to be in control of all the aspects of your mail, but hacks are possible
with the standard Sun system.

Ivan Dean				ivan@anucsd.anu.oz.au
Programming Section
Computer Science Department, Australian National University