IP pools
An IP pool is a set of addresses that mail servers send from. Without a
pool, a server's mail leaves from the node's own address with
KARTA_OUTBOUND_HOSTNAME in EHLO, as it always did. With one, every
connection of its deliveries is bound to one of the pool's addresses and
greets with that address's name. Pools let you keep the reputation of
different kinds of mail apart, give a cluster of nodes one sending
address, and move that address between nodes without losing mail.
A new address is warmed up: used for few recipients a day at first and
more each day, under a warm-up plan. Instance administrators manage pools
and plans in the admin interface: IP pools (/instance/ip-pools,
reached from the instance's section of the sidebar) lists the pools and
adds one; a pool's page has its addresses (added with the PTR and address
records checked, or without the check while a record is being set up),
its settings, the mail servers that send from it, each address's warm-up
and its end; Warm-up plans (/instance/warm-up-plans) adds, changes
and removes the plans. The same is done from the console, below.
Setting up a pool
From a remote console (Managing organisations, servers and keys):
{:ok, pool} = Karta.IPPools.create_pool(%{name: "bulk"})
{:ok, _} =
Karta.IPPools.add_address(pool, %{address: "192.0.2.25", helo_name: "mta1.example.com"})
{:ok, _} =
Karta.IPPools.add_address(pool, %{address: "2001:db8::25", helo_name: "mta1.example.com"})
{:ok, server} = Karta.IPPools.assign_server(server, pool)
{:ok, server} = Karta.IPPools.assign_server(server, nil) # back to the node's addressThe name (lower-case letters, digits and hyphens, at most 40 characters) names the pool's delivery queue,
outbound_bulk, and does not change. A pool that servers still send from cannot be deleted (delete_pool/1); its addresses go with it.An address belongs to one pool. It must be on the network interfaces of the node that sends from it (see below), or, behind one-to-one NAT (a cloud's public address that the node never sees), give the node's own address as
local_address, which is then bound in its place:Karta.IPPools.add_address(pool, %{ address: "203.0.113.10", local_address: "10.0.0.5", helo_name: "mta2.example.com" })Assigning a server moves its delivery jobs that wait to the new pool's queue at once; a job that is running moves when it runs next.
A pool has two settings of its own (
update_pool/2;nilreturns one to its default):concurrency, the pool's delivery jobs each node runs at once (defaultKARTA_OUTBOUND_CONCURRENCY; a change applies within seconds), anddestination_limits, the limits per destination of the pool's mail in place ofKARTA_OUTBOUND_DESTINATION_LIMITS:Karta.IPPools.update_pool(pool, %{ concurrency: 4, destination_limits: "*.example.com connections=2 per_minute=100, * connections=5" })
HELO names and PTR records
Receiving servers compare the name in EHLO with the sending address's
PTR record, and many refuse or mark mail whose names do not match.
add_address/3 therefore checks, before it saves the address, that:
- the address's PTR record names the HELO name; and
- the HELO name's A record (IPv4) or AAAA record (IPv6) leads back to the address.
An address that fails is refused with the reason on helo_name, for
example the PTR record of 192.0.2.25 names mx2.example.com, not mta1.example.com. While the PTR record is still being set up, add it
with check_dns: false and check it later:
Karta.IPPools.add_address(pool, attrs, check_dns: false)
Karta.IPPools.check_dns({192, 0, 2, 25}, "mta1.example.com") # :ok or {:error, reason}The lookups go to the resolver directly, not through Karta's DNS cache.
SPF
A receiving server checks the sending address against the SPF record of the envelope sender's domain (the return path domain, with VERP). Every address of a pool must be allowed there, in both families: a pool with an IPv6 address sends over IPv6 to every mail server that has one, and an SPF record that lists only IPv4 networks fails that mail.
Karta.IPPools.check_spf(pool, "example.com")
#=> %{"192.0.2.25" => :pass, "2001:db8::25" => :fail}Each address should get :pass. The check follows the record as a
receiver does (ip4, ip6, a, mx, include, exists, redirect,
the limits of 10 lookups and 2 void lookups) and answers :unknown where
the record uses macros or ptr, which depend on a message. Karta does
not check SPF when it delivers.
Which addresses a delivery uses
- A delivery job of a server in a pool uses only the pool's addresses that are on the node it runs on. Of those, it takes one per IP family, chosen by the message, so retries of a message come from the same address (greylisting remembers it), and different messages spread over the pool. An address that has reached its warm-up limit for the day is passed over for the next one with room (below).
- The pool's families decide which addresses of the recipient's mail
servers are tried: a pool with only IPv4 addresses delivers to IPv4
addresses only, one with only IPv6 addresses to IPv6 only; a pool with
both follows
KARTA_OUTBOUND_IP_FAMILY. A recipient whose servers have no address of a family the node holds is deferred (4.4.0). EHLOgives the chosen address'shelo_name. Delivery status notifications still nameKARTA_OUTBOUND_HOSTNAMEas the reporting MTA.- The address used is recorded with every attempt (
ip_used).
Warming up a new address
Receiving servers distrust an address they have not seen before: mail from it in volume is deferred, throttled or filed as spam until the address has a history. So a new address is used for few recipients a day at first, and for more each day. A warm-up plan gives the daily limits, and an address under a plan is used for no more recipients on a day than the plan allows, by all nodes together.
{:ok, plan} =
Karta.IPPools.create_warmup_plan(%{
name: "standard",
daily_limits: [50, 100, 200, 400, 800, 1_500, 3_000, 6_000, 12_000, 25_000]
})
# Or a ramp: from 50, twice as many each day, up to 50,000.
Karta.IPPools.WarmupPlan.ramp(50, 2, 50_000)
#=> [50, 100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 50000]
{:ok, address} = Karta.IPPools.start_warmup(address, plan) # from today
{:ok, address} = Karta.IPPools.start_warmup(address, plan, on: ~D[2026-12-01]) # from a given day
Karta.IPPools.warmup_status(address)
#=> %{plan: "standard", day: 3, days: 10, limit: 200, sent: 57}
{:ok, address} = Karta.IPPools.stop_warmup(address) # no limit from now on- Days are UTC days. The first limit is that of the day the warm-up starts, the second that of the next day, and so on, for at most 365 days. After the last day the address has no limit; before the first it is not used. A start day in the past continues a warm-up begun elsewhere.
- A plan can be changed (
update_warmup_plan/2); its addresses follow the new limits at once. A plan that addresses warm up under cannot be deleted. - What counts is every recipient sent to from the address in an SMTP transaction, whatever the receiving server answered. A delivery reserves its recipients before it connects, in the database, so the limit holds with any number of nodes and jobs at once; what it did not use (no server could be reached) is given back.
- An address that is full is passed over for another address of the pool, of the same IP family, that the node holds and that has room (or no plan). When there is room for only some of a message's recipients at a domain, those go now and the others in a following run.
- When no address has room, the recipients wait, without an attempt:
the delivery looks again at the start of the next UTC day, and every
hour until then (a plan may have changed, an address been added).
Nothing bounces because of a limit, but the 5-day retry period keeps
running, as for any wait: a recipient still waiting when it ends
bounces with
4.4.7, the limit being its last error. A pool too small for its mail shows long before that in the metrics (below).
One sending address for a cluster
Every node checks, every 5 seconds, which pool addresses are on its own
network interfaces (Karta.IPPools.Monitor). A pool's delivery queue
runs only on the nodes that hold one of its addresses. So an address that
moves between nodes, such as a keepalived virtual address or a cloud's
floating address, takes the pool's delivery with it, with no election
between the nodes:
| What happens | What Karta does |
|---|---|
| A node gets the address | starts or resumes the pool's queue there within seconds |
| A node loses the address | pauses the queue there: running deliveries finish, no new one starts |
| No node has it | the pool's mail waits in the queue and goes once a node has it again; each recipient's 5-day retry period keeps running |
| The address leaves in the middle of a transaction | the connection fails, the recipient is deferred and retried later from the new holder; a receiving server that had the message already may get it twice, as with any lost connection |
| Two nodes have it for a moment | both deliver; each job still runs on one node only; the node whose packets go nowhere sees timeouts and defers |
| A job runs on a node that has just lost the address | it makes no attempt and looks again a minute later |
The nodes must see the address: run Karta with host networking (or a
macvlan network), so that the address appears on the container's
interfaces. Where that is not possible, do not use a pool: let the hosts
translate the source address (SNAT) and set KARTA_OUTBOUND_HOSTNAME to
that address's PTR name.
Every node runs up to the pool's concurrency deliveries at a time in
each pool queue it runs (by default KARTA_OUTBOUND_CONCURRENCY, as in
outbound).
Watching it
Each node logs when it gets or loses an address:
[info] IP pool bulk: this node now holds 192.0.2.25
[warning] IP pool bulk: this node no longer holds 192.0.2.25and reports karta_ip_pool_address_held{pool, address}: 1 on the node
that holds the address, 0 on the others (Monitoring).
Alert when no node holds an address:
max by (pool, address) (karta_ip_pool_address_held) == 0and look when two do for longer than a failover takes:
sum by (pool, address) (karta_ip_pool_address_held) > 1For warm-up, karta_warmup_sent{pool, address} and
karta_warmup_limit{pool, address} show each address's day so far, and
karta_delivery_held_back_recipients{reason="warmup", pool} counts the
recipients that waited for room:
karta_warmup_sent / karta_warmup_limit > 0.9
sum by (pool) (increase(karta_delivery_held_back_recipients{reason="warmup"}[1h])) > 0