sendmail

sendmailSearch this book
Previous: 30.8 Alphabetized F= FlagsChapter 31Next: 31.2 Command-Line Definitions
 

31. 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 (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:

  1. When sendmail first begins to run, it preassigns strings of text to certain macros.

  2. 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.

  3. 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.

  4. 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.

31.1 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 Section 31.10, "Alphabetized Reference".

Table 31.1: Preassigned Macros
MacroDescription
$_Section 31.10.1, $-RFC1413-validation and IP source route (V8.1 and above)
$bSection 31.10.3, $bThe 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)
$jSection 31.10.20, $jThe canonical hostname
$kSection 31.10.21, $kUUCP node name (V8.1 and above)
$mSection 31.10.24, $mThe domain name (V8.1 and above)
$nSection 31.10.26, $nThe bounced mail sender
${opMode}Section 31.10.28, ${opMode}The startup operating mode (V8.7 and above)
$vSection 31.10.38, $vThe sendmail program's version
$wSection 31.10.40, $wThe 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.


Previous: 30.8 Alphabetized F= FlagssendmailNext: 31.2 Command-Line Definitions
30.8 Alphabetized F= FlagsBook Index31.2 Command-Line Definitions