Fri Oct 17 13:29:01 MET DST 1997

Content:
		0- concepts and definitions
		1- sendmail: sources, directories etc.
		2- server and clients for "ifh"
		3- use of compound aliases on a client machine
		4- Done in order to avoid unwanted use of sirius as relay
		5- some tests
		6- changing mail addresses (user_name --> mail_name)
=========================================================================
0- concepts and definitions
---------------------------

mail gateway:	handle connections between networks

mail server:	is a system maintaining users mailboxes (in dir /var/mail)
		For us: sirius

mail client:	all client workstations which mount /var/mail from sirius
		==> all have the "OR" option in /etc/mail/sendmail.cf
		This is called a "remote mode"

How mailing works:

    user_one 
      |
   mailtool
    mailx ==> sendmail  ------> routed  ------> sendmail ==>  mailx
                                                             mailtool
                                                               |
                                                             user_two

Client in "remote mode" send all mail to the server.
The server expand aliases. 
If mail is local: it delivers it using /usr/lib/mail.local
If not send it to the domain given in the address.

Example:

{sirius:[mail]:159}# mailx -v -s test charbon@eecs.berkeley.edu
  .. text ..
.
EOT
charbon@eecs.berkeley.edu... Connecting to eecs.berkeley.edu. via esmtp...
220-mica.EECS.Berkeley.EDU Sendmail 8.6.10/8.6.6.Beta11 ready at Tue, 21 Oct 1997 09:23:12 -0700
220 ESMTP spoken here
>>> EHLO ifh.ee.ethz.ch
250-mica.EECS.Berkeley.EDU Hello sirius-ifh.ethz.ch [129.132.41.60], pleased to meet you
250-EXPN
250-SIZE
250 HELP
>>> MAIL From: SIZE=158
250 ... Sender ok
>>> RCPT To:
250 ... Recipient ok
>>> DATA
354 Enter mail, end with "." on a line by itself
>>> .
250 JAA20906 Message accepted for delivery
charbon@eecs.berkeley.edu... Sent (JAA20906 Message accepted for delivery)
Closing connection to eecs.berkeley.edu.
>>> QUIT
221 mica.EECS.Berkeley.EDU closing connection


Some definitions used when speaking about mail:

mail user agent:  interface between user and "mail transport agent"
		  Examples:  mailx , mailtool , dtmail , pine , elm

mail transport agent: routing of messages and resolution of addresses
		      Example:  /usr/lib/sendmail

		- accept messages from "mail user agent"
		- resolve destination addresses
		- select a program "delivery agent" to deliver mail
		- receive incoming mail from others "delivery agents"

mail delivery agent: implement a "mail delivery protocol"
		- SMTP mail delivery agent is the most common for TCP/IP nets
		- SMTP uses port 25 (see /etc/inet/services)
		- UUCP uses uux
		- local mail is delivered using mail.local

mailers:	is a sendmail specif term. It is used to identify a
		specific instance of a customized "mail delivery agent":
		- ether mailer uses SMTP protocoll to transport a message
		- smartuucp mailer uses uux
		- uucp mailer uses "!"-addresses in header

domain names:	a directory structure  mailbox@subdomain.subdomain.top_level

	= our domain is defined in the /etc/mail/sendmail.cf file
...
# my official domain name
Djifh.ee.ethz.ch
...


route-indipendent addressing: INTERNET
	OLD:  user@host.subdomain.domain
	NEW:  user@subdomain.subdomain.domain

route-based addressing:  path!host!user  ( used by UUCP )

mailbox:	a file on a server where mail messages will be appended
		At our site:  /var/mail/user_name

=========================================================================
1- sendmail: sources, directories etc.
--------------------------------------

/usr/lib/sendmail  is the program for the mail distribution.

It is started at boot time bei /etc/rc2.d/S88sendmail

with the command  /usr/lib/sendmail -bd -q1h

	"-bd" means sendmail runs as a daemon
	"-q1h" means to process saved messages in the queue each hour
	     P.S. a message arriving from a client to be sent is processed
	          immediately

