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 (Chapter 32, Class Macros) are used to represent multiple values. Database macros (Chapter 33, Database Macros) represent values stored in external files or networked maps. In this chapter 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 Section 31.2, "Command-Line Definitions") command-line
switch
[1]
are assigned their values.
[1] Prior to V8.7 the
-oM
option (see Section 34.8.77, (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 Section 31.3, "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.
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 Section 31.10, "Alphabetized Reference".
Macro | Description | |
---|---|---|
$_ | Section 31.10.1, $- | RFC1413-validation and IP source route (V8.1 and above) |
$b | Section 31.10.3, $b | The current date in RFC822 format |
${bodytype} | Section 31.10.4, ${bodytype} | The ESMTP BODY parameter (V8.8 and above) |
${client_addr} | Section 31.10.7, ${client-addr} | The connecting host's IP address (V8.8 and above) |
${client_name} | Section 31.10.8, ${client-name} | The connecting host's canonical name (V8.8 and above) |
${envid} | Section 31.10.12, ${envid} | The original DSN envelope ID (V8.8 and above) |
$j | Section 31.10.20, $j | The canonical hostname |
$k | Section 31.10.21, $k | UUCP node name (V8.1 and above) |
$m | Section 31.10.24, $m | The domain name (V8.1 and above) |
$n | Section 31.10.26, $n | The bounced mail sender |
${opMode} | Section 31.10.28, ${opMode} | The startup operating mode (V8.7 and above) |
$v | Section 31.10.38, $v | The sendmail program's version |
$w | Section 31.10.40, $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 Section 37.5.120, -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.