Macros can
greatly simplify your work. They allow you to represent text
symbolically and to define it in one central place.
Changes in that text are automatically propagated
to the rest of the file. For example,
consider the following definition in your sendmail.cf file:
D{REMOTE}mailhost
If you use the expression ${REMOTE} anywhere
in that file, a single change to the definition
of D{REMOTE}mailhost changes the value of
${REMOTE} throughout the entire file.
Here is the format for defining macros:
DXtext
The letter D must begin the line. The D is immediately followed by
the name of the macro, here
X, with no intervening space. The name
is then followed (again with no intervening space) by the
text (value) for the macro's definition. The value is all the
text up to the end of the line.
[1]
Macros may have single-character names or multicharacter
names. Multicharacter names must always be enclosed in
curly braces. Single-character names may be enclosed
in curly braces if you desire. Prior to V8.7 you could use
single characters only without curly braces.
DRmailhost
single-character name (prior to V8.7)
D{R}mailhost
same beginning with V8.7
D{REMOTE}mailhost
multicharacter name (beginning with V8.7)
Except for header and delivery agent configuration commands,
[2]
macros, in general, are expanded (the text replaces the symbol)
when the configuration file is read. Consequently, you must define
them before you use them:
D{ROLE}son
S${ROLE}
use the text value ``son''
D{ROLE}mother
S${ROLE}
use the text value ``mother''
Here, ROLE was first given the value son. When the
first S command is processed, sendmail replaces
the expression ${ROLE} with its current value to form
Sson
Then ROLE is redefined and given a different value,
that of mother. The second S command is processed,
and its ${ROLE} is replaced with the new value:
Smother
Please note that this is very bad style. In general, each macro should be defined only once to avoid confusion.