The RHS

The purpose of the RHS in a rule is to rewrite the workspace. To make this rewriting more versatile, sendmail offers several special RHS operators. The complete list is shown in Table 18-2.

Table 18-2. RHS operators

RHS

§

Description or use

$digit

Section 18.7.1

Copy by position

$:

Section 18.7.2

Rewrite once (when used as a prefix), or specify the user in a delivery-agent “triple,” or specify the default value to return on a failed database-map lookup

$@

Section 18.7.3

Rewrite and return (when used as a prefix), or specify the host in a delivery-agent “triple”, or specify an argument to pass in a database-map lookup or action

$>set

Section 18.7.4

Rewrite through another rule set (such as a subroutine call that returns to the current position)

$#

Section 18.7.5

Specify a delivery agent or choose an action, such as to reject or discard a recipient, sender, connection, or message.

$[ $]

Section 18.7.6

Canonicalize hostname

$( $)

Section 23.4

Perform a lookup in an external database, file, or network service, or perform a change (such as dequoting), or store a value into a macro.

$&

Section 21.5.3

Delay conversion of a macro until runtime

Copy by Position: $digit

The $digit operator in the RHS is used to copy tokens from the LHS into the workspace. The digit refers to positions of LHS wildcard operators in the LHS:

R $+ @ $*    $2!$1
      $1           $2 

Here, the $1 in the RHS indicates tokens matched by the first wildcard operator in the LHS (in this case, ...

Get Sendmail, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.