To stop and restart sendmail use:

/etc/init.d/sendmail stop
/etc/init.d/sendmail start

sendmail read a configuration file in /etc/mail :
===> /etc/mail/sendmail.cf
    ------------------------------------------------------------------------
    DO NOT directly edit this file!! To modify the configuration file go
    to  /usr/local/sendmail then change into the directory with the
    desired version of sendmail (i.e. sendmail-8.8.5 ) and in cf create
    (if not already there) a directory "ifh". Copy there, if necessary, the
    ifh.mc file from a former version and edit it. Then run "m4" and copy the
    "ifh.cf" file obtained to /etc/mail/sendmail.cf. 
    
    Example:  
    see Chapter 4 "4- Done in order to avoid unwanted use of sirius as relay
    
    in short:  (*)
    
    cd /export/local/sendmail/sendmail-8.8.5/cf/ifh
    vi ifh.mc
    m4 ifh.mc >ifh.cf
    mv /etc/mail/sendmail.cf /etc/mail/sendmail.cf.old
    mv ifh.cf /etc/mail/sendmail.cf
    /etc/init.d/sendmail stop
    /etc/init.d/sendmail start
    
    (*) Well, I will recommend to first make a test of the new conf-file:
    
    /etc/init.d/sendmail stop
    /usr/lib/sendmail -v -C ifh.cf   <== sendmail starts with conf file ifh.cf
    ==> watch log file /var/logs/syslog to check if everything is OK.
    ------------------------------------------------------------------------

In file /etc/mail/sendmail.cw there is a list of hosts from which sirius
accept to be used as a mail server. This file will be updated everytime
we update the NIS database ( using /etc/mail/MAKE-sendmail.cw  see 
/var/yp/Makefile ). 

=========================================================================

2- server and clients for "ifh"
-------------------------------

  Concept:
  ========

   - daemon /usr/lib/sendmail runs only on the server.
   - Directory /var/mail is on the server and NFS mounted by each client
   - aliases are defined on the server

   - on clients: no daemon for sendmail :

    SunOS4 Clients:
      - /etc/sendmail.cf from betelgeuze has to be copied to /etc
      - in /etc/rc.local comment out
	    /usr/lib/sendmail -bd -q1h; echo -n ' sendmail'
	
      - in root's crontab:
	    # do a queue run every hour
	    13 * * * * /usr/lib/sendmail -q  >/dev/null 2>&1
	  ( ^^  different for each machine )
      - kill sendmail daemon 
    
    
    Solaris 2 clients:
      - /etc/mail/sendmail.cf for instance from vega in /etc/mail
      - mv /etc/rc2.d/S88sendmail /etc/rc2.d/inactive.S88sendmail
      - in root's crontab:
	    # do a queue run every hour
	    13 * * * * /usr/lib/sendmail -q  >/dev/null 2>&1
	  ( ^^  different for each machine )
      - kill sendmail daemon 

      - cd /etc/mail
        /usr/bin/newaliases


    DNS:
    ====
    Host resolution should succed using DNS:

    On each machine, in file /etc/resolv.conf:

		domain ethz.ch
		nameserver 129.132.98.12
		nameserver 129.132.1.11
		nameserver 129.132.250.2
		nameserver 129.132.98.160

    and in file /etc/nsswitch.conf the line for "hosts" should be like this:

		hosts:      nis dns [NOTFOUND=return] files


=========================================================================

3- use of compound aliases on a client machine
----------------------------------------------

Definition: "compound aliases" are those whose list of recipient is 
	    stored in a file, for example sirius:/etc/mail/aliases.emf

Those files are NOT present on client machines! Thus on client deneb:

deneb:ballisti:[etc]:14 % /usr/lib/sendmail -v -bv emf
emf... aliased to :include:/etc/mail/aliases.emf
:include:/etc/mail/aliases.emf... including file /etc/mail/aliases.emf
:include:/etc/mail/aliases.emf... Cannot open /etc/mail/aliases.emf: No such file or directory

