OpenBSD manual page server

Manual Page Search Parameters

SMTPD-TABLES(7) Miscellaneous Information Manual SMTPD-TABLES(7)

smtpd-tablestable API for the smtpd daemon

The smtpd(8) daemon provides a Simple Mail Transfer Protocol (SMTPD) implementation, which allows ordinary machines to become Mail eXchangers (MX). Some features that are commonly used by MX, such as querying databases for user credentials, are outside of the scope of SMTP and too complex to fit in smtpd(8).

Because an MX may need to provide these features, smtpd(8) provides an API to implement table(5) backends with a simple text-based protocol.

smtpd-tables are programs that run as unique standalone processes, they do not share smtpd(8) address space. They are executed by smtpd(8) at startup and expected to run in an infinite loop, reading events and queries from standard input and writing responses to standard output. They are not allowed to terminate.

Because smtpd-tables are standalone programs that communicate with smtpd(8), they may run as different users than smtpd(8) and may be written in any language. smtpd-tables must not use blocking I/O, they must support answering asynchronously to smtpd(8).

The protocol consist of human-readable lines exchanged between smtpd-tables and smtpd(8).

The protocol begins with a handshake. First, smtpd(8) provides smtpd-tables with general configuration information in the form of key-value lines, terminated by ‘config|ready’. For example:


Then, smtpd-tables register the supported services, terminating with ‘register|ready’. For example:


Finally, smtpd(8) can start querying the table. For example:


The “|” character is used to separate the fields and may only appear verbatim in the last field of the payload, in which case it should be considered a regular character and not a separator. No other field may contain a “|”.

Each request has a common set of fields, followed by some other fields that are operation-specific. The common format consists of a protocol prefix ‘table’, the protocol version, the timestamp and the table name. For example:


The protocol is inherently asynchronous, so multiple request may be sent without waiting for the table to reply. All the replies have a common prefix, followed by the operation-specific response. The common format consist of a prefix with the operation name in followed by ‘-result’, and the unique ID of the request. For example:


The list of operations, operation-specific parameters and responses are as follows:

Ask the table to reload its configuration. The result is either ‘ok’ on success or ‘error’ and a message upon a failure to do so.
service id query
Check whether query is present in the table. The result is ‘found’ if found, ‘not-found’ if not, or ‘error’ and a message upon an error.
service id query
Look up a value in the table for given the query. The result is ‘found’ and the value if found, ‘not-found’ if not found, or ‘error’ and a message upon an error.
service id
Fetch the next item from the table, eventually wrapping around. It is only supported for the source and relayhost services. The result is ‘found’ and the value if found, ‘not-found’ if the table is empty, or ‘error’ and a message upon an error.

Each service has a specific format for the result. The exact syntax for the values and eventually the keys are described in table(5). The services and their result format are as follows:

One or more aliases separated by a comma.
Only usable for check. Lookup key is username and cleartext password separated by ‘:’.
A domain name.
The user name, followed by ‘:’ and the encrypted password as per smtpctl(8) encrypt subcommand.
IPv4 and IPv6 address or netmask.
The user id, followed by ‘:’ then the group id, then ‘:’ and finally the home directory.
IPv4 and IPv6 address.
An username, a domain or a full email address.
Used to map IP addresses to hostnames.

Assuming the table is called “devs”, here's an example of a failed update transaction:

update-result|478ff0d2|error|failed to connect to the database

A check request for the netaddr service for the IPv4 address which is not in the table:


A successful lookup request for the userinfo service for the user ‘op’:


A series of fetch requests for the source service that wraps around:



smtpd-tables first appeared in OpenBSD 7.6.

June 9, 2024 OpenBSD-current