SMTP and IMAP Cold Email Automation: Why Reply Detection Is Hard

The Sendvanta Team · October 25, 2026 · 8 min read

Every few weeks someone posts a version of the same thing: "We cancelled our $97/month sending tool and built our own with Python, SMTP, and a cron job." The sending part is genuinely easy. A few dozen lines of `smtplib`, a template engine, a sleep timer, and you are delivering personalized multi-step sequences through your own mailboxes.

Then the first complaint arrives. A prospect replied on Tuesday, said "sure, send me times," and got follow-up #3 on Thursday asking whether they had seen the earlier note. Or the opposite: half the sequence stopped dead because people were on holiday and their auto-responders counted as replies.

That is reply detection, and it is the part of cold email automation that is much harder than it looks. Here is what actually goes wrong at the protocol level, and what a correct implementation has to handle.

{"h2":"Two failure modes, very different costs"}

{"h2":"Two failure modes, very different costs"}

There are only two ways reply detection fails, and they are not symmetrical:

{"ul":["False negative — someone replied, you didn't notice, the sequence kept going. This is the expensive one. It makes you look like a bot to the one person who engaged, and it burns the deal.","False positive — an out-of-office or a bounce was counted as a reply, the sequence stopped, and that lead silently falls out of the campaign. Cheaper per incident, but invisible: nobody complains, your pipeline is just quietly smaller."]},

Most home-built systems optimize for the first and ignore the second. A good system tracks both and reports on them separately.

{"h2":"Threading is a convention, not a guarantee"}

The obvious approach is header matching. When you send, you record the `Message-ID` you generated. When a message lands in the inbox, you look at its `In-Reply-To` and `References` headers; if either contains your stored Message-ID, it's a reply to that step. Clean, deterministic, and correct — when the headers survive.

They often don't. Things that break the chain:

{"ul":["Gateways rewrite Message-IDs. Some security and archiving gateways (and some mail hygiene appliances in front of Exchange) re-generate message identifiers in transit. Your stored ID no longer matches anything the reply references.","Mobile and web clients that compose fresh. A prospect who hits 'forward' to a colleague, or copies your text into a new message, sends something with no `In-Reply-To` at all.","Outlook's subject threading. Outlook historically groups by normalized subject as well as by headers. A reply can arrive with `References` pointing at an unrelated earlier thread in the same conversation.","Subject munging. `RE:`, `AW:`, `RE: RE:`, `Antwort:`, `[EXTERNAL] RE:` — subject-based fallback matching needs a normalizer that strips localized reply prefixes, tags injected by the recipient's gateway, and whitespace, before it compares anything.","You didn't set the headers correctly on follow-ups. If your own follow-ups don't carry proper `In-Reply-To`/`References` back to step 1, replies to step 3 won't thread back to the lead record either."]},

In practice you need layered matching with confidence levels, not one rule.

{"table":{"headers":["Signal","Confidence","Main failure mode"],"rows":[["In-Reply-To / References contains your Message-ID","Very high","Headers stripped or rewritten in transit"],["From address exactly matches the lead","High","Reply comes from an alias or assistant"],["From domain matches lead domain + normalized subject match","Medium","Role inboxes, shared domains like gmail.com"],["Normalized subject match only","Low","Unrelated threads, forwarded chains"],["Body quote contains your original text","Low-medium","Expensive to compute, easy to fool"]]}},

{"h2":"The address you mailed is often not the address that replies"}

Header matching assumes the reply comes back from the same mailbox. A large share of real replies don't. Founders forward to an EA. `john@company.com` is an alias that delivers to a shared `sales@` inbox, and the reply comes from `sales@`. Someone replies from their personal Gmail because they are on a plane. A gatekeeper replies from `reception@` on behalf of the owner.

If your stop rule is "suppress the lead whose email equals the From address," all of those cases keep sending. The fix is to suppress at the level above the address — the company, the thread, and any other contact you have at that domain — and to use the thread identity, not the sender identity, as the primary key. We covered the full pattern in how to stop follow-ups when a prospect replies from a different address.

{"h2":"Auto-replies look exactly like replies"}

Out-of-office messages thread correctly, come from the right address, and have a `RE:` subject. Everything your matcher looks at says "reply." You need a second classification pass before you let a message change sequence state.

Signals worth checking, in roughly this order:

