Mailfromd Manual (split by node):   Section:   Chapter:FastBack: Library   Up: Library   FastForward: Using MFL Mode   Contents: Table of ContentsIndex: Concept Index

5.1 Sendmail Macro Access Functions

Built-in Function: string getmacro (string macro)

Returns the value of Sendmail macro macro. If macro is not defined, raises the e_macroundef exception.

Calling getmacro(name) is completely equivalent to referencing ${name}, except that it allows to construct macro names programmatically, e.g.:

  if getmacro("auth_%var") = "foo"
    …
  fi
Built-in Function: boolean macro_defined (string name)

Return true if Sendmail macro name is defined.

Notice, that if your MTA supports macro name negotiation18, you will have to export macro names used by these two functions using ‘#pragma miltermacros’ construct. Consider this example:

func authcheck(string name)
do
  string macname "auth_%name"
  if macro_defined(macname)
    if getmacro(macname)
      …
    fi
  fi
done

#pragma miltermacros envfrom auth_authen

prog envfrom
do
  authcheck("authen")
done

In this case, the parser cannot deduce that the envfrom handler will attempt to reference the ‘auth_authen’ macro, therefore the ‘#pragma miltermacros’ is used to help it.

Footnotes

(18)

That is, if it supports Milter protocol 6 and upper. Sendmail 8.14.0 and Postfix 2.6 and newer do. MeTA1 (via pmult) does as well. See MTA Configuration, for more details.