Prev | Current Page 1382 | Next

Bryan Costales, Claus Assmann, George Jansen, Gregory Shapiro

"sendmail, 4th Edition"

5.3 Use Value As Is with $&
For situations in which a macro should not be recursively expanded when the configuration
file is read, but rather should be used in rules as is, V8 sendmail offers the $&
prefix. For example, consider the following RHS of a rule:
R... $w.$&m
When sendmail encounters this RHS in the configuration file, it recursively expands
$w into its final text value (where that text value is your hostname, such as lady). But
because the m macro is prefixed with $&, it is not expanded until the rule is later evaluated
at runtime.*
To illustrate one application of $&, consider a client/hub setup. In such a setup, all
mail sent from a client machine is forwarded to the hub for eventual delivery. If the
client were to run a sendmail daemon to receive mail for local delivery, a mail loop
could (in the absence of an MX record) develop where a message would bounce back
and fourth between the client and the hub, eventually failing.
To break such a loop, a rule must be devised that recognizes that a received message
is from the hub:
R $+ $: $&r @ $&s <$1> Get protocol and host
R smtp @ $H <$+> $#local $: $1 Local delivery breaks a loop
R $* <$+> $#smtp $@ $H $: $2 Punt to hub
* Prior to V8.9, expansions with $& remained a single token even if they were legitimately multitokened. Beginning
with V8.9, $& correctly returns multitokens when a value is multitokened.


Pages:
1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394
życzenia katalog stron katalog stron pozycjonowanie Connie Talbot