| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Some of the mail filtering conditions may depend on the value of
helo domain name, i.e. the argument to the SMTP EHLO (or
HELO) command. If you ever need such conditions, take into
account the following caveats. Firstly, although Sendmail
passes the helo domain in $s macro, it does not do this
consistently. In fact, the $s macro is available only to
the helo handler, all other handlers won't see it, no matter what
the value of the corresponding Milter.macros.handler
statement. So, if you wish to access its value within an other
handler, you will have to store it in a variable in the helo
handler and then use this variable value in the other handler. This
brings us to the concept of variables in mailfromd scripts.
A variable is declared using the following syntax:
type name |
where variable is the variable name and type is ‘string’, if the variable is to hold a string value, and ‘number’, if it is supposed to have a numeric value.
A variable is assigned a value using set statement, as shown
below:
set name expr |
where expr is any valid MFL expression.
To get the value of a variable, the following notation is used:
%name. The set statement can occur within handler
declarations as well as outside of them.
There are two kinds of Mailfromd variables: global
variables, that are visible to all handlers and functions, and
automatic variables, that are available only within the handler
or function where they are declared. For our purpose we need a global
variable (See section Variable classes, for detailed descriptions
of both kinds of variables).
The following example illustrates the approach that allows to use
the HELO domain name in any handler:
# Declare the helohost variable string helohost prog helo do # Save the host name for further use set helohost $s done prog envfrom do # Reject hosts claiming to be localhost if %helohost = "localhost" reject 570 "Please specify real host name" fi done |
Notice, that for this approach to work, the Sendmail
statement Milter.macros.helo must contain ‘s’
(see section Configuring Sendmail to use mailfromd). This requirement can be removed by
using the handler argument of helo. Each
mailfromd handler is given one or several arguments. The
exact number of arguments and their meaning are handler-specific and are
described in Handlers, and milter-control-flow.
The arguments are referenced by their ordinal number, using the notation
$n. The helo handler takes one argument, whose
value is the helo domain. Using this information, the helo
handler from the example above can be rewritten as follows:
prog helo
do
# Save the host name for further use
set helohost $1
done
|
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by Sergey Poznyakoff on March, 10 2008 using texi2html 1.78.