Macros are named with a single character or with a word in braces ({}). Single character names may be selected from the entire ASCII set, but user-defined macros should be selected from the set of upper case letters only. Lower case letters and special symbols are used internally. Long names beginning with a lower case letter or a punctuation character are reserved for use by sendmail, so user-defined long macro names should begin with an upper case letter.
The syntax for macro definitions is:
Dx | val
x is the name of the macro (which may be a single character or a word in braces) and val is the value it should have. There should be no spaces given that do not actually belong in the macro value.
Macros are interpolated using the construct $x, where x is the name of the macro to be interpolated. This interpolation is done when the configuration file is read, except in M lines. The special construct $&x can be used in R lines to get deferred interpolation.
Conditionals can be specified using the syntax:
$?x text1 $| text2 $.
This interpolates text1 if the macro $x is set, and text2 otherwise. The else (<$|) clause may be omitted.
Lower case macro names are reserved to have special semantics, used to pass information in or out of sendmail(1M), and special characters are reserved to provide conditionals, and so on. Upper case names (that is, $A through $Z) are specifically reserved for configuration file authors.
The following macros are defined and/or used internally by sendmail for interpolation into argv's for mailers or for other contexts. (The macros not marked by a footnote are passed out of sendmail but are not otherwise used internally.)
Date: line.
Received:
lines plus the value of the -h command line flag.
$j Sendmail $v ready at $b. Commonly redefined to include
the configuration version number, for example, $j Sendmail
$v/$Z ready at $b.
From $g $d.
<$g>. It is commonly redefined to be
$?x$x <$g>$|$g$ or $g$?x ($x)$., corresponding
to the following two formats:
sendmail properly quotes names that have special characters if the first form is used.
Date: line of the
message (if there was one), and $b is the current date
and time (used for postmarks). If no Date: line is found
in the incoming message, $a is set to the current time
also. The $d macro is equivalent to the $b
macro in UNIX (see the
ctime(3C)
manual page) format.
The macros $w, $j, and $m are set to the identity of this host. sendmail tries to find the fully qualified name of the host if at all possible; it does this by calling gethostname(3bsd) to get the current hostname and then passing that to gethostbyname(3N) which is supposed to return the canonical version of that host name.
For example, on some systems, gethostname might return foo which would be mapped to foo.bar.com by gethostbyname.
Assuming this is successful, $j is set to the fully qualified name and $m is set to the domain part of the name (everything after the first dot). The $w macro is set to the first word (everything before the first dot) if you have a level 5 or higher configuration file; otherwise, it is set to the same value as $j. If the canonification is not successful, it is imperative that the config file set $j to the fully qualified domain name. The $f macro is the ID of the sender as originally determined; when mailing to a specific host the $g macro is set to the address of the sender relative to the recipient. For example, if a message is sent to bollard@matisse.CS.Berkeley.EDU from the machine vangogh.CS.Berkeley.EDU, the $f macro will be eric and the $g macro will be eric@vangogh.CS.Berkeley.EDU.
The $x macro is set to the full name of the sender.
This can be determined in several ways. It can be passed as flag
to sendmail. It can be defined in the NAME
environment variable. The third choice is the value of the
Full-Name: line in the header if it exists, and the
fourth choice is the comment field of a From: line.
If all of these fail, and if the message is being originated
locally, the full name is looked up in the /etc/passwd
file.
When sending, the $h, $u, and $z macros get set to the host, user, and home directory (if local) of the recipient. The first two are set from the $@ and $: part of the rewriting rules, respectively.
The $p and $t macros are used to create
unique strings (for example, for the Message-Id: field).
The $i macro is set to the queue id on this host; if
put into the timestamp line it can be extremely useful for
tracking messages. The $v macro is set to be the
version number of sendmail; this is normally put in
timestamps and has been proven extremely useful for debugging.
The $c macro is set to the hop count, for example, the number of times this message has been processed. This can be determined by the -h flag on the command line or by counting the timestamps in the message.
The $r and $s macros are set to the protocol used to communicate with sendmail and the sending hostname. They can be set together using the -p command line flag or separately using the -M or -oM flags.
The $_ macro is set to a validated sender host name. If the sender is running an RFC1413-compliant IDENT server and the receiver has the IDENT protocol turned on, it will include the user name on that host.
The ${client_name}, ${client_addr}, and ${client_port} macros are set to the name, address, and port number of the SMTP client who is invoking sendmail as a server. These can be used in the check_* rulesets using the $& deferred evaluation form (see ``Ruleset hooks'' for details).