Gmail · local Skadi · Njord on hail
Your mail, ready
when the link returns.
Njord prepares mail while a client-supplied credential remains valid in RAM. Skadi reads a local mailbox while its worker exchanges headers, downloads and outgoing mail over separate authenticated connections. A dropped connection preserves completed items and partial transfers.
Development setup. These instructions require the persistent-service source build containing njord-client. The currently published 0.1.0 packages contain the earlier forwarding relay. This page does not announce a new binary release.
In Skadi, choose Main Menu → Setup → Google Account (S, then G) for a guided walkthrough with terminal-clickable browser links. It covers personal Gmail and Google Workspace addresses, direct IMAP or Njord, and OAuth or app passwords where permitted. Use N for the next step, B to go back, and Tab/Enter to select and open links. App-password setup saves your account settings directly from a masked form. OAuth has its own walkthrough.
Quick setup with an app password
In Skadi, press S, then G. Choose Gmail or Workspace, choose Direct IMAP or your Njord relay, then App password. There are three pages:
- Open Gmail and sign in to the mailbox you want to connect.
- Create an app password named Skadi and copy it.
- Enter it in Skadi. Press N to open the form, enter your full email address and paste the app password. For Njord, paste the installer’s provisioning token when prompted. Confirm Save as default account.
Skadi updates the Inbox, sending server, From address, and local sent-mail and postponed-message folders for you. You do not need to edit the config file. Spaces in Google’s displayed password are accepted. Open your Inbox to connect; cancelling the form leaves your existing settings unchanged.
For a hosted domain, enter your complete address, such as you@your-company.example. For Njord, obtain a separate provisioning token for each installation. The form enrolls this computer and saves its connection settings automatically. An existing enrolled profile does not ask for the token again.
If Google does not offer app passwords
Enable 2-Step Verification. Some managed accounts and Advanced Protection settings do not allow app passwords; use the OAuth walkthrough or ask your administrator. See Google’s app-password instructions if needed.
Where Skadi saves the password
Direct IMAP saves each account’s password in a mode-600 file under ~/.skadi/google/, inside private mode-700 directories. Skadi uses it only for verified TLS connections to Google’s IMAP and SMTP servers. It is separate from ~/.pinerc.
With Njord, Skadi saves ~/.njord/PROFILE/credentials.json locally with mode 600. The local worker supplies the password over mutually authenticated TLS; Njord caches it only in RAM for a renewable lease. The local cache_seconds setting defaults to 3600. App passwords remain long-lived credentials at Google; OAuth uses temporary access tokens instead.
1. Install the current source build
Build Skadi locally and Njord on hail. Njord needs C++17, OpenSSL with TLS 1.3, libevent, zstd, librsync, libcurl 8.22 or newer, WebP, SQLite with JSON support, and the nlohmann JSON headers. Skadi also needs SQLite, zstd, WebP and Alpine’s normal build dependencies. Python is only needed to run tests.
# macOS dependencies
brew install pkgconf openssl@3 openssl@4 libevent zstd librsync curl webp sqlite nlohmann-json ncurses
# Linux development packages (check the installed libcurl version)
sudo apt install build-essential pkg-config libssl-dev libevent-dev libzstd-dev \
librsync-dev libcurl4-openssl-dev libwebp-dev libsqlite3-dev nlohmann-json3-dev libncurses-dev
# In your Skadi checkout, configure for your platform, then:
make -j1 c-client.d c-client
make -C pith
make -C pico
make -C alpine
make -C njord install PREFIX="$HOME/.local"
install -m 755 alpine/alpine "$HOME/.local/bin/skadi"
export PATH="$HOME/.local/bin:$PATH"
On macOS, configure Skadi with ./configure --without-ldap --without-krb5 --without-tcl --disable-nls --with-ssl-dir="$(brew --prefix openssl@3)". On Linux, use your normal ./configure options. A distribution with an older libcurl needs an updated curl development package or a separate curl build; the service checks this before fetching mail.
2. Let Skadi prepare your Njord setup
In Skadi, choose Setup → Njord Setup (S, J), then Server hostname. Enter the Njord server’s hostname, such as njord.goblinreactor.com. You can enter user@host when SSH needs a different login name. Enter the email identifying your Njord account, or an existing account ID. Google setup prefills this email; you can change it if your Njord account uses a different address. Enter an installation description, such as laptop or tablet.
Skadi shows the complete command with your hostname, Njord account identity and installation description filled in. Press C to copy it if your terminal allows clipboard writes. Run it in another terminal, or give it to your installer. For example:
ssh -t -- njord.goblinreactor.com 'sudo njord-provision create --email you@your-domain.example --name laptop --server https://njord.goblinreactor.com:1143'
The token comes from njord-provision on the server. SSH and sudo may prompt for authentication. The installer handles that command and the copy-and-paste step; Skadi does not run SSH. Use ssh HOST 'COMMAND' syntax: SSH’s -c selects ciphers, not the remote command. The generated command uses -t so sudo can prompt in a terminal.
Copy the entire output line beginning NJORD1., return to Skadi and press N to paste it into the hidden token field. Skadi writes your chosen hostname into ~/.njord/default/config.json as https://HOST:1143, verifies that server’s TLS certificate, generates a local device key and saves the certificate paths. You do not need to edit JSON or configuration files. An SSH username is used only in the command, never in the saved mail-server address.
If you already have a token, choose Paste Token (T) to skip the hostname and command instructions. Skadi uses the token’s address for a new profile, or preserves the previously chosen address when retrying the same enrollment. Google setup also offers these choices when enrollment is needed.
The same screen contains a clickable guide link and commands for managing installations. On hail, these commands are:
sudo njord-provision list
sudo njord-provision revoke DEVICE-ID-FROM-LIST
Repeat setup on the tablet to get its own token and key. --email finds or creates the Njord account identified by that email. An installer can still use --account ACCOUNT-ID to select an account explicitly.
Each token enrolls one installation. Laptop and tablet have different keys and device IDs but share the same Njord account. Revoking one device leaves the other authorized. Revocation also cancels an unused token. A token normally expires after 24 hours; the installer can set --expires-in SECONDS. The device remains enrolled after its token expires. If setup is interrupted, paste the same token on the same installation to resume. Keep the token private until enrollment; anyone holding an unused token can claim that installation.
njord-provision defaults to /etc/njord/server.json; use --config /absolute/path/server.json for another installation. Run it as the service user or root. --email automatically selects or creates the Njord account identity (--gmail remains a compatibility alias). If several account IDs use the same identity email, specify --account to choose one. Account additions become available without restarting Njord. Other providers use an account already configured by the installer.
Njord stores device names, account bindings, token hashes, expiration/redemption/revocation times and enrolled public keys in STATE/provisioning.db, using SQLite. On hail that is /var/lib/njord/provisioning.db. Its mailbox table stores each Njord account’s separate mailbox identities and nonsecret provider paths. Raw tokens, device private keys and Google credentials are not stored there. Back up this database with the server state using a consistent SQLite backup or with the service stopped. Do not copy a client’s private profile between devices; issue another token.
A future commercial website can issue these same tokens. The client enrollment flow will stay the same. Mail and enrollment use TLS directly on TCP 1143; Skadi does not launch SSH. The installer’s trusted token supplies server trust, and all mail routes require an enrolled device key.
3. OAuth with Njord
Google refresh credentials belong to the client. Skadi’s local worker renews access tokens and supplies temporary access tokens over the mutually authenticated connection. Njord holds them only in RAM, scoped to your enrolled account; it does not store refresh tokens, client secrets, passwords or access tokens in its configuration, database, spool or logs. A restart clears the cache. When a token expires, provider operations wait for the client; already-prepared mail remains downloadable.
In Skadi choose Main Menu → Setup → Google Account (S, G), choose Gmail or Workspace, then Njord relay → OAuth. The walkthrough links each Google page and provides a local credential form. These steps use your own OAuth application and Google’s token-import flow:
- Open Google Cloud Console and select or create your project.
- Complete Branding, set your Audience, and configure Data Access with
https://mail.google.com/, the IMAP/SMTP mail scope. External apps in Testing normally issue mail refresh tokens that expire after seven days; ongoing use needs an appropriate production or internal configuration. - On Clients, create a Web application for this token-import flow. Add exactly
https://developers.google.com/oauthplaygroundas an authorized redirect URI, without a trailing slash. Copy its client ID and client secret. The separate direct-IMAP walkthrough uses a Desktop client. - Open Google OAuth Playground. In settings select Use your own OAuth credentials, enter your client ID and secret, keep Google endpoints and Server-side flow, and select Offline access and Consent Screen. Using your own credentials avoids the Playground’s default 24-hour refresh-token revocation.
- In Step 1 enter
https://mail.google.com/, choose Authorize APIs, and sign in to the correct mailbox. In Step 2 choose Exchange authorization code for tokens. Copy the refresh token. - Back in Skadi’s Authorize Njord step, press U for Local Creds. Enter your full email address, the Njord provisioning token if not already enrolled, client ID, client secret, and refresh token. Secret fields are hidden and accept long tokens without truncation. Confirm the local save; cancelling preserves existing credentials.
The form saves ~/.njord/default-google-MAILBOX-HASH/credentials.json locally with mode 600. It is separate from the relay connection configuration and is never uploaded to Njord. The local worker reads changes automatically and saves rotated refresh tokens locally. Each mailbox gets its own private file; the hash is derived from its full email address. For manual configuration, the file has this form:
{
"user": "you@gmail.com",
"oauth": {
"client_id": "YOUR-OAUTH-CLIENT-ID",
"client_secret": "YOUR-OAUTH-CLIENT-SECRET",
"refresh_token": "YOUR-OFFLINE-REFRESH-TOKEN"
}
}
4. Start the authenticated service on hail
On hail, ~/.config/njord/gmail.json contains only account and provider settings, never Google credentials:
{
"user": "you@gmail.com",
"imap": "imaps://imap.gmail.com:993",
"smtp": "smtps://smtp.gmail.com:465",
"folders": ["INBOX"],
"prefetch": "text",
"poll_seconds": 30
}
The service rejects account files containing oauth, password, access_token, refresh_token or client_secret. Remove old server-side credentials before upgrading. prefetch: "text" prepares unnamed text parts while a client-supplied credential is valid; "headers" prepares metadata and "bodies" also prepares complete messages.
For a new server, generate its identity once with njord-keygen server "$HOME/.config/njord/keys" njord.example.com. Keep an existing server’s identity unchanged. The CA signing key can remain offline; token enrollment does not use it. Create ~/.config/njord/server.json. Replace every /home/YOU with the real absolute home directory of Njord’s service account; JSON paths do not expand ~ or environment variables.
{
"listen": "0.0.0.0",
"port": 1143,
"public_url": "https://njord.example.com:1143",
"state": "/home/YOU/.local/share/njord",
"certificate": "/home/YOU/.config/njord/keys/server.crt",
"private_key": "/home/YOU/.config/njord/keys/server.key",
"client_ca": "/home/YOU/.config/njord/keys/ca.crt",
"authorized_keys": "/home/YOU/.config/njord/authorized.json",
"accounts": {"gmail": "/home/YOU/.config/njord/gmail.json"}
}
chmod 600 "$HOME/.config/njord/"*.json
printf '{}\n' > "$HOME/.config/njord/authorized.json"
njord --service "$HOME/.config/njord/server.json"
Start the service before issuing tokens so its state directory exists. Then use njord-provision --config "$HOME/.config/njord/server.json" create --account gmail --name laptop. Setting public_url saves repeating --server. If the server uses a different certificate authority from its legacy client CA, set server_ca to the PEM trust bundle clients should use. New client certificates are self-signed and authenticated by their enrolled public-key fingerprints. Existing CA-signed devices and the legacy --authorize/--revoke registry remain supported.
Run the service under a dedicated unprivileged Linux account. Point your chosen public hostname at the address accepting connections, allow inbound TCP 1143, and forward it to hail’s TCP port 1143 if needed. Use raw TCP forwarding so Njord handles TLS and client-certificate authentication directly. The server certificate must cover the hostname in the client URL. Keep the state directory private. Back up server state, nonsecret account configuration and enrollment material together; back up Google refresh credentials separately on the client. Njord can read prepared mail and use the temporary credential while it is cached, so the operator is still trusted with that access. Revoking the supplying device invalidates its cached provider credential.
For unattended operation, install the supplied packaging/systemd/njord.service after adapting its user, paths and writable state directory, then enable it with systemd. The package does not enable a listener automatically.
5. Open the local mailbox in Skadi
Token enrollment saves the private connection profile automatically. Google setup stores provider credentials separately in ~/.njord/default-google-MAILBOX-HASH/credentials.json. Opening the Njord Inbox starts the background worker. For diagnostics, run njord-client --profile PROFILE status, using the mailbox profile from its #njord#PROFILE/INBOX path. Advanced users can enroll a named profile with njord-client --profile NAME enroll, supplying a JSON object with a token field on standard input. Do not put tokens in command arguments or shell history. Existing profiles for another device are not overwritten; choose a new profile if replacing an enrollment. A server field in the enrollment form supplies the user’s chosen HTTPS address. Changing the address for the same device requires the same trusted CA and successful TLS verification; unrelated profile settings are preserved.
Both the app-password and Njord OAuth forms write the mailbox settings automatically. Run Setup → Google Account once for each Google address. One enrolled installation can use both a personal Gmail account and a Workspace account, regardless of the email identifying the Njord account. Skadi keeps their credentials, caches, downloads and outgoing queues separate and lists both in Incoming Folders.
On the Main Menu, press I for Inboxes. With multiple incoming accounts, Skadi shows Choose an Account: use the arrow keys and Enter to open a mailbox. Press M to return to the Main Menu, then I to switch accounts. Google setup refreshes this list as soon as you save; existing configurations also get the chooser automatically. Selecting an account does not rewrite your configuration. A single account opens directly.
Read and compose from the selected mailbox’s address. Adding another mailbox reuses this installation’s key. A different computer needs its own token and key, even when registered with the same Njord email; label each device during setup so njord-provision list and revoke DEVICE-ID identify the right one.
Local sent-mail and postponed-message folders keep composing independent of the network. Explicit per-role SMTP overrides still use the selected SMTP server. Opening a Njord mailbox starts its background worker automatically; an already-running worker is reused.
Read and compose normally. Headers arrive independently. Press K in the index to queue selected complete messages. Inspect attachment sizes with [. Opening an uncached part or explicitly activating an HTTPS image queues it; reopen it when Skadi reports that content is ready. Image previews use WebP when it reduces size; originals are separate requests.
Sending reports queued locally for Njord after the local spool is durable. njord-client status distinguishes local, queued, accepted, failed and uncertain submissions. Accepted means Gmail accepted SMTP delivery, not that the recipient has read it. If a connection or crash loses the final SMTP reply, Njord stops automatic retries of that message to avoid duplicates. Check Gmail’s Sent folder before explicitly running njord-client retry JOB-ID.
What survives a dropped connection?
Each message or attachment has an immutable compressed object, its own checksum and its own completion point. Transfers use zstd level 22 with rsyncable boundaries. One batch request includes the saved offset of every queued body or attachment, and the server streams their remaining bytes without a round trip per item. The worker resumes an unchanged partial object at its saved byte offset; librsync can repair a changed or damaged local basis, and interrupted delta transfers have their own checkpoint. A new arrival does not change an older object’s identity. Each complete header frame is committed immediately, even if the rest of that response is interrupted.
Headers, bulk downloads and outgoing mail use separate persistent TLS connections, so a large attachment does not hold up a new subject or an outgoing message. The daemon can continue after Skadi closes. Stop it when ending a metered session; leaving it running continues polling. Set a larger client poll_seconds to reduce idle traffic. No real Iridium or Globalstar throughput measurements are claimed yet.
Direct IMAP remains available by selecting {imap.gmail.com:993/ssl/user=you@gmail.com}INBOX and configuring Gmail authentication in Skadi. The older /njord mailbox option selects the forwarding relay, not the persistent service described here. Use the #njord#PROFILE/INBOX path written by setup with njord --service.
Current mailbox operations include reading, queued system flags and UID-specific expunge where the provider supports it. Server-side folder creation, copy/move and appending into Njord folders are not implemented in this development path. The client reports unsupported operations rather than pretending they succeeded.