7. Macros
One of the major strengths of the sendmail.cf file is that it allows text to be referenced symbolically. This is very similar to how variables in the Bourne and C shells are used:
REMOTE=mailhost Bourne shell set REMOTE=mailhost C shell D{REMOTE}mailhost sendmail.cf file
The statements above all cause
a variable with the name
The expression for using (referencing) the value stored
in
$REMOTE Bourne shell $REMOTE C shell ${REMOTE} sendmail.cf file
That is, all of the above expressions yield the value
stored in 7.1 OverviewMacros 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 Here is the format for defining macros:
D
The letter
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,
Sson
Then
Smother Please note that this is very bad style. In general, each macro should be defined only once to avoid confusion. |
|