Skip to content

Per-domain SMTP gateway management (ORM, REST, CLI) - #96

Open
gott-alexander wants to merge 5 commits into
grommunio:masterfrom
gott-alexander:feature/per-domain-smtp-gateway
Open

Per-domain SMTP gateway management (ORM, REST, CLI)#96
gott-alexander wants to merge 5 commits into
grommunio:masterfrom
gott-alexander:feature/per-domain-smtp-gateway

Conversation

@gott-alexander

@gott-alexander gott-alexander commented Sep 3, 2026

Copy link
Copy Markdown

Summary

Adds management of per-domain outbound SMTP gateways (smart-hosts): an ORM
model mirroring the domain_smtp_gateway table, REST endpoints and a CLI
command. The table itself is created by gromox's dbop (schema version 134);
this repository only reads and writes it.

Changes

  • orm/domain_smtp_gateway.py (new): DomainSmtpGateway model — mirror of
    the dbop table, including validation of the encryption values and the
    port range. Any schema change here must be reflected in gromox's
    lib/dbop_mysql.cpp and vice versa.
  • endpoints/domain/smtp_gateway.py (new):
    GET/PUT/DELETE /api/v1/domains/<ID>/smtpGateway, guarded by
    DomainAdmin (write) / DomainAdminRO (read) permissions. The GET response
    censors the password and reports a passwordSet flag instead; a PUT
    with an empty password keeps the stored one (usual password-field UX),
    so credentials never need to be sent back to the client.
  • cli/domain_smtp_gateway.py (new): grommunio-admin domain smtp-gateway set/show/delete/list — same operations for the shell,
    with the password masked in show.
  • res/openapi.yaml: schemas and endpoints documented.
  • cli/domain.py, endpoints/domain/__init__.py, orm/__init__.py:
    registration of the new modules.

No service restarts are triggered on changes: the consumer of the table
(the MTA) evaluates it live.

Verification

Built against the official spec; PUT/GET/DELETE round-trip including the
password-keep behaviour, rejection of invalid encryption values and port
ranges (400), permission checks, and CLI set/show/list/delete against a
test database.

Alexander and others added 5 commits September 3, 2026 13:24
Adds the grommunio-admin API surface for the per-domain SMTP-gateway
table that gromox reads at SMTP delivery time.

Changes:

  * New SQL migration `sql/001-domain-smtp-gateway.sql` that creates
    the `domain_smtp_gateway` table (one row per domain) and an
    index on `enabled`. Compatible with MariaDB 10.5+ and MySQL 8+.
  * New ORM model `orm.domain_smtp_gateway.DomainSmtpGateway`
    registered in `orm/__init__.py`.
  * New REST endpoint mounted at
    `GET    /api/v1/domains/<id>/smtpGateway`
    `PUT    /api/v1/domains/<id>/smtpGateway`
    `DELETE /api/v1/domains/<id>/smtpGateway`
    The endpoint re-emits the gromox config-reload signal so the
    lookup table is picked up without restarting the daemons.
  * New CLI subcommand
    `grommunio-admin domain smtp-gateway {set,show,delete,list}`
    for headless configuration. Passwords are masked in `show` and
    `list` output.
  * OpenAPI 3 spec updated: `/domains/{domainID}/smtpGateway` path,
    `domainSmtpGateway` / `domainSmtpGatewayWrite` schemas.
  * `res/openapi.json` regenerated from `openapi.yaml`.

Companion changes: grommunio/gromox#<PR> (service registry +
`cu_send_mail` integration) and grommunio/admin-web#<PR>
(SMTP-gateway tab in the domain details).
The domain_smtp_gateway table is now created by gromox's dbop module
(schema version 134, lib/dbop_mysql.cpp), both on fresh installs
(gromox-dbop -C) and upgrades (gromox-dbop -U / mysql_adaptor
schema_upgrade). The standalone SQL file and its ORM docstring
reference are therefore obsolete.
Nothing consumes the from_address column anymore: outbound smart-host
routing (and any envelope rewriting) is the MTA's job, which evaluates
the domain_smtp_gateway table directly (see doc/mta-smart-hosts.rst in
gromox). Drop the column from the ORM, CLI, API docs and endpoint
documentation so the UI does not offer a field without effect.
The MTA evaluates domain_smtp_gateway live, so no service restart is
needed after changes; reload_gromox() only caused pointless
gromox-delivery restarts. Also drop unused imports and update
comments that still described the removed in-gromox delivery hook
(resolve_smtp_url_for_sender) and the outgoing_smtp_url fallback.
@gott-alexander gott-alexander changed the title Per-domain SMTP gateway (smart-host) configuration Per-domain SMTP gateway management (ORM, REST, CLI) Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant