Next: SMTP RSET and Milter Abort Handling, Previous: Avoiding Verification Loops, Up: Tutorial [Contents][Index]
As any programming language, MFL has a concept of variables. A variable is declared using the following syntax:
type name
where variable is the variable name and type defines its
type: either string, or number.
A variable is assigned a value using the set statement:
set name expr
where expr is any valid MFL expression.
The set statement can occur within handler or function
declarations as well as outside of them.
A variable need not be declared prior to assigning a value: a
set statement with name referring to a variable
that has not been declared, declares it implicitly, deducing its type
from that of the expr.
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. Any variable declared outside of
a prog block is a global variable. Global variables are used to
pass information between the handlers. For example, the following
code fragment uses global variable helohost to store the
argument to the helo handler and to use it later on to decide
whether to accept the message.
# Declare the helohost variable string helohost prog helo do # Save the host name for further use set helohost $1 done prog envfrom do # Reject hosts claiming to be localhost if helohost = "localhost" reject 570 "Please specify real host name" fi done
Next: SMTP RSET and Milter Abort Handling, Previous: Avoiding Verification Loops, Up: Tutorial [Contents][Index]