For this reason all those adresses with compund aliases should be given
in FULL, i.e. with @ifh.ee.ethz.ch
^^^^^^^            ^^^^^^^^^^^^^^^
Example on client deneb:

 deneb:ballisti:[ballisti]:20 % /usr/lib/sendmail -v -bv emf@ifh.ee.ethz.ch
emf@ifh.ee.ethz.ch... deliverable: mailer ether, host sirius, user emf@ifh.ee.ethz.ch


Of course it easy to distribute those files to every client. I did not
do it because it is against my idea of using ONLY NIS to distribute
information to client. Also it is not possible to mount /etc/mail because
the sendmail.cf would then be the one of the server and not suited for 
a client machine.

=========================================================================

4- Done in order to avoid unwanted use of sirius as relay


20.10.97

New directory is : /export/local/sendmail/sendmail-8.8.5/cf

{sirius:[cf]:65}# ftp ife
 (user karrer, password ...)
..
ftp> get  uni-kiel.check.26-jan.97.tar.gz 
..

creating directory "hack"

{sirius:[cf]:67}# gunzip  execute: m4 ifh.mc >ifh.cf

{sirius:[ifh]:81}# diff ifh.cf /etc/mail/sendmail.cf
51c51
< ##### built by root@sirius on Mon Oct 20 10:49:18 MET DST 1997
---
> ##### built by root@sirius on Mon Oct 20 09:43:14 MET DST 1997
82d81
< #####  @(#)spammers.m4	1.0 (Claus Assmann) 1996-11-23  #####
84,102d82
< 
< #####  @(#)spamdoms.m4	1.0 (Claus Assmann) 1996-11-23  #####
< 
< 
< #####  @(#)check_mail.m4	1.0 (Claus Assmann) 1996-11-23  #####
< 
< 
< 
< 
< 
< #####  @(#)use_ip.m4	1.0 (Claus Assmann) 1996-11-23  #####
< 
< 
< #####  @(#)check_rcpt.m4	1.0 (Claus Assmann) 1996-11-23  #####
< 
< 
< 
< 
< 
184,185c164
< # file containing full e-mail addresses of well-known spammers
< F{Spammer} /etc/mail/Spammer
---
> FR-o /etc/mail/sendmail.cw
187,188d165
< # file containing domains of well-known spammers
< F{SpamDomains} /etc/mail/SpamDomains
190,192d166
< # file containing IP numbers of machines which can use our relay
< F{LocalIP} /etc/mail/LocalIP
< 
568,569d541
< 
< 
814,827d785
< Scheck_mail
< # no mails from spammers (user@dom.ain)
< R<$={Spammer}>	$#error $@ 5.7.1 $: "571 We don't accept junk mail." 	go away
< R$={Spammer}	$#error $@ 5.7.1 $: "571 We don't accept junk mail." 	go away
< R$*		$: $>3 $1						canonify
< R$-		$@ ok							local host
< # no host without a . in the FQHN ?
< R$*<@$->$*	$#error $@ 5.1.8 $: "518 invalid host name"		no real name
< # no spam domains
< R$*<@$*$={SpamDomains}.>$*	$#error $@ 5.7.1 $: "571 This domain is banned." 	go away
< R$*<@$*$={SpamDomains}>$*	$#error $@ 5.7.1 $: "571 This domain is banned." 	go away
< 
< 
< 
829,841c787,789
< R$+			$: $>3 $1				canonify
< R$+			$: $(dequote $1 $)
< R$-			$@ ok					to here
< R$* % $*		$: relay attempt
< R$* @ $* < @ $*.>	$: relay attempt
< R$+ < @ $=w.>		$@ ok					to here
< #R$+ < @ $*$={RelayTo}.>	$@ ok		allow relay to there
< R$+			$: $(dequote "" $&{client_addr} $)
< R0			$@ ok		client_addr is 0 for sendmail -bs
< R$={LocalIP}.$*		$@ ok					from here
< #R$+			$: $(dequote "" $&{client_name} $)
< #R$-			$@ ok					from here
< #R$*$={LocalNames}		$@ ok					from here
---
> # anything terminating locally is ok
> R< $+ @ $=w >		$@ OK
> R< $+ @ $=R >		$@ OK
843c791,795
< R$*			$#error $@ 5.7.1 $: "571 we do not support relaying"
---
> # anything originating locally is ok
> R$*			$: $(dequote "" $&{client_name} $)
> R$=w			$@ OK
> R$=R			$@ OK
> R$@			$@ OK
844a797,798
> # anything else is bogus
> R$*			$#error $: "550 Relaying Denied"
{sirius:[ifh]:82}# mv /etc/mail/sendmail.cf /etc/mail/sendmail.cf.old
{sirius:[ifh]:83}# mv ifh.cf /etc/mail/sendmail.cf 


