Managing organisations, servers and keys
Organisations, their members, mail servers, domains, DKIM keys and credentials are managed in the admin interface (see The admin pages below and Sign-in and access). Everything can also be done from a remote console on a running node, which this page shows as well:
docker exec -it <container> /app/bin/karta remote # a release
iex -S mix # development
Every function below returns {:ok, record} or {:error, changeset}
(unless noted), so mistakes are reported, not raised. Once a server has an
API key with the credentials:write scope, further credentials can be made
over the Karta API, and the suppression list is
managed over every API.
The admin pages
After signing in, / lists the organisations you belong to (all of them
for an instance administrator, who also creates organisations there). The
sidebar leads through the levels you are in: the organisations, and
for an instance administrator the instance's IP pools and Warm-up
plans; an organisation's overview, domains, members and reports; a mail server's
overview, messages, received mail, credentials, routes, endpoints,
webhooks, suppressions and settings. The bar at the top shows the way back
(the breadcrumbs), your address (to your account page) and Sign out;
on a narrow screen the sidebar opens from the menu button. Every page
shows what your role lets you see, and every action on it is checked
again, on the server, against your role at that moment; a page you may not
see answers 404. The pages follow the browser's light or dark colour
scheme. Values to publish or to keep (tokens, DNS records, new keys) have
a copy button. Some pages update by themselves while they are open, with
a "Live" sign in their header: a server's overview (every few seconds),
its messages and a message, its received mail and a received message, its
routes, its endpoints, its suppressions, its webhooks, a webhook and a
delivery, an organisation's overview, its reports, a report, its domains
and a domain (its verification, DNS health and tracking host), and the
instance's IP pool
and warm-up plan pages;
what changed is highlighted for a moment. A member whose role changes, or
who is removed, has their open pages reloaded under the new role.
| Page | Who changes what |
|---|---|
| Organisation | Its mail servers and domains with their states. Owners rename it (the slug stays); owners and admins add mail servers. |
| Members | Owners and admins add members (users who have signed in at least once), change their roles and remove them; only owners make or unmake owners, and the last owner stays. Read-only for organisations the identity provider manages (KARTA_OIDC_GROUP_ROLES). |
| Mail server | The overview: its state and token, the last 24 hours (messages accepted, their recipients by state, messages per hour), the messages it sent and received each UTC day and the deliveries of the last minute against its sending limit, its retention, sending limit, tracking and active credentials. Everyone in the organisation sees it. |
| Mail server settings | Owners and admins change its settings and choose its tracking host; instance administrators suspend it, with a reason everyone in the organisation sees on every page of the server, and resume it. |
| Credentials | Owners, admins and members create API keys (with their scopes) and SMTP logins, and revoke them. A new key or password is shown once, on that page; Karta keeps only a hash and cannot show it again. |
| Domains | Owners and admins add domains, check the TXT record that verifies a domain (shown with the token) and its DNS health (SPF, DKIM, DMARC, MX, reverse DNS and HELO, the return path, MTA-STS, TLS-RPT and BIMI, each with what to do), generate, activate (once the record is in DNS), rotate and retire DKIM keys (each with the record to publish and where its rotation stands), add, check and remove a verified domain's tracking host (with the CNAME record to publish and the last check), set the MTA-STS policy Karta serves for it (testing, enforce once every MX host accepts TLS, or withdrawn; with its records and the last check of its CNAME record), set the address of its TLS reports, upload its BIMI logo (checked against SVG Tiny PS) with its certificate's URL, look at the changes publishing through the instance's DNS provider would make and publish them (where it publishes the domain's zone), and remove domains; instance administrators verify a domain without its record, and withdraw verification. A domain's page updates by itself as checks finish. |
| Messages | Everyone in the organisation searches a server's messages and reads them, the raw message included; members, admins and owners can try a message's waiting recipients again now, hold and release them, and cancel a scheduled message, and the message page lists who did what (Delivery). |
| Received | Everyone in the organisation searches the messages the server received, by text, what became of their deliveries and dates, and reads them, the raw message included. Members and above send a waiting or failed delivery again; nothing is ever bounced to the sender. |
| Routes | Everyone in the organisation sees which addresses the server receives and where their mail goes. Owners and admins add a route for a verified domain of the organisation and change or remove it: to an endpoint, stored, stored and read as a DMARC aggregate report, stored and held, or refused, with plus addressing, whether forged mail is refused, and what a message scoring at or above its spam threshold gets (marked, held or refused) and whether a scanner that cannot answer refuses it. A route only for a domain the organisation verified. |
| Endpoints | Everyone in the organisation sees where received mail goes. Owners and admins add an endpoint (an application's URL in a format chosen once, a mail server over SMTP with its TLS policy, or addresses forwarding with SRS), change it and remove it while no route uses it, and set an extra authentication header. An HTTP endpoint's signing secret is shown once, on that page; a URL's user name and password are kept apart and the password is never shown. |
| IP pools | Instance administrators see the sending address pools, each with its addresses (address and HELO name, family, whether the node serving the page holds it, warm-up progress), its settings and the mail servers that send from it; they add a pool and its addresses (with the PTR and address records checked, or without while they are set up), remove an address, change the settings, assign a mail server to the pool and back, start and end a warm-up, and remove a pool no server sends from. |
| Warm-up plans | Instance administrators add a plan's daily limits, change them (the addresses under it follow) and remove a plan no address warms up under. |
| Suppressions | Everyone in the organisation searches the server's suppression list by the start of the address and by reason. Members and above add an address (with its reason and an optional expiry) and remove one. See Suppressions. |
| Webhooks | Owners and admins add webhooks (in a format chosen once), change, switch off and on, test and remove them, rotate their secrets (shown once, on that page), and send deliveries again; everyone in the organisation sees them, their deliveries and requests, never their secrets. See Webhooks. |
| Reports | Everyone in the organisation sees the reports it received (DMARC aggregate and failure reports, and TLS reports), newest first, 50 to a page, and one report's page with, by kind, the policy it says the domain published and its records, the fields of a failure, or the policies of a TLS report with their failure details. A report whose domain the organisation does not serve is kept, unattributed; a message that could not be read as a report is kept with the reason. Nothing changes here. Summaries adds the reports up over the last 7, 30 or 90 days: for DMARC, the messages, how many passed SPF and DKIM and what receivers did, by domain and by reporter; for TLS, the sessions that succeeded and failed and the failure reasons. |
| Account | Your sessions, and signing out everywhere else; for a local account, a new password (which also signs out your other sessions) and a new authenticator app. |
Messages
A server's messages page lists its accepted messages, newest first, 50 to a page. The search finds text in the envelope sender and recipients, the From address, the subject and the Message-ID (without regard to case), and narrows by a recipient state (queued, deferred, delivered, bounced, suppressed), a tag and a range of days (UTC). The search and the page are part of the page's address, so a search can be bookmarked; a page is named by the id of a message next to it, which Karta only ever looks up among that server's messages.
The list is live. On its first page, while its top is in view, new messages that match the search appear at the top. On a later page, or scrolled down, the rows shown change in place (a row that no longer matches the search goes) and a button at the bottom of the window counts the new messages and leads to the first page; the search, the page and the scroll stay as they are.
A message's page shows its envelope, its recipients with their states, every
delivery attempt (the reply, the server tried, TLS), opens and clicks, its
plain text, its attachments (names, types and sizes) and its header fields,
all as text. Its HTML part is shown in a frame that runs no scripts and
loads nothing from other hosts: Karta takes out everything that would run,
load, submit or navigate before it sends the part (remote images are
not loaded; images the message carries itself, up to 2 MiB in all, are
shown), and the frame's own policy forbids the rest. The frame is as
tall as the part is long, and its lower edge can be dragged to see more; a
message without an HTML part shows only its text. Links do not open;
their targets are shown when the pointer rests on them. Download gives
the message as stored, as an .eml file. Messages larger than 10 MiB are
not opened on the page, only offered as a download. The recipients, the
delivery attempts and the opens and clicks update while the page is open;
a message removed meanwhile (retention) says so instead of showing its
content.
Webhooks
A server's Webhooks page lists its webhooks: name, the URL's host,
format, events, and state: on, failing (since when its requests fail),
off, or stopped (Karta switched it off because its requests kept failing).
Owners and admins add one there: a name, the URL (https://; a user name
and password in it are sent as Basic authentication), the format, which
cannot be changed later, and every event of the format or some of them.
The secret of a webhook in Standard Webhooks' or Mailgun's format is
shown once, right after it is added, until Done or until the page is
left.
A webhook's page shows its URL (the user name of its Basic authentication, never the password), format, events and state, and how its requests are signed:
- Standard Webhooks: Rotate the secret shows the new secret once; the previous one keeps signing for a day, an hour, a week or not at all, as chosen.
- Mailgun's format: Rotate the key shows the new key once. The webhooks Mailgun's webhooks API made share one key, as Mailgun's do: the page names the others, and Rotate the shared key changes it for all of them.
- SendGrid's format: the public key, to copy, at any time; Rotate the key pair makes a new pair that signs at once (give the receiver the new public key). The private key is never shown.
- Postal's format: the address of the instance's JWK set and the id of its key; the operator rotates that key (below).
- Postmark's format: not signed; put a user name and password in the URL and check them.
Owners and admins change the name, the URL (a URL with another user name
and password replaces them; they stay unless replaced or removed) and the
events, Switch off and Switch on, Send a test event
(webhook.test, while it is on) and Remove it, with its deliveries.
The page lists the webhook's deliveries, newest first, 50 to a page, by
state (pending, succeeded, failed), with their requests so far; each leads
to the delivery's page: the event's id, its state, the body every request
carries and every request (the address connected to, the answer, how long
it took, the start of the response). Send again sends one delivery
again, and Send them again the failed deliveries (and, if asked, those
that succeeded) of events in a period, in UTC; not while the webhook is
off. The pages update while they are open.
Organisations
An organisation (Karta.Accounts.Organisation) is a customer: it owns
domains and mail servers.
{:ok, org} = Karta.Accounts.create_organisation(%{name: "Example"})
{:ok, org} = Karta.Accounts.update_organisation(org, %{name: "Example Ltd"})name is required, at most 100 characters; a unique slug is made from it
when the organisation is created. Renaming (Karta.Accounts.rename_organisation/2,
as the admin page does) keeps the slug, because the identity provider's
group mapping names organisations by slug. To find one again:
org = Karta.Repo.get_by!(Karta.Accounts.Organisation, slug: "example")Users are created when they first sign in through the identity provider,
or with Karta.Release.local_user/2 for local login. Memberships (roles
owner, admin, member and read_only) come from the provider's groups
or are managed on the members page; from the console,
Karta.Accounts.add_member/3 adds one without any check. See
Sign-in and access for what each role may do.
Mail servers
{:ok, server} = Karta.Servers.create_server(org, %{name: "Shop"})
{:ok, server} =
Karta.Servers.update_server(server, %{
retention_days: 30,
retention_size_mb: 2048,
send_limit_per_minute: 120,
track_opens: true,
track_clicks: true,
list_unsubscribe: false
})The fields are listed in the Configuration reference.
Each server also gets a random public token (12 characters) and a slug
unique within its organisation. Which addresses its mail leaves from is
set by assigning it to an IP pool
(Karta.IPPools.assign_server/2).
Suspending a server
An instance administrator suspends a server on its page, with a reason the organisation sees, or from the console:
{:ok, server} = Karta.Servers.suspend(server, "Spam complaints")
{:ok, server} = Karta.Servers.resume(server)While a server is suspended:
- its credentials are refused: the APIs answer
server_suspended(403) and SMTP550 5.7.1 Sending is suspended for this serveratMAIL FROM; - the mail it accepted before waits: its delivery jobs make no attempt
and look again every minute. Nothing is dropped or bounced, and delivery
goes on within a minute of
resume/1. Each recipient's retry period (5 days from when it was queued) keeps running meanwhile, so mail held longer than that bounces at its next failed attempt.
Domains
{:ok, domain} = Karta.Domains.create_domain(org, %{name: "example.com"})
{:ok, domain} = Karta.Domains.verify_domain(domain)- Names are stored in lower-case ASCII form (an internationalised name is
converted to its
xn--form), without a trailing dot; a name needs at least two labels. Subdomains are separate domains. - Verification is normally the organisation's own: it publishes the
TXT record
_karta.<domain>with the domain's token (Karta.Domains.ownership_record/1), and Karta verifies the domain when it finds the record (Karta.Domains.check_ownership/2, on the domain's page and every hour); a domain verified that way loses verification when its record has been gone for 7 days (Domains and DNS).verify_domain/1is the operator's override, after checking that the organisation controls the domain by other means; such a verification does not depend on the record. A name can be verified for only one organisation at a time; a second gets{:error, changeset}with "is verified by another organisation", and a second organisation's record is reported as:taken. Karta.Domains.Health.run(domain)runs the DNS health checks andKarta.Domains.Health.list(domain)reads their last results (Domains and DNS).Karta.Domains.unverify_domain/1withdraws verification: the organisation can no longer send from the domain, and its keys stop signing.Karta.Domains.delete_domain/1deletes the domain and its keys.Karta.Domains.list_domains(org)andKarta.Domains.get_domain(org, id)look domains up.- A verified domain can have a tracking host of its own
(
Karta.Tracking.Hosts.add(domain, %{name: "click"})), used for the tracking links in its mail once its CNAME record is in place; see Tracking hosts of sending domains.
DKIM keys
{:ok, key} = Karta.Domains.generate_dkim_key(domain, %{algorithm: "ed25519"})
{:ok, rsa} = Karta.Domains.generate_dkim_key(domain, %{algorithm: "rsa", bits: 2048})
Karta.Domains.DKIMKey.record_name(key, domain) # "karta-xxxxxxxx._domainkey.example.com"
key.public_key # "v=DKIM1; k=ed25519; p=..."
Karta.Auth.DKIM.Key.dns_strings(rsa.private_key) # the RSA record cut into 255-octet strings
{:ok, key} = Karta.Domains.activate_dkim_key(key)algorithmisrsaored25519;bits(RSA only) is 2048 (default), 3072 or 4096;selectoris optional (defaultkarta-and eight random characters).- Keys are generated by Karta and stored encrypted with the vault key; a private key is never taken from input or shown.
- A new key is
pending. Publish its record, then activate it. Activation needs a verified domain ({:error, :domain_not_verified}otherwise; a retired key gives{:error, :retired}) and moves the previous active key of the same algorithm toretiring. A domain can have one active Ed25519 key and one active RSA key; mail is then signed twice. Karta.Domains.retire_dkim_key/1marks a keyretired: it no longer signs, and its record can be removed.Karta.Domains.list_dkim_keys/1lists a domain's keys, newest first.Karta.Domains.Rotation.activate/2activates a key only once its record is in DNS ({:error, :record_missing},:record_differentor:lookup_failedotherwise), as the domain's page does;activate_dkim_key/2above does not look.Karta.Domains.rotate_dkim_key/1starts a rotation of an active key (a pending key of the same kind that replaces it); the hourlyKarta.Domains.CheckrunsKarta.Domains.Rotation.advance/2, which activates it once its record has been in DNS for an hour and retires the replaced key a week later. RunRotation.advance(domain)to take a step now.
See Domains and DNS for publishing and rotating keys.
The MTA-STS policy, the TLS reports' address and the BIMI logo (Domains and DNS):
{:ok, policy} = Karta.MTASTS.Hosting.save(domain, %{"mode" => "testing", "mx" => "mx1.example.com"})
Karta.MTASTS.Hosting.records(domain, policy) # the CNAME and TXT records to publish
Karta.MTASTS.Hosting.readiness("example.com", ["mx1.example.com"]) # :ok, or why enforce would stop mail
{:ok, domain} = Karta.Domains.TLSReporting.update(domain, %{"tls_rpt_rua" => "tls-reports@example.com"})
{:ok, logo} = Karta.BIMI.upload(domain, File.read!("logo.svg")) # {:error, {:invalid, problems}} otherwise
Karta.BIMI.record(domain, logo)The Public Suffix List Karta uses (Karta.PublicSuffix.in_use/0) and a
refresh now (Karta.PublicSuffix.Refresh.run/0):
Karta.PublicSuffix.in_use() # %{source: :vendored} or %{source: :fetched, version: …}
Karta.PublicSuffix.Refresh.run() # {:ok, :updated | :unchanged} or {:error, reason}Where the instance publishes domains' zones through a DNS provider:
Karta.DNS.Publish.plan(domain) # {:ok, changes}: what publishing would change
Karta.DNS.Publish.publish(domain) # writes them; the hourly check does the sameCredentials
{:ok, credential, key} = Karta.Credentials.create_api_key(server, %{name: "Shop"})
{:ok, credential, key} =
Karta.Credentials.create_api_key(server, %{
name: "Admin",
scopes: Karta.Credentials.scopes(),
rate_limit_per_minute: 1200
})
{:ok, smtp, password} = Karta.Credentials.create_smtp_credential(server, %{name: "Shop"})
Karta.Credentials.username(smtp)- The secret (
keyorpassword) is returned once. Karta keeps an Argon2id hash of an API key's secret and only SCRAM-SHA-256 keys for an SMTP password. scopesdefaults tomessages:sendandmessages:read;Karta.Credentials.scopes/0lists them all. See API keys and scopes.rate_limit_per_minutedefaults to 600 (requests for an API key, messages for an SMTP credential).Karta.Credentials.list_credentials(server)lists a server's credentials, revoked ones included;Karta.Credentials.update_credential/2changesname,rate_limit_per_minuteand (API keys)scopes;Karta.Credentials.revoke_credential/1revokes one for good.
Suppressions
The mail server's Suppressions page lists the addresses it does not send to, with the reason, who or what added each and when it stops counting. Everyone in the organisation sees it; members and above add an address and remove one there. The list is live.
Karta.Suppressions.suppress(server, %{address: "bob@example.net", reason: :manual}, "operator")
Karta.Suppressions.unsuppress(server, "bob@example.net")
Karta.Suppressions.list_suppressions(server, limit: 100)See Suppressions.
Postal signing key for an organisation
Each organisation has one RSA key that signs its requests in
Postal's format: those of its webhooks and
of its inbound HTTP endpoints. Karta makes it (2,048 bits) when it is
first needed and publishes its public key at the organisation's own JWK
set, /.well-known/jwks/<token>, whose address the webhook's page and
GET /api/v2/postal-key show. A request signed for one organisation does
not verify with another's key. In a release, naming the organisation by
its slug or id:
bin/karta eval 'Karta.Release.postal_signing_key("acme")' # its id and address
bin/karta eval 'Karta.Release.rotate_postal_signing_key("acme")' # a new key
Each prints the key's id (kid, as in X-Postal-Signature-KID), the
address of the organisation's JWK set and the DNS record of its public
key in the form Postal prints (v=DKIM1; t=s; h=sha256; p=…;), for
receivers that look it up in DNS: publish it where they look (Karta
publishes nothing). The private key is never printed; it is stored
encrypted by the vault.
Rotating makes a new key that signs at once; the old one stays in the JWK set for a week, and the set's address does not change. Receivers that keep the public key themselves must take the new one: rotate when they can, since a request carries one signature per algorithm. An organisation's owner can rotate it on a Postal-format webhook's page too.
Looking at messages
Karta.Messages.list(server, limit: 20) # newest accepted messages
{search, _} = Karta.Messages.Search.cast(%{"q" => "bob@example.net", "status" => "bounced"})
Karta.Messages.search(server, search).entries # as the messages page searches
message = Karta.Messages.get(server, id)
Karta.Outbound.recipients(message.id) # per-recipient state
Karta.Outbound.deliveries(message) # every attempt
{:ok, raw} = Karta.Messages.raw(message) # the stored message, decryptedReading a message body from the console decrypts customer mail; treat it like any other access to it.