SUMMARY: Setting out-going mail to "Firstname.Lastname@domain" format

Date: Thu Jan 27 1994 - 15:39:30 CST

I asked in despair and desperation....
> Dear Sunmanagers,
> I give do you persuade sendmail to convert the outgoing mail address
> to 'Firstname.Lastname@domain' format ??? I've been R'ing TFMs but can find
> no reference to it, and my own attempts at it have all been doomed to failure.

As you can see, I got it working ! Actually, I stumbled on the solution by
trial and error soon after posting the request. The problem was that the
aliases I had in /etc/aliaes on the NIS master weren't going into the
mail.byaddr NIS map. The reason for this is that (drum roll....) only aliases
of the form

aliasname: realname@host

(with the "@host" being the critical part) go into the mail.byaddr map. Once
over this hurdle, it was relatively simple to persuade the on the
server to do the conversion.

The rest of this summary contains the specifics of how its done at
our site and excerpts from some respondants about how they managed to crack it.
It may be useful to someone - if you're not interested, you can skip the rest
of this (rather long) message (or if you responded to the original query, skip
the the bottom to see your name in lights !!!!)

Here it goes...:

The /etc/aliases file at our site contains an entry for every staff member
which looks like this:


These go into the mail.byaddr map, with "" being the key
and "Eamonn.McGonigle" being the result of a lookup with that key (the opposite
of a normal alias lookup).

The on our mail gateway is trained to convert the sender address to
'' regardless of which machine the message originated from,
and to accept messages destined for 'user', 'user@singlehost',
'', '' etc etc and to treat them as
local. The following extract from the .cf file does most of the work:-

# DDN Mailer specification
# Send mail on the Defense Data Network
# (such as Arpanet or Milnet)

#Mddn, P=[TCP], F=msDFMuCX, S=22, R=22, A=TCP $h, E=\r\n
# We want the sender to be rewritten as firstname.lastname@domain
Mddn, P=[TCP], F=msDFMuCX, S=32, R=22, A=TCP $h, E=\r\n

# map containing the inverse of mail.aliases

#R$*<@LOCAL>$* $:$1
#R$-<@$-> $:$>3${Z$1@$2$} invert aliases
#R$*<@$+.$*>$* $@$1<@$2.$3>$4 already ok
#R$+<@$+>$* $@$1<@$2.$m>$3 tack on our domain
#R$+ $@$1<@$m> tack on our domain
# Rewrite 'user', 'user@host' or 'user@host.ourdomain' as 'user@ourdomain'.
# (EMcG)
R$+<@$->$* $@$1<@LOCAL>$3 user@host
R$+<@$+.LOCAL>$* $@$1<@LOCAL>$3 user@host.thisdomain
R$+<@$+>$* $@$1<@$2>$3 user@host.anydomain
R$+ $@$1<@LOCAL> user

# This ruleset looks up the 'Z' NIS map (Z defined above) to convert 'username'
# to 'firstname.lastname' (EMcG)
R$* $:$>22$1 affix LOCAL to locals
R$-<@LOCAL> $:${Z$1@$m$}<@LOCAL> convert username
R$-@$m<@LOCAL> $@$1<@LOCAL> fix names not converted

Ruleset 32 converts from username to firstname.lastname. It looks up
'' in the NIS map. The return value will be either
'Firstname.Lastname' or '' depending on whether or not
it finds a match. In either case, it tags '<@LOCAL> on the end. The last line
of ruleset 32 simply converts the '<@LOCAL> (in the case
where no match is found) to 'username<@LOCAL>'. There are probably 1000 better
ways to do this...but it works and its not tooooo ugly (I think !).

On a completely different tack, several people pointed out that IDA sendmail
or sendmail 8 can do all this (and other things) with far less trouble and
heartache. A number of other solutions were proposed using Sun's sendmail,
the bones of which I've included below.

