The sendmail program uses DNS in several different ways:
When sendmail first starts, it might use DNS to
get the canonical name for the local host. That name is then assigned
$j macro ($j). If DNS returns additional names for the local host, those
names are assigned to the class
When sendmail first starts, it looks up the IP number or numbers assigned to each network interface. For each address it finds, it uses DNS to look up the hostname associated with that address.
When another host connects to the local host to transfer mail, the local sendmail looks up the other host with DNS to find the other host’s canonical name.
Before accepting mail, sendmail can look up the IP address of the connecting host on various blacklist sites (Chapter 7). If that address is listed, the message is rejected.
To relay based on MX records (Section 7.4.4), sendmail does a lookup to determine if the connecting host is listed as an MX server for the local domain.
When delivering network SMTP mail, sendmail uses DNS to find the address (or addresses) to which it should connect.
When sendmail expands
$] in the RHS of a rule, it looks up the hostname
(or IP number) between them.
We discuss each of these uses later in this chapter.
All versions of sendmail use more or less the same logical process to obtain the canonical name of the local host. As illustrated in the following sample program, sendmail first calls gethostname ...