
How to read email over IMAP without marking it as seen
Use a fetch form that does not implicitly set the \Seen flag when the automation should inspect a message without changing the human inbox state.
Read field note →Filter by the layer you are operating. Every article is scoped to one question and links back to primary technical sources.

Use a fetch form that does not implicitly set the \Seen flag when the automation should inspect a message without changing the human inbox state.
Read field note →
Display names are not portable identifiers; providers can expose localized or vendor-specific mailbox names.
Read field note →
Message sequence numbers can change as the mailbox changes; UIDs are designed to remain stable within a UIDVALIDITY epoch.
Read field note →
Deletion is normally a flagging operation followed by expunge semantics; automation should define exactly which messages are eligible before removal.
Read field note →
A reply processor should be safe to run twice: the second pass must not create a second reply event, cancel the same sequence twice or resurrect follow-ups.
Read field note →
Missing folders can be a namespace, subscription, permission or provider-mapping issue; it is not always deletion.
Read field note →IMAP UIDs are only stable within a mailbox while UIDVALIDITY remains the same. If UIDVALIDITY changes, cached UIDs from the old validity value can no longer be trusted as identities in the new mailbox state.
Read field note →IMAP IDLE can notify a connected client about mailbox changes, but TCP sessions and servers can drop. Reply detection needs reconnect and catch-up logic instead of assuming one IDLE session lives forever.
Read field note →IMAP distinguishes read-write and read-only selected mailboxes. If a mailbox is opened with EXAMINE or the server grants only read-only access, permanent state changes and expunge behavior are restricted.
Read field note →Standard Delivery Status Notifications can use multipart/report with a message/delivery-status part that carries structured per-recipient fields. Parsing that structure is more reliable than matching “Undeliverable” in the subject.
Read field note →RFC 3834 recommends Auto-Submitted: auto-replied for automatic responses. It is a strong signal for vacation and automatic replies, but real systems still need a layered classifier because not every provider follows the standard perfectly.
Read field note →UNSEEN describes mailbox read state, not whether your automation processed a message. Human activity, mobile clients, filters, and other workers can change the Seen flag before your reply detector runs.
Read field note →UIDNEXT predicts the next UID value assigned to a future message. It can tell a client that mailbox state may have changed, but it does not guarantee a particular message exists with that UID.
Read field note →Gmail exposes labels through IMAP folder-like behavior and provides a stable message identifier extension. Automation that scans multiple labels needs a deduplication key above per-folder UIDs.
Read field note →The IMAP flags describe state on a stored message. They do not prove who generated a new inbound reply, and different clients can set or ignore them in ways that break outbound automation assumptions.
Read field note →A reconnect can change message sequence numbers while stable UIDs remain valid inside the same UIDVALIDITY epoch. Incremental workers should resume with UID-based ranges and validate the epoch first.
Read field note →RFC 5322 says messages should have globally unique Message-ID values, but automation still needs a fallback when malformed or duplicated identifiers appear in real mail.
Read field note →Ordinary EXPUNGE can remove every message currently carrying \Deleted in the selected mailbox, including flags set by another client. UID EXPUNGE narrows the destructive action to chosen UIDs when supported.
Read field note →IMAP servers advertise a hierarchy delimiter in LIST responses. Hard-coding “/” can break mailbox discovery on servers that use another delimiter or have a flat namespace.
Read field note →Gmail exposes X-GM-THRID for its own thread model, while RFC 5322 uses Message-ID, In-Reply-To and References. Outbound reply systems benefit from keeping both layers.
Read field note →