Part ids and nested message ids are stored as 16-bit numbers, and nothing checked that a message's ids fit: for a message of more than 65,535 parts (about 650 KB of empty parts) they wrapped, so the root multipart listed itself among its own parts. IMAP BODYSTRUCTURE and JMAP Email/get (bodyStructure, textBody, htmlBody and attachments, which webmail asks for when a message is opened) then walked the parts in a cycle, rebuilding all of them at each step, until the server ran out of memory. Anyone who can send to port 25 could leave such a message in a mailbox, and every fetch of it took the server down again. Now such a message is refused: at SMTP DATA with 552 5.3.4, and when it's delivered, appended over IMAP or imported over JMAP. Ids that don't fit are left out of the stored structure, never wrapped. For messages already stored, the walks follow a multipart only to parts after it and a nested message only to messages after the current one, emit no more parts than the message has, and textBody, htmlBody and attachments skip ids that name a multipart. Found in a security review. Test: in crates/email, the root multipart of a parsed 65,537-part message listed itself after storing; now it lists only later parts. In crates/email and crates/imap, the JMAP body part and IMAP BODYSTRUCTURE walks of a multipart listing itself, or of a nested message that is the message itself, ran into the 10,000-level nesting guard; now they end with the parts there are, and shared parts are emitted at most as many times as the message has parts. In the IMAP suite APPEND of a 65,537-part message succeeded and in the SMTP data suite DATA got 250; now APPEND gets NO and DATA 552 5.3.4.