Here is a complete answer to your questions.
Required MySQL/MariaDB Schema
The docs provide an official reference schema for MySQL/MariaDB. You need three tables:
CREATE TABLE accounts (
name VARCHAR(32) PRIMARY KEY,
secret VARCHAR(1024),
description VARCHAR(1024),
type VARCHAR(32) NOT NULL,
active BOOLEAN DEFAULT 1
);
CREATE TABLE group_members (
name VARCHAR(32) NOT NULL,
member_of VARCHAR(32) NOT NULL,
PRIMARY KEY (name, member_of)
);
CREATE TABLE emails (
name VARCHAR(32) NOT NULL,
address VARCHAR(128) NOT NULL,
type VARCHAR(32),
PRIMARY KEY (name, address)
);
What Values Are Expected in Each Column
accounts.type (the “mailtype” equivalent) must be one of:
individual (or person) – a regular mailbox user
group – a group/distribution account
accounts.secret must be a hashed password in a supported format. You can generate a SHA-512 crypt hash with:
openssl passwd -6
emails.type should be primary for the main address, or alias for aliases.
Column Mappings (for custom schemas)
The default queries expect these column names: name, secret, description, type. If your table uses different column names, you can override the mappings on the Directory object:
columnEmail (default: "name")
columnSecret (default: "secret")
columnClass (default: "type") – this is the individual/group field
columnDescription (default: "description")
Inserting a Test User
INSERT INTO accounts (name, secret, description, type)
VALUES ('john', '<HASHED_SECRET>', 'John Doe', 'individual');
INSERT INTO emails (name, address, type)
VALUES ('john', '[email protected]', 'primary');
Troubleshooting: Enabling Trace-Level Logging
debug level may not show SQL query details. For authentication troubleshooting, the docs specifically recommend setting the log level to trace, which provides a granular view of authentication operations. You can adjust the tracer’s level field to trace in the WebUI under Settings > Telemetry > Tracers.
The full SQL backend documentation is at: SQL Database | Stalwart
This is an automated reply from the Stalwart Help Bot. Other community members may follow up if this answer is incomplete or wrong.