Next: To Do
Up: Mail Handling
Previous: Sendmail
Subsections
To configure sendmail, you need to edit the
/etc/mail/sendmail.cf file.
Sun has thoughtfully provided two sample configuration files,
/etc/mail/main.cf and /etc/mail/subsidiary.cf
Our sendmail system is the main sendmail system for the network; it decides
where to send everything.
We simply need to make a few modifications to the
/etc/mail/main.cf file so that it meets our
requirements.
To modify sendmail.cf you first need to make a copy of
main.cf and modify it.
Change directory to /etc/mail and
type cp main.cf sendmail.cf
Afterwards, you'll need to make some changes to sendmail.cf
summarised in figures 19 and 20.
Rather than do all this work, you can get a complete copy of the
modified file at
http://users.orac.net.au/ doug/network/sendmail.cfYou will need to further modify this file so that it has the
correct domain names, etc.
Once you have changed sendmail.cf
(and if you have sendmail running) you will
need to inform sendmail of the fact that a change has occurred.
To do this, you will need to send a HUP signal to the sendmail
daemon.
Figure 19:
Changes to the sendmail.cf File -- Part 1
21c21
< Lmmaildomain
---
> #Lmmaildomain
We have no sendmailvars table.
26c26
< Dj$m
---
> #Dj$m
28c28
< #Dj$w.$m
---
> Dj$w.$m
We want this machine to appear inside the flibble.orac.net.au
domain, as solaris.flibble.orac.net.au or whatever you have
named your machine and domain.
34c34
< DMsmartuucp
---
> DMether
By default, we pass things in a chunk across the network.
37,38c37,39
< DR ddn-gateway
< CR ddn-gateway
---
> # Forward any mail I don't understand on to my ISP
> DR smtp.nat.orac.net.au
> CR smtp.nat.orac.net.au
Where to send mail that is outside my understanding.
Any mail which is not local gets sent on to the ISP's mail server,
and then on to the outside world.
73,75c74,90
< # Example:
< # DmCS.Podunk.EDU
< # Cm cs cs.Podunk.EDU
---
>
> #
> # Everything looks like it is coming from my ISP, although
> # I know better.
> Dmorac.net.au
> Cm orac.net.au
Although my domain name is flibble.orac.net.au
I want any mail sent to appear to come from my ISP.
That way, any returned mail will end up in the right place.
|
Figure 20:
Changes to the sendmail.cf File - Part 2
>
> # My local domain is really the DNS domain that I am actually
> # running in.
> # Domains which are really local domains
> DLflibble.orac.net.au
> CL flibble.orac.net.au
This is a list of the domains that are truly local.
Any mail addressed to this domain is delivered via the local mailer.
>
> # I don't want to send mail to myself outwards
> # Users which are really local users
> FU /etc/mail/localusers
>
Any user who is listed in the file /etc/mail/localusers
gets sent locally, even if it is addressed to them at the ISP.
This way, local mail is not sent out just so that it can be sent back again.
236c251,252
< R$*<@$*$=m>$* $1<@$2LOCAL>$4 convert local domain
---
> R$*$=U<@$=m>$* $1$2<@$L>$4 localise true local users
> R$*<@$*$=L>$* $1<@$2LOCAL>$4 convert true local domain
Any users who are listed in <STRONG>/etc/mail/localusers</STRONG> are
redirected locally.
Mail sent to the local domain name is also sent locally.
271c287
< R$+ $@$1<@$k> tack on my mbox host name
---
> R$+ $@$1<@$m> tack on my mbox host name
275c291
< R$+ $@$1<@$k> tack on my mbox host name
---
> R$+ $@$1<@$m> tack on my mbox host name
Mail sent from here appears to originate at my ISP, rather than
at this machine.
|
The sendmail.cf file, described above, uses a file called
/etc/mail/localusers to see who is a local user.
Mail addressed to an address of the form
localuser@your.isp.domain, eg.
doug@orac.net.au, get redirected
into local mailboxes, rather than sent out to the ISP.
The localusers file simply contains a list of local names,
one to a line.
As a sample, my localusers file contains:
doug
alison
If you wanted to get more sophisticated, you could pipe the
contents of your /etc/passwd file through a
suitable awk script.
Whenever you change the localusers file, you will need to
inform the sendmail daemon
that a configuration change has occurred, using the HUP signal.
One of the major motivations for setting up your own mailing
systems is the ability to use the aliases file.
Note that sendmail checks the alias file for local aliases only.
An alias with a domain name attached will be sent to the outside world.
Testing sendmail is liable to be a long and tedious
process and prone to errors.
When you start testing, it is a good idea to have your modem turned off,
so that your ISP is not bombarded by strange and undeliverable messages.
Another good idea, until you are happy, is to rename your
sendmail.cf file to something like test.cf and run
sendmail using the
-C test.cf option.
To test address rewriting, you will need to start sendmail in
address testing mode and see how well it looks after the various
addresses you give it.
To start sendmail in address testing mode, use the command
/usr/lib/sendmail -C test.cf -bt
You will be presented by a prompt, where you can try out various addresses
and see how they are rewritten.
Since you have the modem turned off, you may have to wait until the DNS server
times out before a prompt appears.
Samples, with comments, are shown in
figures 21, 22 and
23.
Figure 21:
sendmail Address Re-Writing -- Part 1
> 30 doug
rewrite: ruleset 30 input: doug
rewrite: ruleset 3 input: doug
rewrite: ruleset 3 returns: doug
rewrite: ruleset 0 input: doug
rewrite: ruleset 9 input: doug
rewrite: ruleset 9 returns: doug
rewrite: ruleset 0 returns: $# local $: doug
rewrite: ruleset 30 returns: $# local $: doug
|
Names by themselves are delivered locally. |
> 30 doug@orac.net.au
rewrite: ruleset 30 input: doug @ orac . net . au
rewrite: ruleset 3 input: doug @ orac . net . au
rewrite: ruleset 6 input: doug < @ orac . net . au >
rewrite: ruleset 6 returns: doug < @ LOCAL >
rewrite: ruleset 3 returns: doug < @ LOCAL >
rewrite: ruleset 0 input: doug < @ LOCAL >
rewrite: ruleset 30 input: doug
rewrite: ruleset 3 input: doug
rewrite: ruleset 3 returns: doug
rewrite: ruleset 0 input: doug
rewrite: ruleset 9 input: doug
rewrite: ruleset 9 returns: doug
rewrite: ruleset 0 returns: $# local $: doug
rewrite: ruleset 30 returns: $# local $: doug
rewrite: ruleset 0 returns: $# local $: doug
rewrite: ruleset 30 returns: $# local $: doug
|
Addresses which are part of my ISP's domain, but are
listed in the /etc/mail/localusers
table are rewritten by ruleset 6 to be delivered locally. |
> 30 doug@flibble.orac.net.au
rewrite: ruleset 30 input: doug @ flibble . orac . net . au
rewrite: ruleset 3 input: doug @ flibble . orac . net . au
rewrite: ruleset 6 input: doug < @ flibble . orac . net . au >
rewrite: ruleset 6 returns: doug < @ LOCAL >
rewrite: ruleset 3 returns: doug < @ LOCAL >
rewrite: ruleset 0 input: doug < @ LOCAL >
rewrite: ruleset 30 input: doug
rewrite: ruleset 3 input: doug
rewrite: ruleset 3 returns: doug
rewrite: ruleset 0 input: doug
rewrite: ruleset 9 input: doug
rewrite: ruleset 9 returns: doug
rewrite: ruleset 0 returns: $# local $: doug
rewrite: ruleset 30 returns: $# local $: doug
rewrite: ruleset 0 returns: $# local $: doug
rewrite: ruleset 30 returns: $# local $: doug
|
Anything directed to my local domain is delivered locally. |
> 30 someone@orac.net.au
rewrite: ruleset 30 input: someone @ orac . net . au
rewrite: ruleset 3 input: someone @ orac . net . au
rewrite: ruleset 6 input: someone < @ orac . net . au >
rewrite: ruleset 6 returns: someone < @ orac . net . au >
rewrite: ruleset 3 returns: someone < @ orac . net . au >
rewrite: ruleset 0 input: someone < @ orac . net . au >
rewrite: ruleset 9 input: someone < @ orac . net . au >
rewrite: ruleset 9 returns: someone < @ orac . net . au >
rewrite: ruleset 0 returns: $# ether
$@ mail . orac . net . au $: someone < @ orac . net . au >
rewrite: ruleset 30 returns: $# ether
$@ mail . orac . net . au $: someone < @ orac . net . au >
|
Anybody in my ISP's domain not listed in the
/etc/mail/localusers table gets passed on
to the ISP's mail system. |
> 30 someone@flibble.orac.net.au
rewrite: ruleset 30 input: someone @ flibble . orac . net . au
rewrite: ruleset 3 input: someone @ flibble . orac . net . au
rewrite: ruleset 6 input: someone < @ flibble . orac . net . au >
rewrite: ruleset 6 returns: someone < @ LOCAL >
rewrite: ruleset 3 returns: someone < @ LOCAL >
rewrite: ruleset 0 input: someone < @ LOCAL >
rewrite: ruleset 30 input: someone
rewrite: ruleset 3 input: someone
rewrite: ruleset 3 returns: someone
rewrite: ruleset 0 input: someone
rewrite: ruleset 9 input: someone
rewrite: ruleset 9 returns: someone
rewrite: ruleset 0 returns: $# local $: someone
rewrite: ruleset 30 returns: $# local $: someone
rewrite: ruleset 0 returns: $# local $: someone
rewrite: ruleset 30 returns: $# local $: someone
|
But the local domain is still delivered locally. |
|
Figure 22:
sendmail Address Re-Writing -- Part 2
> 30 a.n.other@awm.gov.au
rewrite: ruleset 30 input: a . n . other @ awm . gov . au
rewrite: ruleset 3 input: a . n . other @ awm . gov . au
rewrite: ruleset 6 input: a . n . other < @ awm . gov . au >
rewrite: ruleset 6 returns: a . n . other < @ awm . gov . au >
rewrite: ruleset 3 returns: a . n . other < @ awm . gov . au >
rewrite: ruleset 0 input: a . n . other < @ awm . gov . au >
rewrite: ruleset 9 input: a . n . other < @ awm . gov . au >
rewrite: ruleset 9 returns: a . n . other < @ awm . gov . au >
rewrite: ruleset 0 returns: $# ether
$@ smtp . nat . orac . net . au $: a . n . other < @ awm . gov . au >
rewrite: ruleset 30 returns: $# ether
$@ smtp . nat . orac . net . au $: a . n . other < @ awm . gov . au >
|
Anybody else gets passed on to the ISP's mail system, to be forwarded
from there.
We do not deliver directly, as that means that each individual domain
in the address list needs to be delivered separately.
This could mean quite a bit of traffic; let the ISP do the work. |
|
Figure 23:
sendmail Address Re-Writing -- Part 3
|
Ruleset 11 is used to pre-process the sender when mail is being
delivered by the ether agent.
Similarly, ruleset 21 pre-processes the receiver. |
> 11 doug
rewrite: ruleset 11 input: doug
rewrite: ruleset 11 returns: doug < @ orac . net . au >
> 21 doug
rewrite: ruleset 21 input: doug
rewrite: ruleset 21 returns: doug < @ orac . net . au >
|
If we haven't got a domain name, then add our ISP's name. |
> 11 doug<@orac.net.au>
rewrite: ruleset 11 input: doug < @ orac . net . au >
rewrite: ruleset 11 returns: doug < @ orac . net . au >
> 11 a.n.other<@awm.gov.au>
rewrite: ruleset 11 input: a . n . other < @ awm . gov . au >
rewrite: ruleset 11 returns: a . n . other < @ awm . gov . au >
> 21 doug<@orac.net.au>
rewrite: ruleset 21 input: doug < @ orac . net . au >
rewrite: ruleset 21 returns: doug < @ orac . net . au >
> 21 a.n.other<@awm.gov.au>
rewrite: ruleset 21 input: a . n . other < @ awm . gov . au >
rewrite: ruleset 21 returns: a . n . other < @ awm . gov . au >
|
Addresses with domain names attached get left alone.
|
|
Once you are happy with the address rewriting, you can
start sending mail about the place.
Have a few friends on tap who will send you replies, or a mail
redirection service so that you can send mail to yourself.
Any mail that you send yourself should get diverted into the local
mailbox.
You can examine the Received by: trail in the
returning mail to see whether your setup is working correctly.
Sendmail traffic is logged, by default, to the
/var/log/syslog file.
Having a window up displaying the output of
tail -f /var/log/syslog is a good idea, while you
are testing.
Next: To Do
Up: Mail Handling
Previous: Sendmail
Doug Palmer
2003-02-15