SUMMARY: Lastname.Firstname in sendmail on Solaris

From: Wesson.Dennis@epamail.epa.gov
Date: Fri Jan 26 1996 - 11:56:10 CST


   Thanks to all who responded so quickly to my request for help in setting
up sendmail to use Lastname.Firstname in the From: line. There were several
"me too" responses so here is a summary.

  My original question was;
  
> We have several SPARCstations running Solaris 2.3 and 2.4. I have installed
> Sendmail 8.7.1 on each of these and now I need to find out how to configure
> sendmail to make the 'From:' line be of the form
> "Lastname.Firstname@host.domain". Any help would be appreciated.
>

Thanks to Stuart.Little@ssu.stcssl.co.uk
          Anderson McCammont <and@morgan.com>
          Alex Pakter <Alex.Pakter@omnitel.it>
          Ric Anderson <ric@rtd.com>
          Robert Moyer <Rob.Moyer@MHDI.COM>
          Daniel.Blander@ACSacs.com
          stern@sunrise.East.Sun.COM
          Stuart Abramson <stuart.abramson@ped.gmeds.com>
          
and anyone I may have missed.

   I was suprised at how few responses merely said "read the FAQ". I ended ups
using the Berkely db routines. Anyway, here is a summary of the other responses.
          
          
          
>From Stuart.Little@ssu.stcssl.co.uk:

If you are running NIS and can setup a NIS map containing
entries like:-
fred Basset.Fred

Add something like

Kreal nis -o realnames
to sendmail.cf. 'realnames' is the name of the map.

Add
R$+@$+ $:$(real $1 $)@ $2
R$+ $:$(real $1 $)

to Rule S1 in sendmail.cf.
This works for me, but you will probably get a better answer.
If you aren't running NIS there are other ways of doing it but
I've not tried them.

>From Anderson McCammont <and@morgan.com>:

use the aliases file/map to reengineer the name before it leaves the mail hub

>From Alex Pakter <Alex.Pakter@omnitel.it>:

-1) Read *carefully* the sendmail docs, and understand how to use keyed
database lookups in the sendmail.cf file.

2)

Put a rule similar to the following in ruleset 1 (S1):

#
# Rewrite From: lines into format First.Last, if possible.
# First, try to look up the user name in the DB. If we can't
# get values for First.Last, from the DB, then try to
# use the values from $x (assumes $x is in form "Firstname Lastname".
#
# For any hosts in our domain, rewrite from host to $m (our domain name).
#
 
S52
R$-<@$=M.$m.>$* $: $(namemap $1@$2 $:$1$)<$1@$2.$m.>$3 DB name lookup
R$*<$-@$=M.$m.>$* $: $1<$(namemap $2@$3 $:*}NO_GOOD{*$)@$3.$m.>$4
                                DB name lookup - check for nonexistent user
R$+<*}NO_GOOD{*@$*>$* $@ $1<@$2>$3 We didn't find it -- do nothing
R$*<$*@$*>$* $: $1<@$3>$4 clean up any mistaken inserts
R$+<@$+.$m.>$* $@ $1<@$m.>$3 try to do user<@domain>

The "namemap" above is a DBM database that maps users account names
to "Name.Surname" . The class =M references above is a list of all the
machines for which we want to remap the names.

Basically the rule says:
-if the mail comes from a machine in our domain ($m), and that machine
belongs to the class for which we want to remap the names, THEN:
-look up the account (form: user@host in the DB "namemap", and replace
it with what we get out of the DB.
-If the lookup fails, then just strip the hostname from the mail. This
way none of our internal hostnames get out.

>From Ric Anderson <ric@rtd.com>:

You need the user database facility in sendmail to do this.
Its described in the sendmail docs (see the .ms man pages) and
in the book "Sendmail" by Bryan Costales; ISBN 1-56592-056-2
published by O'Reilly and Associates.

You'll also need the userdb software from ftp.cs.berkeley.edu
but the whole mechanism does work.

>From Robert Moyer <Rob.Moyer@MHDI.COM>:

1. Add the following to your /etc/aliases file

        Rune.Paulsen: rune

2. Make the following changes to your NIS makefile:

        

aliases.time: $(ALIASES)
        @cp $(ALIASES) $(YPDBDIR)/$(DOM)/mail.aliases;
        @/usr/lib/sendmail -bi -oA$(YPDBDIR)/$(DOM)/mail.aliases;
        $(MKALIAS) $(YPDBDIR)/$(DOM)/mail.aliases $(YPDBDIR)/$(DOM)/mail.byaddr;
New line-> #
New line-> # Build my own mail.byaddr wiping out existing mail.byaddr
New line-> #
New line-> @(egrep '[A-Z][a-z]*\.[A-Z][a-z]*:' $(DIR)/aliases $(CHKPIPE))\
New line-> |( sed -e 's/:/ /' -e 's/@themailhost//' -e 's/,/ /'
$(CHKPIPE))\
New line-> |( awk '{print $$2,$$1}' $(CHKPIPE))\
New line-> | $(MAKEDBM) - $(YPDBDIR)/$(DOM)/mail.byaddr;
New line-> #

        rm $(YPDBDIR)/$(DOM)/mail.aliases;
        @touch aliases.time;
        @echo "updated aliases";
        @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOM) mail.aliases; fi
        @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOM) mail.byaddr; fi
        @if [ ! $(NOPUSH) ]; then echo "pushed aliases"; fi

   Make aliases and check it with command ypcat mail.byaddr

3. Change your /etc/sendmail.cf file. The modification is for rule
   22 and should work for both ddn and smartuucp mailer.

DZmail.byaddr
 

S22
# Next line is the new line that change From address
R$- $:$>3${Z$1$} firstname.lastname
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

4. restart sendmail and test !!!

---
Dennis Wesson       
DynTel Corporation
wesson.dennis@epamail.epa.gov            



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:10:52 CDT