A set of commands to manipulate a postfix sqlite database. Supports adding users, domains and aliases and creating the DB schema.
-
Clone the repository
$ git clone https://github.com/bkutil/postlite.git ~/.postlite
-
Make sure
~/.postlite/bin
is in your$PATH
(use.bashrc
on Debian/Ubuntu and.zshrc
for ZSH):$ echo 'export PATH="$HOME/.postlite/bin:$PATH"' >> ~/.bash_profile
-
Add
postlite init
to your shell to enable autocompletion.$ echo 'eval "$(postlite init -)"' >> ~/.bash_profile
-
Restart the shell
-
Create
~/.postliterc
and configure path to your Postfix sqlite DB:POSTLITE_DB=/etc/postfix/postfix.db
-
Run
postlite db init
to create the database and schema
Sqlite3 command line client needs to be installed.
doveadm pw
is used to hash/prompt for user passwords.
Postfix needs to be configured to use following virtual maps via main.cf
:
sqlite-virtual-alias-maps.cf
dbpath = /etc/postfix/postfix.db
query = SELECT destination FROM virtual_aliases WHERE source='%s'
sqlite-virtual-mailbox-domains.cf
dbpath = /etc/postfix/postfix.db
query = SELECT 1 FROM virtual_domains WHERE name='%s'
sqlite-virtual-mailbox-maps.cf
dbpath = /etc/postfix/postfix.db
query = SELECT 1 FROM virtual_users WHERE email='%s'
Dovecot needs to be configured to use sqlite as it's backend and use this password query:
dovecot-sql.conf.ext
driver = sqlite
connect = /etc/postfix/postfix.db
default_pass_scheme = SHA512-CRYPT
password_query = \
SELECT email as user, password \
FROM virtual_users WHERE email = '%u'