{"ul":["`Auto-Submitted: auto-replied` or `auto-generated` (RFC 3834). The cleanest signal when present — but it is a recommendation, not an enforced rule.","`X-Autoreply`, `X-Autorespond`, `X-Auto-Response-Suppress`, `Precedence: bulk` or `auto_reply`.","Empty `Return-Path` (`<>`) — standard for automatically generated messages and bounces.","Content type `multipart/report; report-type=delivery-status` with a `message/delivery-status` part — that is a DSN, not a human. Parse the status code; `5.x.x` is a hard bounce, `4.x.x` is a transient defer.","Body heuristics as a last resort: 'out of the office', 'on annual leave', 'maternity leave', 'no longer with the company' in several languages."]},

The handling differs by type. An OOO should pause the sequence until the stated return date — not stop it, not count as a reply in your stats. A "no longer with the company" is a suppression plus a trigger to find a replacement contact. A bounce goes to bounce handling. A real human "not interested" is a stop plus suppression. If you lump all of it into one `replied = true` flag, your reply rate is inflated by 20-40% and your pipeline math is wrong. The categories are broken down in how to classify positive, negative, referral, and out-of-office replies.

{"h2":"IMAP itself is a moving target"}

Even with perfect matching logic, the transport layer has sharp edges.

{"ul":["Polling cadence vs. limits. Checking 40 mailboxes every two minutes is 28,800 IMAP sessions a day. Gmail allows a limited number of simultaneous IMAP connections per account and caps daily IMAP bandwidth; hammer it and you get throttled or temporarily locked out, which looks exactly like 'no replies today'. IDLE is better but needs one long-lived connection per mailbox and reconnect logic for silent drops.","UIDVALIDITY. IMAP UIDs are only stable while `UIDVALIDITY` is unchanged. When the server changes it, your 'last seen UID' pointer is meaningless and you either reprocess thousands of messages or skip a window of them.","Gmail folder weirdness. `[Gmail]/All Mail` duplicates messages that are also in INBOX, labels are not folders, and the special-use folder names are localized. Hardcoding `INBOX` and `Sent` works until a client's mailbox is in German or Portuguese; use the `SPECIAL-USE` / `XLIST` attributes instead.","Auth. Microsoft retired basic authentication for IMAP in Exchange Online, so OAuth2 is required for Microsoft 365 — token storage, refresh, and re-consent when an admin rotates app permissions. Gmail needs app passwords or OAuth too, and app passwords break whenever 2FA settings change.","Replies that never hit the inbox. If the prospect's reply lands in spam on your side, or gets auto-filtered by a rule, your poller never sees it. Scanning the Sent folder and the spam folder is not optional at scale."]},

{"h2":"The stop rule is a concurrency problem"}

The last trap is timing. A reply arriving at 09:58 does not help if your scheduler picked up the 10:00 batch at 09:57 and already handed 300 messages to SMTP. Detection latency has to be shorter than your batch lead time, and the final suppression check has to happen at send time with a lock on the lead record — not just when the batch is built.

The same applies across campaigns. If the same person appears in two lists under two email addresses, a reply to one should stop both. That means suppression lives at the workspace level, keyed on normalized email, domain, and thread — not inside a single campaign's state table.

{"h2":"What this costs to maintain"}

None of this is impossible. It is maybe two weeks to a working version and then an indefinite tail: a new gateway rewrites headers, a client's mailbox is in a language you didn't normalize, Microsoft changes an auth requirement, Gmail throttles your poller, a holiday season fills the queue with auto-replies in five languages. The $97/month you saved buys roughly one engineering hour a month at consulting rates.

Build it if reply handling is a core competence or your volume is low enough that a human can eyeball the inbox daily. Buy it if the cost of one missed "yes, let's talk" exceeds the subscription — which for most B2B offers it does on the first incident.

{"h2":"How Sendvanta handles it"}

Sendvanta connects to your own Gmail, Microsoft 365, or SMTP/IMAP mailboxes and does the layered matching described above: Message-ID and References first, then address and normalized-subject fallbacks, with suppression applied at the lead, thread, and domain level so a reply from an alias or an assistant stops every sequence that touches that company. Auto-replies, DSNs, and security-scanner activity are classified separately from human replies, so out-of-office messages pause rather than silently kill a sequence and your reply rate reflects real people. The final suppression check runs at send time, not at batch build time.

The free plan is $0 forever with 500 active leads, 1,000 emails a month, and up to 10 of your own SMTP mailboxes — enough to run the same sequences you'd run from a script and compare what the reply log actually catches. Paid plans start at $29/mo. Connecting your own mailboxes is free on every plan. More detail on what's included is on the features page.

If you keep your own build, at minimum: normalize subjects before comparing them, check `Auto-Submitted` and `Return-Path` before setting any reply flag, suppress by domain and not just by address, and log every message you classified so you can audit the false negatives. Those four changes fix most of the damage.

Ready to send outbound that lands?

Create your free Sendvanta workspace — no credit card required.

Start free