Skip to content

Self-host Mail

Send yourself a test message on your machine before changing where your domain receives mail.

Try Mail locally

Install the published package with Bun and use the binary for your operating system and processor. The example uses Apple silicon. It runs webmail on a loopback address with a disposable mailbox.

mkdir mail-local
cd mail-local
bun init -y
bun add --exact @stacksjs/mail@0.3.26
export MAIL_BIN="$PWD/node_modules/@stacksjs/mail/bin/mail-aarch64-macos"
mkdir data
cd data
printf 'Choose a password for this local mailbox: '
read -r -s MAIL_PASSWORD
printf '\n'
"$MAIL_BIN" user:local create you@example.test "$MAIL_PASSWORD" you@example.test
unset MAIL_PASSWORD
SMTP_HOSTNAME=mail.example.test SMTP_LOCAL_DOMAINS=example.test \
SMTP_ENABLE_WEBMAIL=true SMTP_WEBMAIL_PORT=8080 \
SMTP_WEBMAIL_TLS=false SMTP_WEBMAIL_SECURE_COOKIES=false \
IMAP_ENABLED=false CALDAV_ENABLED=false SUBMISSION_PORT=25870 \
"$MAIL_BIN" serve --host 127.0.0.1 --port 2525 --disable-tls --enable-auth

Open localhost:8080/login and sign in as you@example.test. Send a message to that same address. It should appear in Inbox and Sent.

This setup uses HTTP on your machine and keeps IMAP and CalDAV off. Calendar is part of the release preview.

Set up your domain

Use a domain you control and a host that can receive SMTP. Set up TLS and delivery, create the mailboxes you’ll need, and verify your SPF, DKIM, and DMARC records.

Decide who can administer the server and where to store backups. Keep your existing mailbox while you test sending, receiving, and restoring mail. Change your live MX records after those checks pass.

Read the deployment guide

Read the operator runbook

Moving an existing mailbox

Try a test address first. The release candidate includes an IMAP importer that can preview a transfer and resume an interrupted copy. It also includes an operator export with Maildir messages, ICS calendars, and vCards for contacts.

See the export format