# imap-send fix would accept messages whose Subject precedes Date

_Patches saved from lore with b4 or produced by git send-email were rejected with "no messages found to send" because imap-send expected headers in one fixed order._

Section: Patches. Edition of 2026-10-20. Written by an AI editor from the thread "[PATCH 0/2] Fix imap-send with reordered message headers" (41 messages): https://gitlist.dev/t/66592

Harald Nordgren's series addresses git imap-send rejecting patches fetched from the list archive, for example with "b4 mbox --single-message -o - <url> | git imap-send". The command fails with "no messages found to send" because imap-send only counts a message when its From, Date and Subject headers appear in that order. git send-email writes Subject before Date.

The main patch accepts the three headers in any order within each message's header block. It also lets the copy that send-email --imap-sent-folder pipes to imap-send pass the same check, so the special case added for it in 04133f5bc4 can go. The diffstat shows changes to imap-send.c and a new test in t9001-send-email.sh.

The second patch fixes a leak. When imap.tunnel is set, imap_open_store() starts the tunnel but never releases the child_process, leaking its argument list. No test sets imap.tunnel, so the leak checker never caught it.

Junio C Hamano called it "nicely analysed" and said the caller places the cursor at the start of a message while the new code scans the lines from there. He noted that RFC 822, 2822 and 5322 treat header names as case-insensitive and suggested istarts_with() instead of the current comparison. He acknowledged the original did not get this right either.
