Skip to content

Instantly share code, notes, and snippets.

@oal
Created November 27, 2013 17:12
Show Gist options
  • Save oal/7679396 to your computer and use it in GitHub Desktop.
Save oal/7679396 to your computer and use it in GitHub Desktop.
Schema and configuration example for using SQLite with OpenSMTPD.
# sqlite.conf
dbpath /mail/mail.db
query_alias select value from aliases where key=?;
query_domain select domain from domains where domain=?;
query_userinfo select uid, gid, directory from users where user=?;
query_credentials select key, value from credentials where key=?;
query_netaddr select value from netaddr where value=?;
# In smtpd.conf, define your tables like this, then use it just like any other table:
table domains sqlite:/mail/sqlite.conf
# SQLite schema:
CREATE TABLE "aliases" (
"key" TEXT,
"value" TEXT
);
CREATE TABLE "users" (
"user" TEXT,
"uid" INTEGER,
"gid" INTEGER,
"directory" TEXT
);
CREATE TABLE "credentials" (
"key" TEXT,
"value" TEXT
);
CREATE TABLE "netaddr" (
"value" TEXT
);
CREATE TABLE domains (
"domain" TEXT
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment