Reply detection has to win the race with the send queue
The worst outcome in outbound is following up with someone who already replied. That requires reply detection to run and cancel pending steps before the next queue cycle, not on a slower schedule. It also has to handle the narrow race where a prospect replies after a follow-up job is locked but before the provider call is made.
Detection should be idempotent: a retried job must not cancel the wrong sequence or send a duplicate. Correlating replies by Message-ID and thread references, and degrading safely when those headers are missing or duplicated, keeps a single malformed message from cancelling an unrelated campaign.
Match on thread evidence, not on the From address alone
Prospects reply from aliases, shared inboxes and forwarded threads. A detector that only compares the reply's From address to the address you mailed will miss those and keep following up. Use thread evidence — In-Reply-To, References, and provider thread identifiers — as the primary signal.
Out-of-office and auto-reply messages need their own handling. The Auto-Submitted header is a more reliable out-of-office signal than matching subject lines, and it also serves as loop prevention so two autoresponders do not keep each other alive.
Unsubscribe belongs above the individual mailbox
If someone opts out, they must stop hearing from every mailbox you send from, not just the one that mailed them. Build the suppression list above the mailbox layer and check it before every send.
One-click unsubscribe (RFC 8058) has two requirements people miss: the List-Unsubscribe and List-Unsubscribe-Post headers must be covered by the DKIM signature, and the endpoint must be idempotent so duplicate POSTs from mail clients do not error or un-suppress the address.
IMAP identifiers: UID, not sequence number
Sequence numbers renumber as messages arrive and are deleted; UIDs are stable within a mailbox as long as UIDVALIDITY does not change. Automation that stores sequence numbers as durable state will eventually act on the wrong message. Store the UID and the UIDVALIDITY together, and when UIDVALIDITY changes, rebuild the cursor instead of trusting the old UIDs.
UIDNEXT is a hint about the next message, not the UID of the next reply, and IMAP SEARCH UNSEEN is unsafe as the only reply detector because a human reading the mailbox marks messages seen. Read with BODY.PEEK so inspection does not change flags.
IMAP folders, deletes and reconnects
Trash and Junk folder names differ across providers and languages, and the folder hierarchy delimiter is not always a slash — read the LIST response before constructing paths. A read-only mailbox will accept a delete or EXPUNGE that silently does nothing.
On reconnect after an IDLE timeout, resume from a stored UID cursor and re-check UIDVALIDITY; do not assume the mailbox is unchanged. Use UID EXPUNGE so a cleanup job removes only the messages it marked, not messages another client flagged in the meantime.
Common questions
How fast does reply detection need to run?
Faster than your follow-up queue cycle. If follow-ups are evaluated every hour, reply detection that runs every few hours will send at least one follow-up to people who already replied. Detection should cancel pending steps before the next send is dispatched.
Why does my system keep following up after a prospect replied from a different email?
Because it matches replies by comparing the From address to the address you originally mailed. Prospects reply from aliases and forwarded threads, so detection should rely on thread headers such as In-Reply-To and References, plus provider thread identifiers, rather than address equality.
Is IMAP SEARCH UNSEEN enough to detect replies?
No. A person opening the shared mailbox marks messages seen, so UNSEEN misses those replies entirely. Track a durable UID cursor per mailbox and process everything above it, reading with BODY.PEEK so your inspection does not change the seen flag.
What is UIDVALIDITY and why does it matter for automation?
It is a value the server returns for a mailbox; when it changes, all previously stored UIDs for that mailbox are invalid. A reply detector that caches UIDs must compare UIDVALIDITY on every session and rebuild its cursor when it changes, or it will act on the wrong messages.
Does one-click unsubscribe need anything special in DKIM?
Yes. Under RFC 8058 the List-Unsubscribe and List-Unsubscribe-Post headers must be included in the DKIM-signed header set. If they are added after signing or left out of the signature, mailbox providers may not honour the one-click flow.
Should an unsubscribe apply to just the campaign or to everything?
Everything. Maintain the suppression list above the individual mailbox and consult it before every send from every account, so an opt-out from one mailbox stops all future contact.