The sendmail.cf and sendmail.mc Files

The m4 macro processor program generates the sendmail.df file when it processes the macro configuration file provided by the local system administrator. Throughout the remainder of this chapter we will refer to this configuration file as the sendmail.mc file.

The configuration process is basically a matter of creating a suitable sendmail.mc file that includes macros that describe your desired configuration. The macros are expressions that the m4 macro processor understands and expands into the complex sendmail.cf syntax. The macro expressions are made up of the macro name (the text in capital letters at the start), which can be likened to a function in a programming language, and some parameters (the text within brackets) that are used in the expansion. The parameters may be passed literally into the sendmail.cf output or may be used to govern the way the macro processing occurs.

A sendmail.mc file for a minimal configuration (UUCP or SMTP with all nonlocal mail being relayed to a directly connected smart host) can be as short as 10 or 15 lines, excluding comments.

Two Example sendmail.mc Files

If you're an administator of a number of different mail hosts, you might not want to name your configuration file sendmail.mc. Instead, it is common practice to name it after the host - vstout.m4 in our case. The name doesn't really matter as long as the output is called sendmail.cf. Providing a unique name for the configuration file for each host allows you to keep all configuration files in the same directory and is just an administrative convenience. Let's look at two example macro configuration files so we know where we are heading.

Most sendmail configurations today use SMTP only. It is very simple to configure sendmail for SMTP. Example 18.1 expects a DNS name server to be available to resolve hosts and will attempt to accept and deliver all mail for hosts using just SMTP.

Example 18.1: Sample Configuration File vstout.smtp.m4

divert(-1)

#

# Sample configuration file for vstout - smtp only

#

divert(0)

VERSIONID(`@(#)sendmail.mc 8.7 (Linux) 3/5/96')

OSTYPE(`linux')

#

# Include support for the local and smtp mail transport protocols.

MAILER(`local')

MAILER(`smtp')

#

FEATURE(rbl)

FEATURE(access_db)

# end

A sendmail.mc file for vstout at the Virtual Brewery is shown in Example 18.2. vstout uses SMTP to talk to all hosts on the Brewery's LAN, and you'll see the commonality with the generic SMTP-only configuration just presented. In addition, the vstout configuration sends all mail for other destinations to moria, its Internet relay host, via UUCP.

Example 18.2: Sample Configuration File vstout.uucpsmtp.m4

divert(-1)

#

# Sample configuration file for vstout

#

divert(0)

VERSIONID(`@(#)sendmail.mc 8.7 (Linux) 3/5/96')

OSTYPE(`linux')

dnl

# moria is our smart host, using the 'uucp-new' transport.

define(`SMART_HOST', `uucp-new:moria')

dnl

# Support the local, smtp and uucp mail transport protocols.

MAILER(`local')

MAILER(`smtp')

MAILER(`uucp')

LOCAL_NET_CONFIG

# This rule ensures that all local mail is delivered using the

# smtp transport, everything else will go via the smart host.

R$* ‹ @ $*.$m. › $* $#smtp $@ $2.$m. $: $1 ‹ @ $2.$m. › $3

dnl

#

FEATURE(rbl)

FEATURE(access_db)

# end

If you compare and contrast the two configurations, you might be able to work out what each of the configuration parameters does. We'll explain them all in detail.

Typically Used sendmail.mc Parameters

A few of the items in the sendmail.mc file are required all the time; others can be ignored if you can get away with defaults. The general sequence of the definitions in the sendmail.mc is as follows:

1. VERSIONID

2. OSTYPE

3. DOMAIN

4. FEATURE

5. Local macro definitions

6. MAILER

7. LOCAL_* rulesets

We'll talk about each of these in turn in the following sections and refer to our examples in Example 18.1 and Example 18.2, when appropriate, to explain them.

Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату