Skip to content
项目

关于

Self-hosted email client for several IMAP mailboxes: conversations, full-text search, rules, contacts, tasks, multi-user and OpenID Connect sign-in, in one container

效率与自动化

这些数字如何统计

实测星标增长

24小时
正在收集历史
7天
正在收集历史
15天
正在收集历史
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文
nexmail

nexmail

A self-hosted email client. One container, one file, your mailboxes stay with you.

Report an issue

nexmail: folder column, message list and reading pane

nexmail brings several IMAP mailboxes together in one place and runs on your own machine. It is meant for people who already host things at home: one container, a single SQLite file, no second database, no cloud account, and no service that gets to see your mail on the way.

Roundcube is webmail bolted onto one mailbox. Thunderbird does not run in a browser. Commercial clients want to pull your mail onto their servers. nexmail is the third option — and if you can use Outlook, you should feel at home.

Version 0.39.4. It reads, writes, searches, sorts, labels, sends, schedules, prints, answers for you while you are away, keeps a calendar and your address books in sync with iCloud or Google, invites people to your own appointments, rephrases a draft with an AI service of your choice, connects with nextasks, nextime and nexpaper in one click, attaches photos from your Immich, lets an AI program work with your mail over MCP if you allow it, backs itself up and reaches you when the browser is closed, on the desktop and on the phone. It is used daily by its author against real iCloud and IMAP mailboxes, and more than 2,000 automated tests watch over it, including more than 190 that drive a real browser against a real mailbox. It is still young: try it on a mailbox you can afford to have trouble with before you point it at the one that matters.

The screenshots below show a throwaway instance filled with invented mail. Every address in them is under example.com, example.org or example.net, which RFC 2606 reserves for exactly this purpose.

What it does

Mail. Several mailboxes side by side, plus a merged All inboxes view. Read, reply, reply-all, forward, move, archive, delete, mark, flag, undo. Drag and drop between folders. Keyboard: Del to trash, E to archive, and Ctrl+K jumps to the search field, and Ctrl+Shift+P opens a command palette that finds every action and folder. Which folder is the trash or the archive nexmail reads from the server's SPECIAL-USE flags and from the usual names; where a server has neither, right-click the folder and pick Use as (on a phone: the … next to the folder). Folders created or removed elsewhere show up with the next sync.

Reading pane, or not. A button next to the search field switches between three layouts: the reading pane to the right of the list, or no reading pane at all, with a message opening either in place of the list or in a window above it. Without the pane the list gets the full width, a click only selects, and a double-click or Enter opens. What opens after you delete, archive or move the open message is up to you, as in Outlook: nothing, the next message, the previous one or the newest (Settings, Appearance).

A face for every sender. Each row and the open message start with a round picture: the contact's photo from your address book, otherwise the sender's brand logo, otherwise their initials. Brand logos follow BIMI as strictly as Apple Mail does and are off by default (Settings, Appearance, Load company logos). A logo appears only when the message passed your provider's sender check, the domain enforces DMARC, and it publishes a mark certificate that chains up to a known BIMI issuer; the logo is taken from the certificate itself. The server looks each domain up once a week, your browser never contacts the sender. Most senders publish no BIMI record and get initials, and messages synced before 0.20.0 carry no sender check and never get a logo.

On the phone. A layout of its own rather than a squeezed desktop: list, then message, with the folders in a drawer. Swipe a row to archive or delete, long-press to select several and act on them from a bar within thumb reach. The calendar shows the month with a dot per calendar and the day's events below it, or the month as a running list.

As the computer's mail app. Installed as a web app from Chrome or Edge, nexmail can be picked as the default mail program in Windows (Settings → Apps → Default apps → MAILTO) or on Linux (KDE: System Settings → Default Applications → Email client). A mailto: link anywhere on the computer then opens a new message in nexmail, sent from your first mailbox.

The iPhone and iPad app. nexmail has a native app that pairs with your server by QR code and talks to it under /api/app/1, a surface of its own that does not break when the server is updated. Besides reading, writing and sorting mail, the app can look after signatures (pictures included), text templates, folders (rename, delete, Use as) and tags, make a rule from a message, add a sender to your contacts and show your profile picture. Setting up mailboxes, users and backups stays in the browser. Each of these ways applies to your own account only, and the server names what it offers, so an older server and a newer app (or the other way round) simply show less.

Photos from Immich. Once the operator has entered the address of the household's Immich and everyone has connected their own account with an API key of their own, the paperclip offers From Immich: pick several photos from the timeline, New in Immich, your albums or a search, as JPEGs for mail or as the original, and they become attachments like files from your device. The picture button in the toolbar puts them into the text instead. Every picture in the text can be sized by its corners, and the recipient sees it at that size. Immich is off until the operator switches it on (Server › Connections › Immich).

Folders and subfolders. Folders with subfolders start folded; the arrow in front opens them, Alt-click opens every level below, and a folded folder counts the unread mail beneath it. A folder's menu folds or unfolds a whole mailbox at once. What is open and which mailboxes are folded is saved with your account, so it stays after signing out and in every browser. Prefer everything open? Switch off Collapse subfolders under My account › Appearance.

Conversations. Related messages fold into one row — matched by the reply chain first, subject only as a fallback and only when sender, subject and a 30-day window all agree. Off by default: grouping wrongly hides a message, and you notice that at the worst possible moment.

Writing. A real formatting toolbar (Tiptap), attachments you can drop onto the window, pasted or dropped images inside the text, drafts stored in the mailbox rather than in the browser, and an outbox that survives a restart. Recipients become address bubbles as you type; nonsense turns red instead of hiding inside a comma list. Set importance, get a question when the text mentions an attachment that is not there, and forward a message as an untouched .eml when someone needs the real thing.

Send later, take it back. Schedule a message for this evening, tomorrow morning or any moment; it waits in nexmail's own outbox, visibly, and cancelling files it as a draft. Undo send holds every outgoing message for a few configurable seconds first — undo brings it straight back into the compose window.

The compose window with its formatting toolbar

Search. Full-text over everything cached, plus IMAP SEARCH at the provider on request. The interface says how far it looked — a search that hides its own reach lets you conclude a message does not exist.

Search results, with a line saying which part was covered

