Re: [PATCH] imap-send: add --draft to set IMAP \Draft flag
From: Wolfgang Faust <hidden>
Date: 2026-09-02 04:29:25
On Tue, Sep 1, 2026, at 8:25 PM, Junio C Hamano wrote:
"Wolfgang Faust" [off-list ref] writes:quoted
The documented purpose of imap-send is to upload draft emails for sending later, but it did not have any way to mark the messages as \Draft, so some email clients presented the result as an un-editable, un-sendable email even if it happened to be in a "Drafts" folder.I agree that defaulting to '--no-draft' is a sensible design choice to avoid breaking clients that have been working fine.
Definite agree; I elaborate further below.
It would be helpful to know if e-mail clients that send messages from the Drafts folder without the '\Draft' flag would misbehave if they encounter messages marked as such.
Not sure how to find this out without doing a complete survey of every possible email client, but I think it's unlikely to be a major issue: any such client would already be incompatible with other standards- compliant clients using the same IMAP account. However:
Knowing this would help us decide whether to flip the default to '--draft', while keeping '--no-draft' as an escape hatch nobody is expected to use.
I think the default should probably be --no-draft anyway. First, imap-send is also used for cases like `git send-email --imap-sent-folder`, which would need to be taught *not* to mark the email as a draft, as in this case it has already been sent and should not be editable. We can change `send-email` to set that flag but this does not help any external tooling that might be relying on this behavior. Second, as `--draft` requires a relatively recent version of curl, or a (non-default) `--no-curl` flag, trying to turn it on would cause most current systems to continue *not* updating the flag, so in practice the behavior would change depending on the user's system libraries, which seems very unusual. (Or, if we changed the curl version check from warning to error, the command would default to being broken unless you pass `--no-draft`.)
quoted
+`--draft`:: +`--no-draft`:: + Mark uploaded messages with the IMAP `\Draft` flag. The default is `--no-draft`. ++ +With libcurl, `--draft` requires version 8.13.0 or later. +Older libcurl still uploads the message but cannot set the flag.When compiled with older libcurl, would the command error out when run with '--draft', or would it silently ignore the option? I have a mild preference for the former over the latter. Issuing a warning without erroring out is better than nothing, but people tend to overlook warning messages.
Right now it issues a warning. I don't think I had any particular reason for that decision and changing to an error seems fine.
Also you might want to consider adding a configuration variable, perhaps? I dunno.
I assume you mean something like `git config imap.draft true`? This has all the same problems as changing the default (in particular the `--imap-sent-folder` case), though I guess at least it would be opt-in. I also read in some past thread (I forget which) that we generally want to start by adding a flag, and only introduce a configuration if there is demand for it after the flag has proven itself.
Thanks.