/etc/init.d/sendmail stop
/etc/init.d/sendmail start



{sirius:[ifh]:120}# cat ifh.mc
# sendmail config file for ifh.ee.ethz.ch
# - mail hub
# - masquerading
# - use cw file to find out which domains are local
# - send uucp to bernina
# - send bitnet to dxmint.cern.ch
# - use procmail for local delivery
# - use /etc/mail/userdb.db for outgoing aliases
# 
# - Andi Karrer, 22 Jan 1997
divert(0)
include(`../m4/cf.m4')
OSTYPE(solaris2)dnl

define(`UUCP_RELAY', `bernina.ethz.ch')dnl
define(`BITNET_RELAY', `dxmint.cern.ch')dnl

define(confDOMAIN_NAME, `ifh.ee.ethz.ch')
MASQUERADE_AS(ifh.ee.ethz.ch)
FEATURE(allmasquerade)
FEATURE(use_cw_file)dnl
FEATURE(always_add_domain)dnl
FEATURE(local_procmail,/usr/bin/procmail)dnl
FEATURE(redirect)dnl
define(confUSERDB_SPEC, /etc/mail/userdb.db)dnl
define(confAUTO_REBUILD, True)dnl
define(confME_TOO, True)dnl

MAILER(local)dnl
MAILER(smtp)dnl

HACK(spammers)
HACK(spamdoms)
HACK(check_mail)

HACK(use_ip)
HACK(check_rcpt)


=========================================================================
5- some tests

To see if a mail can be delivered:
---------------------------------

/usr/lib/sendmail -v -bv recipient_address


{sirius:[etc]:170}# /usr/lib/sendmail -v -bv charbon@eecs.berkeley.edu
charbon@eecs.berkeley.edu... deliverable: mailer esmtp, host eecs.berkeley.edu., user charbon@eecs.berkeley.edu

To check if the rules in sendmail.cf work properly:
---------------------------------------------------
/usr/lib/sendmail -bt    ==> you can now test the rules:

{sirius:[etc]:171}# /usr/lib/sendmail -bt
ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter  
> 3 charbon@eecs.berkeley.edu rewrite: ruleset 3 input: charbon @ eecs . berkeley . edu rewrite: ruleset 96 input: charbon < @ eecs . berkeley . edu > rewrite: ruleset 96 returns: charbon < @ eecs . berkeley . edu . > rewrite: ruleset 3 returns: charbon < @ eecs . berkeley . edu . > > To check a new configuration file: ---------------------------------- /usr/lib/sendmail -v -C test_config_file Just to see what happen: ------------------------ /usr/lib/sendmail -v address mail_name) ==================================================== {sirius:[mail]:116}# pwd /etc/mail {sirius:[mail]:117}# tet userdb Example: bruggman:mailname bruggmann@ifh.ee.ethz.ch bruggmann:maildrop bruggman {sirius:[mail]:118}# ./makemap btree userdb.db < userdb {sirius:[mail]:119}# cd /etc/init.d New directory is : /etc/init.d {sirius:[init.d]:120}# ./sendmail stop {sirius:[init.d]:121}# ./sendmail start ==============================================================================

Please mail suggestions (very welcome) or requests to ballisti@ifh.ee.ethz.ch
Ballisti Ray