Defined Macros
Contents:
Preassigned Macros
Command-Line Definitions
Configuration File Definitions
Macro Names
Macro Expansion: $ and $&
Macro Conditionals: $?, $|, and $.
Categories of Macros
Macros with the m4 Technique
Pitfalls
Alphabetized Reference
The sendmail program supports three kinds of macros. Class macros (Class Macros) are used to represent multiple values. Database macros (Database Macros) represent values stored in external files or networked maps. Now we discuss defined macros, which allow strings of text to be represented symbolically.
Defined macros can be declared (given names and assigned the strings of text that will become values) at four different times:
- When sendmail first begins to run, it preassigns strings of text to certain macros.
- When sendmail processes the options in its command line, macros that were declared by using the
-M
(see "Command-Line Definitions") command-line switch [1] are assigned their values.[1] Prior to V8.7 the
-oM
option (see (M)) was used to define macros on the command line. Although that option still works, the-M
command-line switch is now recommended as the preferred technique. - When sendmail reads its configuration file, macros that were declared by using the
D
configuration-file command (see "Configuration File Definitions") are assigned their values. - Finally, many macros are assigned values internally by sendmail as mail is received and sent.
Macros can be used in any configuration-file command. Generally, they are expanded (their value is used) when mail is sent or received.
Preassigned Macros
When sendmail first begins to run, it preassigns values to certain macros. The complete list of these macros is shown in Table 31.1. Each is described in detail at the end of this chapter in "Alphabetized Reference".
Macro | Description | |
---|---|---|
$_
| $- | RFC1413-validation and IP source route (V8.1 and above) |
$b
| $b | The current date in RFC822 format |
${bodytype}
| ${bodytype} | The ESMTP BODY parameter (V8.8 and above) |
${client_addr}
| ${client-addr} | The connecting host's IP address (V8.8 and above) |
${client_name}
| ${client-name} | The connecting host's canonical name (V8.8 and above) |
${envid}
| ${envid} | The original DSN envelope ID (V8.8 and above) |
$j
| $j | The canonical hostname |
$k
| $k | UUCP node name (V8.1 and above) |
$m
| $m | The domain name (V8.1 and above) |
$n
| $n | The bounced mail sender |
${opMode}
| ${opMode} | The startup operating mode (V8.7 and above) |
$v
| $v | The sendmail program's version |
$w
| $w | The short name of this host |
All preassigned macros can be redefined in the configuration file or in the command line. The -d35.9
(see -d35.9) debugging switch (when run on an empty configuration file) can be used to watch sendmail predefine its macros. [2]
[2] When you use this debugging switch, you will notice that operators such as
$*
are implemented as macros too.
Note that the m4 configuration technique uses many more macros than are shown here (see Table 31.5). But even with that technique this short list of macros is all that are internally defined by the sendmail program when it first starts up.