${client_port}
The connecting host’s port number V8.10 and later
Rule sets cannot know which port a connecting host
used to connect to the listening daemon unless that
port number is stored in a macro. This ${client_port}
macro
holds as its value that port number. This port
number should not be confused with the port number
on which the listening daemon accepted the
connection (usually 25). This is the port number
used by the other MTA to establish its outbound
connection to your listening daemon.
One use for this macro might be to log the client port so that you can develop a profile of ports used by spam sites (and perhaps find a pattern):
LOCAL_CONFIG Klog syslog LOCAL_RULESETS SLocal_check_mail R $* $@ $(log Port_Stat &${client_name} $&{client_addr} $&{client_port} $)
Here, we first define a database map of type syslog
and name it
log
. Then we
declare the Local_check_mail
rule set (Local_check_mail and check_mail
on page 255), which is called just after the
MAIL From:
command is received. The single rule in that rule
set uses the log
database map to syslog the
client’s name, address, and port number. The
$@
beginning
the RHS causes the rule set to return immediately
after logging.
${client_port}
is
transient. If it is defined in the configuration
file or in the command line, that definition can be
ignored by sendmail. Note that
a $&
prefix
is necessary when you reference this macro in rules
(that is, use $&{client_port}
, not ${client_port}
).
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.