| From Wed Jan 26 06:21:33 1994
| Hal Stern has an excellent column in every month's
| issue of SunWorld magazine on sys admin stuff.
| You should get it.
| In the November and December issue he covers some sendmail
| stuff. And quoting from his article:
| [text of article deleted - if/when I get Hal's permission to do so, I'll
| forward it to anyone who wants it.

| From Wed Jan 26 09:19:56 1994 (Dr. Tim Perkins)
| This is a problem that I've been trying to solve for a while and have
| come up with some kind of solution although I'm not completely happy
| with it. Basically, you need to get sendmail to use ruleset S1 to do the
| conversion for outgoing mail (sender only). We have one machine that
| collects all mail on our network before forwarding to more `intelligent'
| mailers run by the University. The /etc/ on our server system
| includes the following lines:
| # Translate id -> First.Last for outgoing mail only
| S1
| Rtdjp1 Tim.Perkins
| Kill and restart the "/usr/lib/sendmail -bd -q" process.
| The above lines were created manually which is fine for a small site.
| For larger installations you may be able to start from a data file
| (/etc/passwd?) and process it to produce both an include file for
| sendmail and the NIS /etc/aliases map---should be fairly easy with awk
| I guess.
| My information on sendmail comes from:
| Sun System & Network Administration
| Sendmail-care and feeding by Reg Quinton (found on sunsite?)
| something by Charles Hendrick (on this mailing list I think)

| From Wed Jan 26 15:18:35 1994 (Andy Feldt)
| Organization: Dept. Physics & Astronomy, The University of Oklahoma
| Here is the summary I kept...
| Good luck!
| Andy Feldt
| System Support Programmer
| Department of Physics and Astronomy
| The University of Oklahoma
| ----- Begin Included Message -----
| >From Fri Mar 12 01:55:32 1993
| Date: Thu, 11 Mar 93 13:55:27 CST
| From: Mike.Jenkins@NCTS.NAVY.MIL (Mike Jenkins)
| To:
| Subject: SUMMARY: how to rewrite outgoing mail?
| Cc:,
| >How do I rewrite outgoing mail to lastname.firstname@domainname?
| Most of the responses I got were "I'd like to do that also". A few
| said this is easily done with Sendmail+IDA found at
| I decided to work with the sendmail that comes with SunOS.
| The key to rewriting sender addresses is the metasymbol "${x key$}"
| which looks up "key" in NIS map $x and returns the value. This is used
| in the ddn mailer ruleset S22 to look up sender addresses of the
| form "user@host" in the mail.byaddr NIS map and rewrite it to the
| value found in mail.byaddr. The ddn mailer is my outgoing mailer
| so I worked on it.
| Most of our sender addresses look like "user" and a few like "user@client".
| I added a rule to S22 to also look up "user" in mail.byaddr. I also
| added some lines to /var/yp/Makefile to rebuild mail.byaddr from the
| Firstname.Lastname aliases in /etc/aliases.
| If you are similiarly configured like us, all it takes is a line to
| S22, 4 lines to /var/yp/Makefile, and a properly setup aliases file.
| See below for details. I hope it works for you!
| Mike Jenkins
| -----------------------------------------------------------------
| The rule added right after S22:
| S22
| R$- $:$>3${Z$1$} user
| ...
| The /var/yp/Makefile changes at aliases.time:
| ...
| rm $(YPDBDIR)/$(DOM)/mail.aliases;
| #
| # Build my own mail.byaddr wiping out existing mail.byaddr
| #
| @(egrep '^[A-Z][a-z]*\.[A-Z][a-z]*:' $(DIR)/aliases $(CHKPIPE))\
| |( sed -e 's/:/ /' -e 's/@themailhost//' -e 's/,/ /' $(CHKPIPE))\
| |( awk '{print $$2,$$1}' $(CHKPIPE))\
| | $(MAKEDBM) - $(YPDBDIR)/$(DOM)/mail.byaddr;
| #
| ...
| The aliases file:
| joe: joe@themailhost
| Joe.Smith: joe@themailhost
| sue: sue@herclient
| Sue.Allen: sue@herclient, sue@elsewhere
| The mail.byaddr built from aliases file:
| Key Value
| --- -----
| joe Joe.Smith
| sue@herclient Sue.Allen
| ----- End Included Message -----

| From: octela!jfd@uunet.UU.NET (John F. Detke)
| Well don't feel bad, it isn't obvious, at least it wasn't to me or several
| sendmail gurus I asked. The solution I came up with I ran by Eric who said
| it seemed to make sense. What I did was munged together a system using
| the Berkeley user DB (which eric is developing, and it is hard to find info
| on) and then in sendmail's cf file access that DB thusly:
| # Eng User DB
| Kfirstlastmap btree /etc/users
| and then tacked on:
| # jfd hack to rewrite to first.last
| R$+ < @ $m . > $:$(firstlastmap $1:mailname $:$1 $) < @ $m . >
| to Ruleset 31, which is used for sender masquerading. I figured if yo
| could masquerade as another machine, why not another user? It works.
| In the lastest Sunworld there's a good article that shows how to do this
| using NIS maps. I rewrite on machines I'd rather not run NIS on, for security
| reasons.

One last "editorial" comment...
It is pretty bad that nowhere in the documentation is the mail.byaddr map
discussed, that the man pages don't contain an entry for mkalias (which
generates the map) and that the whole mechanism it there but totally
undocumented by Sun. Come on, can do better than that.

Thanks to all who took the time and trouble to respond....:

From: (Dave Curado)
From: (Eric Deschamps)
From: (Tim Perkins)
From: bobr@houston.wireline.SLB.COM ( Bob Reardon )
From: (Andy Feldt)
From: Larry Belvin <>
From: (Gordon Laqua)
From: octela!jfd@uunet.UU.NET (John F. Detke)
From: Jon Wright <>
From: Larry Chin <>
From: Kevin Quinlan <>

...and anyone whose reply is in transit still.

 Eamonn McGonigle, Phone: (+353 1) 7045649
 School of Computer Applications, FAX: (+353 1) 7045442
 Dublin City University, Mail:
 Dublin 9,

This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:08:55 CDT