smtpd-tables-scripts
Utility helpers for OpenSMTPD table backend debugging.
Files
table-spy: transparent proxy for table backends; logs live protocol traffic betweensmtpdand a real backend.table-debug: test helper for manual protocol debugging through a local TCP listener.
table-spy
What it does
- Starts the real backend as a child process.
- Forwards bytes both ways:
smtpd stdin -> backend stdinbackend stdout -> smtpd stdout
- Logs both directions with source prefixes (
smtpd:and backend name). - Also logs backend stderr as
<backend>-stderr:.
This is transparent for smtpd and the real backend and supports asynchronous table protocol traffic.
Usage
./table-spy /etc/mail/spy.confConfig format (/etc/mail/spy.conf)
Required keys:
backend /usr/local/libexec/smtpd/table-postgres
backend_config /etc/mail/postgres.conf
logfile /var/log/table-spy.log
Accepted separators: whitespace, :, or =.
OpenSMTPD config example
table vdomains spy:/etc/mail/spy-vdomains.conf
Then create one spy config per table (spy-vdomains.conf, etc.) that points to the real backend and backend config.
table-debug
What it does
- Reads table protocol lines from
smtpdon stdin. - Forwards them to a hardcoded local TCP listener at
127.0.0.1:25252. - Forwards lines received from that listener back to
smtpdon stdout.
Use this when you want to manually emulate a backend or inspect/alter protocol exchanges in a controlled test setup.
Usage
- Start a local listener (example):
nc -l 127.0.0.1 25252- Configure a table to use
debug:backend, for example:
# table my_debug debug:/etc/mail/anything
- Interact through the listener and observe request/response flow.
Install instructions
Install both scripts to OpenSMTPD helper directory:
doas install -o root -g wheel -m 0755 smtpd-tables-scripts/table-spy /usr/local/libexec/smtpd/table-spy
doas install -o root -g wheel -m 0755 smtpd-tables-scripts/table-debug /usr/local/libexec/smtpd/table-debugFor table-spy logging:
doas touch /var/log/table-spy.log
doas chown _smtpd:_smtpd /var/log/table-spy.log
doas chmod 0640 /var/log/table-spy.logFor spy config readability:
doas chmod 0644 /etc/mail/spy-*.confValidate and reload:
doas smtpd -n
doas rcctl restart smtpdNotes
table-spywraps executable helper backends (such astable-postgres).- Built-in backends like
file:are not external helper binaries and are not wrapped bytable-spyunless replaced by an executable backend.
On this page
Created February 22, 2026
Updated February 22, 2026