Stalwart Email server

I’ve recently build my own email server. I’ve chosen stalwart, it’s an all in one email system (Imap,JMAP,SMTP,Antispam…). Here is how I’ve done it :

  • First create a letsencrypt certificate, i’ve already done it using the dns method.
  • Then lauch the install script in root.
curl --proto '=https' --tlsv1.2 -sSf | sudo sh
Welcome to the Stalwart Mail Server installer

? Which components would you like to install? ›
❯ All-in-one mail server (JMAP + IMAP + SMTP)
  JMAP server
  IMAP server
  SMTP server

I select all-in-one and then accept the default parameters :

  • Sqlite
  • Local disk using Maildir
  • Create a new database for accounts

I then configure the domain name : and the server hostname

? Where is the TLS certificate for '' located? (/etc/letsencrypt/live/ ›
? Where is the TLS private key for '' located? (/etc/letsencrypt/live/ ›

I’ll give the script my letsencrypt certificate and private key created before executing the script. Then it will create a dkim key and ask to add some fields info in my dns configuration, it will also create an admin account and password that i’ll note on a text file.

A quick review of the configuration files in /opt/stalwart-mail/etc/ to be sure and I’m good to go.

systemctl enable stalwart-mail

Now the mail server is running, I can check that with the following command :

systemctl status stalwart-mail

If needed I can restart, reload … by using systemctl.

To add a user on the mail server, I’ll have to simply add it to the database and he’ll be ready right away.

I create my test account :

#create a password "test"
root@Courriel:# openssl passwd -6 test
#create a user test with the password "test"
root@Courriel:# sqlite3 /opt/stalwart-mail/data/accounts.sqlite3 

SQLite version 3.40.1 2022-12-28 14:03:47
Enter ".help" for usage hints.
sqlite> INSERT INTO accounts (name, secret, description, type) VALUES ('test', '$6$6MG6WjMQjPkOdnkI$FdiJqIL1KnDc9J9kaZ/1ZMo8e/Jrom0kUrBTqG7mBxBfgnp4x5JAFKUby8vI6BwGRGfHi7iKX.r8L0LrHDXxe0', 'Test User', 'individual');
sqlite> INSERT INTO emails (name, address, type) VALUES ('test', '', 'primary');

My first user is created and active. If I need to modify something i’ll use the sqlite database and modify the values. For example if I need to delete the user :

root@Courriel:# sqlite3 /opt/stalwart-mail/data/accounts.sqlite3

SQLite version 3.40.1 2022-12-28 14:03:47
Enter ".help" for usage hints.
sqlite> DELETE FROM accounts WHERE name = 'test';
sqlite> DELETE FROM emails WHERE name = 'test';

Change the password :

sqlite> UPDATE accounts SET secret = 'mynewpassword' WHERE name = 'test';
sqlite> SELECT * FROM accounts WHERE name = 'test';
test|mynewpassword|Test User|individual|0|1

Modifying a database to update user accounts is a breathe.

The users email are stored in the /opt/stalwart-mail/data/blobs/emails directory. Directory 0 is user 0 email folder, directory 1 is user 1 email folder and so on.

Stalwart mail is really easy to use, with one software I can have an email server up and running without having to install one software for smtp (ex : Opensmtp, postfix…), One software for Imap (Ex: Dovecot…), one spam filter…

To know more about Stalwart Email go to their website :



501 Words

2023-10-31 15:27 +0100