Tasks. Turn a message into a task, tick it off, drag it into order, give it a due date. The task survives its message: if the mail is moved from your phone, the task follows it by Message-ID; if the mail is deleted, the task stays and says so. Each user can connect their own Todoist account under Settings › My account › Connections and send tasks to a Todoist list instead. Only the title, the due date, the sender and a link back to the mail go there, never the text of the mail. Ticking a task in nexmail closes it in Todoist, and what you complete, reschedule or delete in Todoist comes back within a few minutes. The same works with a self-hosted nextasks, connected in one click (see Connecting other nex apps); then pick a list, with its space and section. nexmail sends each message at most once (nextasks' external_ref), and sees completed, reopened, rescheduled and binned tasks within a few minutes. A nextasks that cannot connect by click yet is connected by the operator by hand, with its address and an API key that may read and write (made in nextasks under Settings › My account › Connections › API keys); nexmail checks the key against /api/v1/me before it saves anything, and Change key keeps your tasks connected when the key is replaced. Such a nextasks on your local network needs the operator's permission under Settings › Server › General › Features for every account, as webhooks and calendars do. With nextasks connected, the task view goes further: its spaces and lists appear in the sidebar with their symbols, read live from nextasks (nothing is copied), and you can tick off, edit, move and add tasks there, also without a mail; you choose in the nextasks card which lists nexmail shows. nexmail's own task list can be switched off once a to-do app is connected, and its open tasks can move to your default list. For tools of your own there is a webhook target: nexmail posts each task as signed JSON to an address you choose (see Webhooks for tasks).

Contacts, rules, signatures. An address book with several numbers, addresses and postal addresses per contact, the card's photo, vCard import and export and collection from Sent; connected CardDAV address books (iCloud, Google or any other CardDAV server) that are read and written back line by line, with a question instead of an overwrite when a card changed on both sides, and a vCard file can be imported straight into one of them; contact groups that expand into their members when picked as a recipient; rules that run after each sync and only on new mail, can move, mark, flag and tag, can be run once over a folder that is already full, and can be started from a message with a right-click (Create rule); signatures per mailbox, with pictures such as a logo, sent inline with the mail.

Housekeeping. Trash and junk can empty themselves after a number of days — off by default, measured by how long a message has been in the folder, and never touching a folder you created yourself. Printing produces a clean document and goes straight to the print dialog. On a phone, swiping a row archives or deletes, with the same undo as everywhere else.

Tasks Contacts
The task list The address book

Mailbox groups. Tag mailboxes (personal, work, club) and switch between them above the folder tree.

Labels. Colour a message Important, Work, Later. They are stored as IMAP keywords on the server, not in nexmail's database, so they outlive nexmail and show up in Thunderbird and on your phone. Labels another client set appear here too, with a name and a colour of their own.

Snooze. Park a message until this evening, tomorrow or next week. It moves into a real folder on the server (named Wiedervorlage there, shown as Snooze in the English interface) and comes back when it is due — visible from every other client, not a note that only nexmail knows.

Text templates. The paragraphs you write again and again, kept once and dropped into a message from the compose window.

Out of office. Per mailbox, with a period and a plain-text note. Every sender gets it at most once; mailing lists, other automated systems and delivery failures never get one, and mail that arrived before you left is not answered retroactively. You can see who received one. Note that nexmail can only answer while nexmail itself is running — your provider can usually do this on the mail server, independently of it.

Meeting invitations. An .ics shows up as a card rather than an unopenable attachment: title, time in your own time zone, place, organiser. Accept, tentative or decline goes back as a proper reply, and nexmail remembers what you answered. Add to calendar is a separate button on purpose: saying yes tells the organiser you are coming, it does not mean you want the entry.

Your own invitations. Put people on one of your events and nexmail asks whether to send the invitation — it never goes out by itself, not when you save and not when you change something later. Their answers come back into the attendee list as they arrive, so you can see who is coming without leaving the app. Delete the event and it offers to tell them; without that the appointment would stay in their calendars and they would turn up.

Calendar. Month, week and day, with your own calendars in nexmail or connected over CalDAV to iCloud, Nextcloud or anything else that speaks it. With a self-hosted nextime, one click under Settings › My account › Connections brings all its calendars, in its groups and colours, read live (see Connecting other nex apps); invitations are accepted into a nextime calendar in one step, and Turn into event makes an event from any mail. A nextime from 0.2.0 that cannot connect by click yet is connected by the operator by hand, with its address and an API key. A calendar server on your own network or VPN is refused until the operator allows it under Settings › Server › General › Features for every account; the same switch covers address books and subscribed calendars. Google works too, through the same consent you gave for the mailbox. Recurring events are stored once and worked out for the window on screen, so a every Monday does not fill the database to the year 2031; this one, this and following, all is asked the way every calendar asks it, because the format leaves no other answer. A published .ics link can be subscribed to read-only. A calendar can be downloaded as an .ics file and events read back in from one, so moving in or out does not mean retyping anything; events that are already there are skipped, so reading the same file twice is safe. What nexmail does not understand in a foreign event travels through untouched: alarms, attendees and a dozen X-APPLE- properties come back out the way they came in.

Reminders live on the event as a VALARM, so what you set here also goes off on your phone. They reach you through the browser as well, with nexmail closed — see Notifications below.

Notifications. nexmail can reach you with the browser closed: an event reminder that falls due, and mail the sync actually just fetched. Every device grants permission for itself; what you get notified about belongs to your account and is the same everywhere. New mail is announced after the rules have run, so a message a rule just filed into junk does not claim to be in your inbox — and a mailbox's very first sync announces nothing, because at that point every message is new. Quiet hours drop notifications rather than deferring them: a reminder delivered at seven in the morning for an event at eleven last night is not a reminder. On a phone this needs the site on the home screen; iOS delivers nothing to an ordinary tab, and says nothing about why.

Google and Microsoft mailboxes. Both providers stopped accepting a password for IMAP and SMTP, so nexmail signs in with OAuth. Two levels, kept apart on purpose: the operator registers one app with the provider, every user gives consent for their own mailbox. No secret ships with nexmail — the repository is public, and both providers revoke a key they find in one, so each operator registers their own. The Server section of the settings says so plainly rather than letting you guess why nothing works.

Rephrasing with AI, if you want it. The operator decides under Settings › Server › AI provider who sets the AI service up: one service for everybody, entered there, or each account its own under Settings › My account › AI (an address, a key and a model). An installation from before 0.35 stays with the second. nexmail knows no provider; anything that speaks the common chat completions interface (the OpenAI form) or Anthropic's Messages form works, from Claude, Gemini or OpenAI to Ollama on a machine in your own network. The operator's service may lie in your own network; an account's own access reaches a computer there only when the operator lists it (one already in use before 0.35 is listed by itself), never a link-local or cloud metadata address, and no redirect is followed. Limits per person and minute, per person and day and for the whole server keep the bill in check. A service in your own network is asked not to think (reasoning_effort: "none"), so a thinking model such as Qwen3 or DeepSeek-R1 does not spend a short answer on its thoughts; a server that does not know the field is asked once more without it. In the editor it fixes spelling, translates, or rephrases in one of nine tones, and shows old and new side by side before anything is replaced. Quotes and your signature are never sent, and that page lists verbatim what went out. Off by default, and the operator can block it for the whole installation or for single accounts.

Received mail, only if you allow it. With the same service, a button in the reading pane summarises or translates a message you received, or answers a question about it, and a reply can start from a suggested draft. All of that sends text somebody else wrote to your AI provider, so it is a decision of its own: the operator has a separate switch for received mail, each user has one more, and nothing goes out until you click. What went out then appears verbatim in the same list as everything else. Answers are shown as plain text and labelled as what they are, because a message can try to talk the model into saying something else. A suggested reply is plain text too, leaves what it cannot know in square brackets, and only reaches your draft when you apply it.

Unsubscribing. A message that names a way off its mailing list gets a button below the sender, and a question first that says who is about to hear from you. If the sender offers one-click unsubscribing (RFC 8058) and the message passed your provider's sender check, nexmail's server sends the request. Otherwise the sender's page opens in a new tab, or a prepared message waits in the compose window for you to send. In the junk folder there is no button: unsubscribing there tells a spammer the address is read. Messages opened before this feature existed keep what they had; the next one from the list has the button.

New mail right away. An open window now follows what the server fetched, so the list updates by itself. By default that happens with the regular sync, every two minutes. Turn on See new mail right away for a mailbox and nexmail keeps a second connection open (IMAP IDLE), and a new message shows up within seconds. It is off by default because some providers limit connections; if the server cannot do IDLE, the form says so and the regular sync carries on.

Moving between mailboxes. Drag a message onto a folder of another account, or right-click it, Move, and pick one. MOVE and COPY only work inside one connection, so this fetches, appends at the target, checks that it really arrived, and only then deletes at the source. That order is the whole safety: the worst case is a message that exists twice, which you can see and clean up. A selection may span mailboxes and folders, as in All inboxes or a search: Del puts every message into the trash of its own mailbox, Archive into its own archive, and undo brings them all back.

Moving in and out. Import a Thunderbird mbox, or download a folder as mbox or as a ZIP of .eml files. What is already there is skipped by Message-ID, so an interrupted import can simply be repeated. Read and flagged state travels both ways.

HTML mail, defused. Server-side sanitising with an allow-list, images unhooked until you ask for them, and an iframe sandbox without scripts. The same sanitising runs on what you write, on the way out.

When you do ask for the images, nexmail's server fetches them, your browser never does. The sender learns that the message was opened, which is the price of seeing the pictures in any client, but not your address, your browser or anything else about you. Allow a sender for good with one click, or switch the asking off entirely under Appearance. Addresses inside your own network are refused: a message pointing at http://192.168.x.x/reset would otherwise make the server a remote control for your home network.

What it is not

  • No PGP or S/MIME. Key management is a project of its own, and half-built encryption is worse than none.
  • No Microsoft calendar. Microsoft speaks no CalDAV; events there need the Graph API, which is a client of its own. Mail through IMAP and SMTP works.
  • No out-of-office reply while nexmail is down. It answers only when the container runs. Your provider can usually do this on the server instead, independently of nexmail.

Built with

FastAPI · SQLAlchemy · SQLite · React · Vite · Tailwind CSS · Tiptap · IMAPClient

One container. SQLite instead of Postgres is not a shortcut here, it is a feature: no second container, no database credentials, and a backup is a copy.

Running with Docker

services:
  nexmail:
    image: ghcr.io/derkezorm/nexmail:latest
    container_name: nexmail
    restart: unless-stopped
    ports:
      - "5174:8000"
    volumes:
      - ./data:/data
    environment:
      PUID: 1000
      PGID: 1000
docker compose up -d

Then open http://<server>:5174. On first run you create the operator account: display name, username, an optional email address and a password. The page asks for a setup code first: it is in the server's log (docker logs nexmail) at every start while there is no account, or you set your own with NEXMAIL_SETUP_TOKEN (at least 16 characters). The same code is needed to restore a backup before the setup. After that, this route is closed and nexmail never asks for the code again.

Locked out? If the only operator forgot the password and there is no mail server for a reset link, make a link on the server itself:

docker exec -it nexmail python -m app.notfall reset-link <username or email>

It prints a link that sets a new password, once, valid for a day.

The full compose file with every option and the reasoning behind each one is docker-compose.yml in this repository.

Your mailbox credentials

nexmail asks for them in its own interface and nowhere else. You add mailboxes under Settings › Mail › Mailboxes. They are stored encrypted and never leave your server.

The mailbox list under Settings

For iCloud you need an app-specific password from account.apple.com. Your normal Apple password is refused, and iCloud reports that with the same message it uses for a typo. nexmail says so in the connection test, so you do not spend ten minutes doubting your password.

What to back up

Everything is under /data:

nexmail.db mailboxes, messages, contacts, rules, sessions
secret.key the key to every stored mailbox password
blobs/ attachments, stored by checksum

⚠️ secret.key and the database belong together. Without the key the database is unreadable. With both, whoever holds them holds your mailboxes.

Backup and restore

Under Settings › Server › Storage and backups. At the top you see how much space nexmail takes; below is one list of backups.

Backups in the list are complete copies next to the database: on a schedule (every night, week or month at a time you pick), by hand whenever you want, before every restore, and automatically when an update adds or rebuilds a table (not for a mere new column or index). They are for a failed update or a contact deleted by mistake. If the disk dies, they die with it.

Downloading one gives you an encrypted ZIP with a password of its own, and deliberately without the messages. Those are still in the mailbox on the server, and nexmail fetches them back after a restore. Measured on a real database: 1890 messages turn 0.36 MB into 2.79 MB, and the part that cannot be fetched again does not grow with the mailbox. An archive that grows with your mail is one nobody downloads. Upload it on another server and it joins the list. Back up now takes an optional note, and a downloaded archive tells its date, kind and note once its password is entered.

Restoring checks first: it reports the version, whether the key is included, and whether the public address in the archive differs from the one you are using. The restore window then asks whether the address from the backup should apply; without the tick the current one stays. It has to ask, because invitation links and the OpenID Connect redirect are built from it, and the redirect URI registered with your provider is something nexmail cannot change for you, so the check names it for each provider.

⚠️ Put /data on a local disk, never on an SMB or NFS share. That is the one way SQLite genuinely loses data: its locking does not work reliably over network filesystems. On a NAS, use a path on the internal volume.

Behind a reverse proxy

Set NEXMAIL_URL_BASE=/nexmail and nexmail runs under https://example.org/nexmail. It answers every address twice — with and without the prefix — because proxies are configured both ways.

Set NEXMAIL_COOKIE_SECURE to match your setup. auto (the default) marks the session cookie Secure when the request arrived over HTTPS. Use on only if a proxy terminates TLS and forwards plain HTTP internally — and never if nexmail should also be reachable over http://, because the browser discards a Secure cookie sent over http and then nobody gets in.

Trusted proxies. NEXMAIL_CLIENT_IP=proxy (or proxy:2 for two proxies in a row) tells nexmail that a reverse proxy sits in front. Only then does it believe the proxy's headers: the client address in X-Forwarded-For (for the sign-in brake) and the scheme in X-Forwarded-Proto (the rightmost value, http or https). That scheme decides the redirect address for a sign-in provider while no public address is set, and Secure on the session cookie with NEXMAIL_COOKIE_SECURE=auto. Left empty (the default) or direct, nexmail takes neither header from anyone. This is the setting the authentik card means when it warns that the server sees another scheme than your browser.

Notifications on the iPhone. Apple's push key cannot ship in a public image, so the iPhone app gets its notifications through a small relay at https://push.nexapps.dev. Sender, subject and the start of the mail are encrypted for the device before they leave your server; the relay sees a ticket, that ciphertext and the number for the app icon. NEXMAIL_PUSH_RELAY points to another relay. Set it empty and nothing goes there, and the app offers no notifications.

Signing in through an external provider

nexmail speaks OpenID Connect: authentik, Microsoft Entra ID, Keycloak, Authelia, Pocket ID and anything else that follows the spec. Everything lives under Settings › Server › Sign-in, in three cards:

  1. Sign-in. Sign-in with a password can be switched off once a provider is active; then the sign-in page shows only the provider buttons. You as the operator can always sign in with your password (a small link on the sign-in page), so a provider that fails never locks you out. The public address is the address people use to reach nexmail, base path included; invitations, providers and links in mails use it.
  2. Sign-in providers. Add a provider by hand: name on the button, a short name (part of the redirect address, fixed once saved), the issuer, client ID and secret. The redirect address to register with the provider is shown with a copy button: <public address>/api/oidc/<short name>/callback. Saving asks the provider's discovery document first; an issuer that calls itself something else is refused at the field. Changing the issuer of a provider asks first and then drops its links, because another issuer is another provider. Removing one tells you how many accounts lose their link.
  3. authentik in one step. Enter the address of your authentik and a one-time API token that may create applications. nexmail creates the signing key, provider and application in authentik and adds itself as a provider; the steps are listed with a reason if one fails. The token is used for these calls only and never stored. If you would rather not hand over a token, download the blueprint instead and import it in authentik. Without a public address the card suggests the one your browser uses and stores it before anything is registered.

Each provider has two more switches: New people get an account (off by default: only invited people and linked accounts come in) and The provider checks the second factor itself (on by default; switched off, an account with its own second factor is asked for the code after the provider, as after the password).

Microsoft Entra ID works with a single tenant (https://login.microsoftonline.com/<tenant ID>/v2.0) as well as with common or organizations. Entra only sends an email address as an optional claim; nexmail does not need one.

The sign-in tab with one registered provider

Who comes in:

  1. An existing link. You create it while signed in, under Settings › My account › Security › Sign-in providers; your password confirms it. The operator sees the links in the account list and can remove one, with their own password.
  2. An invitation. On the invitation page, Continue with … takes the invitation key along (in the request body, never in an address). The new account is named after the person at the provider, keeps the display name and contact address from the invitation, and the invitation is spent.
  3. New people, only where a provider has New people get an account on.

⚠️ No email address opens anything, not even an invitation. Matching by address would be the place where a provider claiming an address it does not own could open somebody else's account; in authentik, for instance, users can change their own address. A person is known by provider and subject only.

⚠️ Providers set up in nexmail 0.21 keep their redirect address /api/oidc/<short name>/zurueck; you do not have to change anything at the provider. New providers use /api/oidc/<short name>/callback. Under a sub path (NEXMAIL_URL_BASE) the stored public address stays without the prefix, as in 0.21, and nexmail adds the prefix itself, so the redirect address stays the same and going back to 0.21 keeps working. An address saved with the prefix is stored without it.

⚠️ The issuer must be one address that both the browser and the server can reach. The browser fetches the sign-in page; the container fetches the discovery document and the token. If you run the provider in the same Docker network, enter it under the address the browser knows, not its container name.

Several people

Invite them under Settings › Server › Accounts: an email address and a display name, both optional, and how long the link holds (1, 7 or 30 days). The person invited picks their own username. With an outgoing mail server of its own under Settings › Server › Mail nexmail sends the invitation itself — deliberately not the operator's mailbox, so that removing that mailbox does not take the invitations with it. Without one, nexmail shows the link for you to pass on.

The invitation page offers both ways: set a password, or accept it through a provider. Not everyone has an account with your identity provider, and not everyone should need a password they will never use.

People sign in with their username or their email address. Everyone changes their own display name, username and address in their profile (username and address with their password; a new address counts once its confirmation link was opened, when there is a mail server). Old usernames stay reserved for ever.

A forgotten password has two ways back: a link by mail to the account's own address (one hour, with a mail server), or a link the operator makes under Accounts (1, 7 or 30 days), sent by mail or shown to pass on. A new password signs out every browser; the iPhone app and API keys keep working, and the next sign-in lists them with Disconnect all.

Under Accounts each row has Manage. Any account can be made an operator, so there can be several; nexmail always keeps at least one who can sign in. Block keeps somebody out without deleting anything: while an account is blocked, nexmail syncs none of its mailboxes, calendars, address books or to-do apps and sends it no notifications, and AI programs connected over MCP are disconnected. Unblock and everything goes on. Deleting an account asks for your own password and leaves 30 days to bring it back; it gets no mail in that time. Whether an account may use the AI is set there too.

Languages. German and English are built in. The operator adds more under Settings › Server › General › Languages as a JSON file of texts (at most 512 KB); a template with the English texts can be downloaded there, covering the shared cards such as Devices, Log and Backups as well, and whatever a file leaves out falls back to English. A language added this way can be picked in the profile and on the sign-in page.

Server settings with users and open invitations

Every user has their own mailboxes, contacts, rules and signatures. A guard test walks the entire route table and checks that no address answers without authentication and none hands out another user's data.

Connecting other nex apps

nexmail works together with three other self-hosted nex apps: nextasks for tasks, nextime for calendars and nexpaper for documents. Connecting one takes a click, not an API key.

For everybody. Under Settings › My account › Connections › Other nex apps, click Connect with nextasks (or nextime, or nexpaper). The other app opens, shows who you are signed in as there and says in plain words what each app gets from the other. Agree once, and you are back in nexmail. A connection gets only what it needs, never "read everything": in nextasks you choose which spaces nexmail sees, in nexpaper which vaults it may store into. The card then shows since when you are connected, when the connection was last used and what it may do, with Check now and Disconnect, which ends both directions; what you created stays in both apps. If something goes wrong in the other app, you land back in the card and read there what happened.

App nexmail may there What you do with it in nexmail
nextasks read tasks, create and change them, tick them off, see the members of your spaces Turn into task puts a mail into a nextasks list; its spaces and lists stand in the sidebar of the tasks, where you tick off, edit and add tasks and pick who is responsible
nextime read your calendars and events, create, change and delete events, answer invitations its calendars in nexmail's calendar, events created, changed and deleted there, invitations accepted straight into a nextime calendar, Turn into event from any mail
nexpaper put documents into its inbox Send to nexpaper as a document next to every attachment; if nexmail may store into more than one vault, a small window asks which, the one used last chosen

nextasks and nextime worked with nexmail before, over an API key typed in by hand. Those connections keep working as they are, and the card lets you renew them the new way; after that the connection keeps itself fresh, and nobody types a key again.

For the operator. Under Settings › Server › Connections › Other nex apps, enter the address of each app once; from then on every account only clicks Connect. Until then the card tells people the app is not set up here, and shows you a link to that place. An app at an address in your own network (LAN, VPN) needs Connections into the local network ticked there; without it the error says exactly that. The switch Connections with other nex apps turns it all off: nobody connects anew, existing connections rest, nothing is deleted. The other app needs a release that can connect this way; if it cannot yet, the card says so, and you can still connect nextasks and nextime by hand with an address and an API key.

Dashboards: read-only API keys

A dashboard such as nexdeck can show how many unread messages are waiting and, if you allow it, sender and subject of the latest ones. It reads them with an API key that each user creates for their own mailboxes under Settings › My account › Connections.

Off by default. API keys are a way out of nexmail, so the operator decides whether they exist on an installation at all, with a switch under Settings › Server › Connections › Interfaces. Turning it off stops every key immediately; no key is deleted.

Each key has two limits, set when it is created. It sees only the mailboxes ticked on it, and it has one of two scopes: count only, or count, sender and subject. The text of a message is never available through a key. Keys are stored as hashes and shown once; revoking one takes effect on the next request.

All addresses answer JSON and expect the key as Authorization: Bearer nxm_…. A browser session does not open them, and a key opens nothing else. Only the task addresses write, each only with its own option on the key: May tick off tasks for complete and reopen, May tag messages for tags. Both are meant for the receiver of a webhook.

Address Returns
GET /api/v1/me owner, key name, scope (count or headers), tasks (whether the key may tick off tasks), tags (whether it may tag messages), the mailboxes the key may see
GET /api/v1/summary unread messages in the inbox, in total and per mailbox, with status ok or sign_in_failed
GET /api/v1/messages/latest sender, subject, date and read state of the newest inbox messages; needs scope headers. Optional: mailbox=<id> (repeatable), limit=1..20 (default 5), unread_only=true
POST /api/v1/tasks/{id}/complete ticks off a task from one of the key's mailboxes; returns id, external_id, title, done, completed_at
POST /api/v1/tasks/{id}/reopen reopens it; same answer
GET /api/v1/tags the owner's tags with id, name and keyword; needs May tag messages
GET /api/v1/tasks/{id}/tags the tags on the message of a task, as task_id and tags
POST /api/v1/tasks/{id}/tags/{tag_id} adds a tag to the message of a task on the mail server; returns the tags afterwards
DELETE /api/v1/tasks/{id}/tags/{tag_id} removes it; same answer

Errors come as {"detail": "<code>"}: api_schluessel_fehlt and api_schluessel_ungueltig (401), api_schluessel_abgeschaltet, api_schluessel_nur_anzahl, api_schluessel_ohne_aufgaben and api_schluessel_ohne_schlagworte (403), postfach_unbekannt, aufgabe_unbekannt and schlagwort_unbekannt (404), aufgabe_ohne_mail (409), schlagworte_nicht_unterstuetzt (400, the mail server takes no keywords in that folder) and 502 when the mail server cannot be reached. Counts are as fresh as nexmail's last sync with the mail server.

AI tools (MCP)

An AI program such as Claude Code works with a person's mail through MCP at POST /api/mcp. Off by default: the operator switches MCP access on under Settings › Server › Connections › Interfaces, and decides there whether programs may connect themselves, the highest level and which tools are blocked. An account the operator does not allow AI makes no MCP key, and its keys and programs rest until AI is allowed again.

Each person sets it up under Settings › My account › Connections › AI tools (MCP): either Connect in the program (OAuth with PKCE, the person agrees on nexmail's page) or an MCP key made by hand (nxk_…). Either way it sees only the mailboxes chosen for it, at one of three levels: read, read and drafts, read, drafts and change. Nothing is ever sent: a draft lands in the mailbox's Drafts folder. The text of a message needs the extra Read mail text (off by default); attachments never leave nexmail. Rights can be set per tool to allow, ask or deny; a call that asks waits up to 24 hours for a yes, and the person's browsers are told.

Tool Level Does
mailbox_summary read unread messages in the inbox of each mailbox
search_messages read messages by sender, subject, date and folder, never by their text
read_message read, with Read mail text a message with its text, without attachments
list_tags, list_tasks read the person's tags, the tasks made from messages
draft_reply, create_draft drafts a reply or a new message as a draft
set_tags, move_message, complete_task change on the mail server, as in the app
mark_read, trash_messages change read or unread, or into the trash (not for good, optionally marked as read first), on the mail server

Webhooks for tasks

Under Settings › My account › Connections each user can connect a webhook next to Todoist. It then shows up as a list in Turn into task, and nexmail sends the task as a POST with a JSON body to your address. Before it saves the webhook, nexmail sends a ping and keeps the address only if it answers with 2xx; Send test does the same later and shows the status code if it does not.

What arrives. task.created when a message becomes a task, task.completed and task.reopened when it is ticked or unticked in nexmail, and ping.

{
  "event": "task.created",
  "sent_at": "2026-11-03T08:15:00Z",
  "task": {
    "id": "42",
    "external_id": null,
    "title": "Order confirmation",
    "due_date": "2026-11-10",
    "completed_at": null
  },
  "message": {
    "message_id": "<[email protected]>",
    "subject": "Order confirmation",
    "from": "[email protected]",
    "from_name": "Supplier",
    "date": "2026-11-03T08:12:00Z",
    "mailbox": "Work",
    "mailbox_address": "[email protected]",
    "link": "https://nexmail.example.org/?mail=%3Cabc123%40example.org%3E",
    "tags": [{ "id": 3, "name": "Work", "keyword": "Work" }]
  }
}

task.completed and task.reopened carry the same task and only message_id, link and tags under message; tags is null there if the message is no longer in nexmail. If your endpoint answers task.created with JSON such as {"id": "T-17", "url": "https://…"}, nexmail keeps both: the id comes back as external_id in later events, and the url becomes the link to the task in nexmail.

The text of the message (text, html, text_truncated under message) is only sent if the user turns it on for the webhook and the operator allows it under Settings › Server › General › Features for every account. It is off by default, because on a shared installation any user can enter any address. html is the cleaned HTML nexmail shows itself, without scripts; very long messages are cut, and text_truncated says so.

The signature. Every request carries X-Nexmail-Signature: sha256=<hex>, an HMAC-SHA256 over <X-Nexmail-Timestamp>.<raw body> with the webhook's secret. The secret is shown once when you connect; leave the field empty and nexmail creates one. Check the signature against the raw body and reject old timestamps, so a recorded request cannot be replayed. In Python:

import hashlib, hmac, time

def valid(secret: str, headers, body: bytes) -> bool:
    stamp = headers["X-Nexmail-Timestamp"]
    if abs(time.time() - int(stamp)) > 300:
        return False
    expected = hmac.new(secret.encode(), stamp.encode() + b"." + body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(headers["X-Nexmail-Signature"], f"sha256={expected}")

X-Nexmail-Event names the event, X-Nexmail-Delivery is a random ID per request.

Who owns the checkbox. A webhook cannot be asked what happened, so by default the task stays in nexmail and nexmail owns the checkbox. Two ways to change that:

  • Send only: nexmail sends task.created and keeps no task of its own. The message still remembers where it went, so a second click does not send it again.
  • Report back: create an API key with May tick off tasks for the same mailboxes and call POST /api/v1/tasks/{id}/complete or /reopen with the task.id from the payload. Such a change is not sent back to the webhook.

Tags. An API key with May tag messages can list the user's tags and add or remove them on the message of a task, for example a Done tag when the task is ticked off in your tool. Tags are IMAP keywords, so this writes to the mail server, the same way as tagging in nexmail does, and every copy of the message in that mailbox gets it.

  • GET /api/v1/tags returns {"tags": [{"id": 3, "name": "Done", "keyword": "Done"}]}. Use the id: it stays when a tag is renamed, and a name with accents does not have to go into the URL.
  • GET /api/v1/tasks/{id}/tags returns the tags on the message now.
  • POST /api/v1/tasks/{id}/tags/{tag_id} adds one, DELETE removes it. Both answer with the tags afterwards, as {"task_id": "42", "tags": [...]}.

A task whose message is gone answers 409 with aufgabe_ohne_mail; a key without the option gets 403. Tag changes send no event to the webhook.

Addresses. Only http and https, no credentials in the URL, and redirects are not followed. Addresses on the local network work only after the operator allows them under Settings › Server › General › Features for every account (the same switch as for calendar servers). localhost never works: inside the container it is nexmail itself. If your tool runs on the same host as the nexmail container, use the host's address on your network, for example http://10.0.0.20:8080/hook.

Security, honestly

Two-factor is available and optional. TOTP with replay protection, ten single-use recovery codes, and a per-user switch — including for the operator. On a purely local network it is reasonable to leave it off; reachable from the internet it is not, and nexmail says so where you make the choice. The operator can require a second factor of everybody under Settings › Server › Sign-in; whoever has none sets it up at the next sign-in. Passkeys (over https) sign in without password or code and count as a second factor; the operator can switch them off. A lost phone is handled by the operator, who resets that account's second factor under Accounts.

Sessions live on the server, not in a token. That costs one query per request and buys sign out everywhere with immediate effect. Devices are listed and can be revoked individually. Stay signed in keeps a browser signed in for 30 days of use; without it, the sign-in ends with the browser. A sign-in from a browser nexmail does not know yet sends you a mail, which you can switch off.

The security tab with two-factor and signed-in devices

Passwords use Argon2id, sign-ins are rate-limited, and a spent recovery code stays spent. Ten wrong passwords lock an account for 15 minutes; a browser that has signed in to it before is exempt, so a stranger guessing cannot lock you out.

What two factors cannot do — plainly. Mailbox passwords must be decryptable on disk, because syncing runs while nobody is signed in. The key sits in /data/secret.key. Whoever has file access has your mailboxes, and no login changes that. Setting NEXMAIL_SECRET_KEY moves the key out of the data directory, which is the one effective lever: a stolen backup alone is then worthless.

One question goes out by itself: whether a newer version is out. Once a day, when an operator opens Settings › About nexmail, nexmail asks GitHub for the newest release, without names, contents, settings or its own version, and never through a proxy from the environment. The setup asks once whether to do this; the operator switches it on the About page, where Check now works either way. Members see their version and nothing of the check. NEXMAIL_UPDATE_URL points the question elsewhere.

Development

# Backend
cd backend && python -m venv .venv && .venv/bin/pip install -r requirements.txt
NEXMAIL_DATA_DIR=../data-dev .venv/bin/python -m uvicorn app.main:app --reload --port 8010

# Frontend
cd frontend && npm install && npm run dev
cd backend && python -m pytest        # server, no mailbox needed
cd frontend && npm test               # Vitest, no browser
cd frontend && npm run test:ui        # Playwright, two viewports

The interface tests run in a real browser against a real IMAP mailbox. That is why they prove anything — jsdom would not have found a single one of the layout and rendering faults they were written for.

They only start the Vite server, though. Whatever answers on port 8010 is what they measure, and a backend left running from yesterday will report faults the code no longer has. Check data-dev/logs/nexmail.log for the last is ready line before you believe a red run, or point the proxy elsewhere with NEXMAIL_API=http://127.0.0.1:8011 npm run dev.

Licence

GNU Affero General Public License v3.0. Third-party licences, including the bundled fonts, are listed in THIRD-PARTY.md.

探索相关项目

加载中…