General-Purpose Mail Filter
Socket map (sockmap for short) is a special type of database used in Sendmail and MeTA1. It uses a simple server/client protocol over INET or UNIX stream sockets. The server listens on a socket for queries. The client connects to the server and sends it a query, consisting of a map name and a key separated by a single space. Both map name and key are sequences of non-whitespace characters. The map name serves to identify the type of the query. The server replies with a response consisting of a status indicator and result, separated by a single space. The result part is optional.
For example, following is the query for key ‘smith’ in map ‘aliases’:
A possible reply is:
This reply means that the key ‘news’ was found in the map, and the value corresponding to that key is ‘email@example.com’.
The following reply means the key was not found:
For a detailed description of the sockmap protocol, see Protocol in Smap manual.
The MFL library provides two primitives for dealing with sockmaps. Both primitives become available after requiring the sockmap module.
This function look ups the key in the map. The fd
refers to the sockmap to use. It must be obtained as a result of a
previous call to
open with the URL of the sockmap as
its first argument (see open). For example:
number fd open("@ unix:///var/spool/meta1/smap/socket") string ret sockmap_query(fd, "aliases", $rcpt_to) if ret matches "OK (.+)" set alias \1 fi close(fd)
This function connects to the sockmap identified by the url, queries for key in map and closes the connection. It is useful when you need to perform only a single lookup on the sockmap.
This document was generated on January 3, 2019 using makeinfo.Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.