COMPUTER AND NETWORK
SYSTEM ADMINISTRATION
Summer 1996 - Lesson 20
Sendmail II
B. Mail systems (continued)
.
.
.
8. aliases
- order is local config first
> user agent
> .mailrc for /usr/ucb/mail
> .elm/elmrc for elm
- then /etc/aliases
> receiving transport agent
> NIS aliases, if supported
> newest version allows you to specify the order of local
vs. NIS aliases file
- then ~/.forward
> receiving transport agent
- easy to set up a mail loop
- sendmail assumes loop and bounces if more than (17) number of hops
- it's hard to notify user of this problem :)
- aliases can reference users, files, or programs
- example /etc/aliases file:
# This should be a HUMAN who handles mail problems
Postmaster:kuncick@nu.cs.fsu.edu
# Alias for mailer daemon; returned messages from our MAILER-DAEMON
# should be routed to our local Postmaster.
MAILER-DAEMON: postmaster
kuncicky:kuncick@nu.cs.fsu.edu
#
# Aliases to handle mail to programs or files, eg news or vacation
nobody: /dev/null
#
root:root@nu.cs.fsu.edu,kuncick@nu.cs.fsu.edu
webmaster:franke,kuncick
#
#
# aliases for mail groups
#
# FACULTY - permanent full-time faculty
faculty: :include:/nu1/adm/mail/faculty
#
# STAFF
staff: :include:/nu1/adm/mail/staff
secretary: :include:/nu1/adm/mail/secretary
#
# GRAD STUDENTS
grads: :include:/nu1/adm/mail/grads
#
# TEACHING ASSISTANTS
teachtas: :include:/nu1/adm/mail/teachtas
#
# ACM OFFICERS
acm: :include:/nu1/adm/mail/acm
#
# SYSTEMS GROUP
system: "/dev/null"
#
# INFO (automatic answer program)
info: "|/usr/local/bin/info-reply"
- must run "newaliases" (sendmail -bi) to build hash table
(aliases.dir, aliases.pag) if aliases file is modified
- these programs (aliases) are run as root, must be secure
- programs run by .forward are run as the local user
9. Mail filtering
- there has been a proliferation of mail lists and unwanted
solicitations via e-mail
- there are several ways to filter incoming mail
- one way is to use the elm "filter" command
- you do not have to be an elm user to use 'filter'
- create .forward file with:
"|/usr/local/bin/filter -ov /home/cs5/kuncick/filter.log"
- create a .elm/filter-rules file (see "man filter" for syntax)
- you can see filter rules by typing filter -r
Rule 1: if (from = "kuncick@grep.cs.fsu.edu") then
Save /home/cs5/kuncick/.elm/grep.log
- you can see summary of actions by typing filter -s
A Summary of Filter Activity
----------------------------
A total of 102 messages were filtered:
The default rule of putting mail into your mailbox
applied 98 times (96%)
Rule #1: (save in "/home/cs5/kuncick/.elm/grep.log")
applied 4 times (4%)
- you can see the whole log by typing filter -S
Explicit log of each action;
Mail from kuncick@grep.cs.fsu.edu about asdfasd
SAVE FAILED for file "grep.log" by rule #1
Mail from reynolds about job offer post
PUT in mailbox: the default action
Mail from baker@ada.cs.fsu.edu about Re: MUDs
PUT in mailbox: the default action
C. Sendmail
1. various flags
- standard daemon mode, started once at boot:
/usr/lib/sendmail -bd -q1h
- look at the mail queue, run manually by any user:
/usr/lib/sendmail -bp
-or-
mailq
- address test mode
> this is how you test your config files
/usr/lib/sendmail -bt -C
ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter Ruleset Address
> 3,0 kuncick@cs
rewrite: ruleset 3 input: kuncick @ cs
rewrite: ruleset 8 input: kuncick @ cs
...
many more lines
...
rewrite: ruleset 0 returns: $: kuncick @ NU.CS.FSU.EDU
3. the mail queue
- nu handles about 4000 pieces of mail daily
- a mail message is broken into a number of files
- the file prefix is followed by the queue ID number
- the most common files used are: QF, DF, and XF
- dfLAA15852
hi dave
- xfLAA15852
> this file is empty unless error messages are received
from other mailers
- qfLAA15852
> single letter codes followed by info
H - header
D - data location
$ - addressing information
P0
T795283357
DdfLAA15852
$rESMTP
$sgrep.cs.fsu.edu
$_grep.cs.fsu.edu [128.186.121.152]
S<@grep.cs.fsu.edu:kuncick@nu.cs.fsu.edu>
R
H?P?Return-Path: <<@grep.cs.fsu.edu:kuncick@nu.cs.fsu.edu>>
HReceived: from grep.cs.fsu.edu by nu.cs.fsu.edu with ESMTP (8.6.9/31nu)
id LAA15852; Wed, 15 Mar 1995 11:02:37 -0500
HReceived: from nu.cs.fsu.edu by grep.cs.fsu.edu with ESMTP (8.6.9/56)
id LAA18380; Wed, 15 Mar 1995 11:02:33 -0500
HReceived: by nu.cs.fsu.edu (8.6.9/31nu)
id LAA15839; Wed, 15 Mar 1995 11:02:31 -0500
HDate: Wed, 15 Mar 1995 11:02:31 -0500
HFrom: "D.C. Kuncicky"
HMessage-Id: <199503151602.LAA15839@nu.cs.fsu.edu>
HApparently-To: kuncick@grep
D. Configuring sendmail
1. /etc/sendmail.cf
2. three sections
- definitions of symbols, classes options and parameters
- address rewriting rules
- definitions of mailers
3. section 1 - symbol definition
- use upper case single characters for symbol names
- command codes are listed on page 463 Table 21.5
- lower case characters are mostly reserved
DDfsu.edu - define D to be fsu.edu
DTcs - define T to be cs
Cwnu - class w to be nu and logger
- 'w' is reserved to be this site's hostname
- see table 21.6 on page 465
Dj$w.$T.$D - define 'j' (fully-qualified host name) to be
nu.cs.fsu.edu
DnMAILER-DAEMON - who to send errors to
- this should be aliased to a real person in
/etc/aliases
DlFrom $g $d - define from header to be
From
- ex: From knapp@gamma.cs.fsu.edu
Wed Mar 15 11:13:57 1995
Do.:%@!^/[] - define legitimate delimiters (operators) for addresses
avoid: < > ( ) " \
ex of square brackets:
mail kuncick@\[128.186.121.31\]
Dq$?x$x <$g>$|$g$. - define 'q', the address format of a sender
- conditional macro
$?X true $| false $.
- if x is defined then the sender address format
is full name followed by
otherwise just the envelope sender
ex: From: Thomas Berrisford
De$j Sendmail $v/$V FSU Computer Science Department $b
- define the SMTP entry message
- this is the message you see in the dialog
with the CS dept mailer
- 'j is fully qualified hostname
followed by Sendmail version number
followed by personal message
followed by the date
- you can see this by turning verbose option on in
.mailrc
ex: 220-grep.cs.fsu.edu Sendmail 8.6.9/56
FSU Computer Science Department Wed, 15 Mar 1995 12:12:18 -0500
4. section 1 - setting options
- options are described in the online man page for sendmail
Complete list on page 495 of ORA's "sendmail" book (batbook)
(lists IDA/V8 specifics, too)
- options may either be set in sendmail.cf or be set on the
command line with the -o flag
# location of alias file
OA/etc/aliases
# default delivery mode (deliver in background)
Odbackground
# temporary file mode
OF0600
# log level
OL9
# queue directory
OQ/usr/spool/mqueue
# status file
OS/etc/sendmail.st
# default timeout interval (returns undelivered mail after 3 days)
OT3d
# encrypted wizard's password (for the undocumented "wiz" SMTP command)
OWnot-likely
# maximum load average before queueing mail
Ox10
# maximum load average before rejecting connections
OX15
# the 'p' option - security?
Opnoexpn - turns off EXPN, mail list expansion (causes sendmail
to print what a local address "expands" to; such as
an /etc/alias list).
Opneedmailhelp - verifies IP name and address of sending machine
(sending site needs to issue HELO or ELHO command 1st)
- does NOT stop mail forgery
5. section 1 - setting precedence
Pfirst-class=0
Pspecial-delivery=100
Pbulk=-60
Pjunk=-100
6. section 1 - trusted users
Troot
Tdaemon
Tnews
Tuucp
7. section 1 - set header format
H?P?Return-Path: <$g>
HReceived: $?sfrom $s$. by $j$?r with $r$. ($v/$V)
id $i; $b
H?D?Date: $a St. Patrick's Day
H?F?From: $q Computer Science Department - FSU
H?x?Full-Name: $x
H?M?Message-Id: <$t.$i@$j>
HSubject:
- these are the header formats built by sendmail for the
mail leaving this machine or sent to a local address on
this machine
- example: send mail to kuncick on mu
- when you type 'r' which field does the reply go to?
- let's decipher the Received field:
HReceived: $?sfrom $s$. by $j$?r with $r$. ($v/$V)
id $i; $b
- this is a little different from the example in the book
- not conditional, so always use this
- if 's' (sender's hostname) then 'from s'
followed by 'by' $j (fully-qualified hostname)
- if 'r' (Protocol) then
with $r
- ($v/$V) 'v' is sendmail binary version 8.6.9
'V' is our local sendmail.cf version, defined
in /etc/sendmail.cf
- followed by 'id' $i (queue number) then ';'
- and finally $b - the date
- example:
Received: by mu.cs.fsu.edu (8.6.9/56)
id KAA19690; Fri, 17 Mar 1995 10:10:53 -0500
(continued in "Sendmail III")