Karta.Domains.Health (Karta v1.0.0)

DNS health checks of a sending domain: what receiving servers will find when they check its mail, and what to change. Each check looks up DNS through Karta.DNS (never the cache) and gives findings, each :pass, :warn, :fail or :missing with a sentence, what to do and the record to publish (Karta.Domains.DNSCheck); the check's status is the worst of them.

  • :spf - the domain's SPF record (Karta.Domains.Health.SPF): one record, every sending address authorised (IPv6 too), at most 10 DNS lookups, the qualifier of all.
  • :dkim - the records of its DKIM keys (Karta.Domains.Health.DKIM): every active key's published and equal, pending and retiring keys' too.
  • :dmarc - its DMARC policy, or its organisational domain's (Karta.Domains.Health.DMARC): present, p=, rua, and whether Karta's mail is aligned for quarantine or reject.
  • :mx - where mail to the domain goes (Karta.Domains.Health.MX): no null MX, hosts with IPv4 and IPv6 addresses.
  • :ptr - reverse DNS and HELO of the sending addresses (Karta.Domains.Health.PTR): a PTR record that leads back, naming what Karta gives in EHLO.
  • :return_path - the return path domain, when KARTA_RETURN_PATH_DOMAIN is set (Karta.Domains.Health.ReturnPath): its MX and SPF records.
  • :mta_sts - its MTA-STS record and policy (Karta.Domains.Health.MTASTS): valid, fetched, its mode, every MX host covered, and the id of the policy Karta serves for it, if any.
  • :tls_rpt - its TLS-RPT record (Karta.Domains.Health.TLSRPT), and that it names the address set in Karta, if any.
  • :bimi - its BIMI record (Karta.Domains.Health.BIMI): valid, the logo Karta serves for it, if any, and DMARC strict enough for a logo to be shown.

Sending addresses (senders/2): the addresses of the IP pools the organisation's servers use, and, when one of its servers has no pool or it has no server yet, the addresses of KARTA_OUTBOUND_HOSTNAME (its A and AAAA records, as KARTA_OUTBOUND_IP_FAMILY allows), each with the name Karta gives in EHLO from it.

Results are kept per domain and check (run/2 stores them, list/1 reads them) and announced on the domain's topic (:dns_checks, Karta.Changes). A check whose lookups fail records the failure and keeps its previous result: a failed lookup is not an answer.

Webhooks. When a check of a verified domain turns to :fail (from any other status, or from no result), the run records a domain.dns_failed event for every server of the domain's organisation (Karta.Webhooks), in the transaction that stores the results: once per problem, not on every run while it lasts.

Summary

Types

A check's outcome: findings and the records found, or why it could not finish.

An address Karta sends from, and the name it gives in EHLO there.

Functions

The checks, in the order a domain's page shows them.

The stored results of the domain's checks, in the order of checks/0.

Runs every check of the domain and stores the results. Options: dns (options for Karta.DNS.lookup/3; the cache is never used), now, hostname and ip_family (for senders/2), senders (instead of senders/2, a list of sender/0), return_path (instead of KARTA_RETURN_PATH_DOMAIN) and mta_sts (options of the MTA-STS policy fetch, Karta.MTASTS.Fetcher.fetch/2).

The addresses the organisation's mail leaves from (see the module doc), or {:error, text} when looking up the outbound host name's addresses failed. Options: dns (options for Karta.DNS.lookup/3), and hostname and ip_family instead of config :karta, Karta.Outbound.

Types

outcome()

@type outcome() :: {:ok, [struct()], [String.t()]} | {:error, String.t()}

A check's outcome: findings and the records found, or why it could not finish.

sender()

@type sender() :: %{ip: :inet.ip_address(), helo: String.t()}

An address Karta sends from, and the name it gives in EHLO there.

Functions

checks()

@spec checks() :: [atom()]

The checks, in the order a domain's page shows them.

list(domain)

The stored results of the domain's checks, in the order of checks/0.

run(domain, opts \\ [])

Runs every check of the domain and stores the results. Options: dns (options for Karta.DNS.lookup/3; the cache is never used), now, hostname and ip_family (for senders/2), senders (instead of senders/2, a list of sender/0), return_path (instead of KARTA_RETURN_PATH_DOMAIN) and mta_sts (options of the MTA-STS policy fetch, Karta.MTASTS.Fetcher.fetch/2).

senders(organisation_id, opts \\ [])

@spec senders(Ecto.UUID.t(), keyword()) :: {:ok, [sender()]} | {:error, String.t()}

The addresses the organisation's mail leaves from (see the module doc), or {:error, text} when looking up the outbound host name's addresses failed. Options: dns (options for Karta.DNS.lookup/3), and hostname and ip_family instead of config :karta, Karta.Outbound.