${client_name}

The connecting host’s canonical name V8.8 and later

The ${client_name} macro is assigned its value when a host connects to the running daemon. This macro holds as its value the canonical hostname of that connecting host, which is the same as the hostname stored in the $_ macro.

The ${client_name} macro is useful in the Local_check_rcpt (Local_check_rcpt and check_rcpt on page 257), Local_check_mail (Local_check_mail and check_mail on page 255), and Local_check_relay (Local_check_relay and check_relay on page 252) rule sets. It can, for example, be used to see whether the connecting host is your firewall machine:

LOCAL_CONFIG
D{FireWallHost}fw.our.domain

LOCAL_RULESETS
SLocal_check_mail
R $*                     $: $&{client_name}
R ${FireWallHost}        $@ Okay our firewall machine
R $*                     $#error $@ 5.7.1 $: "550 can accept only from our firewall"

Here, the first rule transfers the value of ${client_name} into the workspace. The $& prefix (Use Value As Is with $& on page 793) prevents that macro from wrongly being expanded when the configuration file is read. The second rule compares the name of the firewall to that workspace. If they match, the connecting host was, indeed, the firewall machine.

${client_name} is transient. If it is defined in the configuration file or in the command line, that definition can be ignored by sendmail. Note that ${client_name} is not guaranteed to be available in the check_compat rule set (The check_compat Rule Set on page 259). Also note that a $& prefix is necessary ...

Get sendmail, 4th 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.