Milter smfi_getsymval()

Fetch a sendmail macro’s value All sendmail versions

The sendmail program defines macros for your use in rule sets (such as the $j and ${mail_addr} macros) and allows you to define new macros for your own use. Milters can access sendmail macros using this smfi_getsymval() routine. It is used like this:

symval = smfi_getsymval(ctx, symname);

Here, ctx is the common context pointer that was passed to your xxfi_eom() function. The symname is the name of the macro whose value you seek and symval is the value (a string) returned by the function call. The symname is a string that specifies the name of a single macro. The $ prefix must be omitted. Multicharacter macro names must be enclosed in curly braces. Single-character names may optionally be surrounded in curly braces:

"${j}"                        ← Won't work, has leading $ character
"{j}"                        ← Good
"j"                        ← Also good
"{mail_host}"                        ← Good multicharacter name
"{mail_host} {mail_addr}"                        ← Won't work, multiple macro names

The returned symval is a pointer to a string that will be NULL if the macro name is undefined, if one is not sent to the Milter, if there was a network error, or if symname is NULL. If the macro’s name is found, symval will point into the Milter library context’s memory. Note that this value is volatile, so you should copy it if you need to preserve it.

In general, an envelope-specific macro is valid only for the current envelope, and a connection-specific macro is valid only for the current connection. That is, sendmail macros ...

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.