TeaNode · Documentation · Source
This walks through standing up a mail server for one domain, from nothing to mail arriving and being forwarded. It takes about twenty minutes, most of it waiting for DNS.
You need three things:
Read this before you rent a host. Most consumer ISPs, and a good number of cloud providers, block outbound port 25 by default — DigitalOcean, Google Cloud, Azure and Oracle Cloud all do, and Amazon EC2 does until you ask.
Inbound port 25 is usually fine. Outbound is what gets blocked, and without it this server can receive mail and cannot deliver it — so forwarding fails while everything looks healthy.
Check before you commit:
nc -vz gmail-smtp-in.l.google.com 25
If that hangs or is refused, you have three options: ask the provider to lift
the block, pick one that does not have it, or set smtp.socks5Proxy to route
outbound mail through a host that can reach port 25.
curl -L -o /usr/local/bin/teanode-server \
https://github.com/ziyan/teanode/releases/latest/download/teanode-server-linux-amd64
curl -L -o /usr/local/bin/teanode \
https://github.com/ziyan/teanode/releases/latest/download/teanode-linux-amd64
chmod +x /usr/local/bin/teanode-server /usr/local/bin/teanode
teanode-server is the server, with the dashboard inside it, so there is
nothing else to install or serve. teanode is the client that administers it,
and belongs on the server and on your own machine; there is a macOS build of
it.
There is a container image too, with both binaries in it, and that is the better way to run this: see reference/deployment.md, which replaces steps 1 and 2 here. The rest of this page — DNS, claiming the dashboard — applies either way.
Configuration lives in PostgreSQL. The environment says how to reach it, and — the first time the server starts against an empty one — what kind of server to create.
mkdir -p /opt/teanode && cd /opt/teanode
teanode-server config env --output .env \
--hostname mail.example.com \
--domain example.com
--hostname is the name of this server. It is what the server announces in
SMTP and what your MX record will point at, so it must be a name you can add a
DNS record for.
--domain is the domain whose mail you want to receive. It becomes the first
domain this server serves.
Open .env and set TEANODE_DATABASE_URL to your PostgreSQL, and
TEANODE_TLS_ACME_EMAIL to an address the certificate authority can warn
about expiry. Then set the database up:
set -a; . ./.env; set +a
teanode-server config init
That runs the migrations and stores the configuration. It generates a DKIM signing key for the domain and a server secret, both of which live in the database from now on — so the database is the thing to back up.
After this the .env is only read for where the database is: settings change
in the dashboard, and the server logs any first-run variable that disagrees
with what is stored.
If this deployment already ran on a teanode.yaml, load it instead of
creating something new. Identifiers, signing keys, the server secret and the
session key all come across unchanged, so stored mail still resolves, SMTP
passwords still work, and nobody is signed out:
teanode-server config import --file /opt/teanode/teanode.yaml
Ask the server what to publish:
teanode dkim show example.com
You need four records. The first is the only one that decides whether mail arrives at all; the rest decide whether it is trusted.
| Type | Name | Value |
|---|---|---|
| A | mail.example.com |
your server's address |
| MX | example.com |
10 mail.example.com |
| TXT | example.com |
v=spf1 mx -all |
| TXT | teanode1._domainkey.example.com |
what dkim show printed |
A word on each:
mx1 and mx2, so you can move the server later without every
domain changing its DNS — list them under server.mailServers and the
dashboard will ask each domain for both.v=spf1 mx -all says "the hosts in my MX record send my mail, and
nobody else does". If something else sends as this domain — a newsletter
service, a CRM — add it here or that mail starts failing.Once mail is flowing, add a fifth:
TXT _dmarc.example.com v=DMARC1; p=none; rua=mailto:rua@mail.example.com
p=none asks nobody to reject anything; it only asks for reports, which the
server parses and shows you. Move to p=quarantine and then p=reject once
the reports show your own mail passing.
teanode-server config validate
teanode-server run
On the first start the server obtains a certificate over HTTP-01, which needs port 80 reachable from the internet. If it is not, that is the first thing the log will tell you.
The image runs as uid 65532 now, not root, with only CAP_NET_BIND_SERVICE to
bind the low ports. If your data directory was created by an earlier
version it is owned by root, and the server will fail to read it. Once, before
starting the new image:
chown -R 65532:65532 /opt/teanode/data/teanode
Open https://mail.example.com/. The first visitor creates the only account,
so do this immediately — before the server has been reachable long enough for
anybody else to find it. If you would rather not race:
teanode user add you
The dashboard lists exactly which DNS records are still missing or wrong, per domain, so you can see what is left rather than guessing. It checks periodically; there is no need to reload it.
There is no password reset by mail; the server's own host is the way back in. On it, with the server's environment in the shell — which a container already has — the client reaches the server as the console and can add an account or set a password:
teanode user create you
teanode user password you
docker compose exec teanode teanode user create you # in a container
When the server is not running, or is running but nobody can sign in and the
console cannot reach it either, teanode-server user edits the stored
configuration directly and needs only the database:
teanode-server user list
teanode-server user add you
teanode-server user password you
teanode-server user reset removes every account, after which the next
visitor to the dashboard creates one, as on the first day. Anyone who can
reach the dashboard can claim it until somebody does, so do not leave it in
that state.
The account you make this way is an administrator with a mailbox of its own,
called Personal. The web UI opens on it: the folders in the rail, a
folder's messages beside the one being read. The management pages — every
message the server handled, the queue, reports, domains, the server itself —
are under /manage, behind Manage at the foot of the rail, and Back to
mailbox at the top brings you back. Your own settings, the mailbox's among
them, are under /settings, behind your name at the foot of the rail.
The Inbox and Starred, every flagged message wherever it sits, stay at the top of the rail; hover any other folder for a pin that puts it up beside them. The search box looks in the open folder, or in the whole mailbox with sender, recipient, subject, date and attachment filters behind More. Contacts, kept from whoever you write to, have a page of their own in the rail, beside the calendar, what your agent knows and your finances.
A mailbox receives nothing until an address points at it. On the domain's
Aliases tab, add one with the kind Deliver into a mailbox and pick
yours: the pattern ^you$ makes you@example.com yours. The same tab is
where hello@example.com forwards elsewhere, so a domain can do both.
Send a message to you@example.com from an account elsewhere. Within a few
seconds it is in your Inbox, unread, with the count in the rail and in the
tab's title. Open it, and Reply: the reply leaves from you@example.com,
signed with the domain's key, and a copy sits in Sent.
A message to hello@example.com shows up in the management side's mail
list instead, with SPF, DKIM and DMARC verdicts for the sender and a delivery
attempt to the address you set as --forward-to.
If it does not arrive, the queue page says why. The usual causes, in order of how often they are the answer:
dig MX example.com.nc -vz mail.example.com 25.Mail programs speak IMAP, which the server serves on port 993 once
listen.imaps is set — the compose file publishes it, and the server
settings page's Listeners tab is where it is turned on for a server that
predates it. A program signs in with your address and an app password:
make one on Mailbox settings → Mail programs, name it for the device, and
type the password shown into the program. It is shown once. The same tab
lists what the program will ask for — the incoming server, the outgoing
server on port 587, and the username — and most programs find those on their
own from the address.
If others use this server, a household or a few friends, put them in a
circle. Open Circles from the account menu at the foot of the rail,
make one called what it is (Family, say), and add the people. Someone who
already has an account is invited by username and joins when they accept.
Someone who has none is added with Make an account for someone: give a
username, a name and a first password, and they are in the circle at once,
with nothing to accept. They sign in with that username and password and can
change the password themselves under Settings → Change password. On the
command line a circle is made with teanode circle create --kind family Family (--kind is required: family, friends or colleagues), and the
account is one step: teanode user create --circle <circle-id> personb
prompts for the first password, and --stdin reads it from standard input
instead (teanode user create --stdin --circle <circle-id> personb). That
command takes only a username; the name other people see is set afterwards
with teanode user update personb --name "Person B", and until then they see
the username.
Once you share a circle with someone you can message each other. Chats are in the agent's drawer: start one with New conversation, beside its search box, then Message someone. Every circle has a chat of its own.
^(sales|support)$ is one alias. An empty pattern is a catch-all that
receives whatever nothing else matched. Several aliases can deliver into
one mailbox, and a mailbox can send as any of its addresses.teanode photo upload <folder>, or turn on Photo backup in the phone
app's settings to send the phone's whole library in the background. The
phone apps only sign in over https (plain http is accepted only for
loopback, which a phone cannot reach), so a server reached at
http://localhost or a local address needs a TLS address first (see
"Photos and the iPhone app" in reference/deployment.md). Deleting a photo
on the phone leaves it here. A photo with no place, or the wrong one, is
given a city with Change location in its details on the dashboard or
the phone, for one photo or several chosen at once. The cities come with
the server, so there is no map service to set up. A library is large: put
the storage
(storage.directory, or the S3 bucket) on a disk with room for it, and back
it up with the database. Manage → Server → Setup turns it off, or turns
on Calendar, Contacts and the rest; the page says what starts after a
restart and has a Restart now button.<selector>._domainkey at the primary
domain with a CNAME and the dashboard will show you the record to publish.Every document is also plain markdown, listed in /llms.txt.