Subject: Re: [PATCH] imap-send: add option to mark sent messages as read or unread

From: Junio C Hamano <[email-masked]>
Date: Wed, 23 Jul 2025 10:25:42 -0700

Aditya Garg <[email-masked]> writes:

> +imap.markAsRead::
> +	Choose whether to mark the sent message as read or not.

Is this something user typically want to use a single setting,
or would it often be per invocation?  Especially with the new
invoker in send-email, wouldn't it become more like "if I use
imap-send to stuff things in my outgoing folder, they shouldn't be
marked as read, but fcc copies send-email stuffs via imap-send
should be marked as read" or something like that?

> +	Default is `true`.

If we never marked these messages as read, then this default is a
breaking change, isn't it?

> @@ -47,11 +47,12 @@
>  
>  static int verbosity;
>  static int list_folders;
> +static int mark_seen = 1;

IOW, this smells problematic.

> +	if (mark_seen) {
> +		ret = imap_exec_m(ctx, &cb, "APPEND \"%s%s\" (\\Seen) ", prefix, box);
> +	} else {
> +		ret = imap_exec_m(ctx, &cb, "APPEND \"%s%s\" ", prefix, box);
> +	}

Why so many braces around single-statement blocks?

> @@ -1702,6 +1710,12 @@ static int curl_append_msgs_to_imap(struct imap_server_conf *server,
>  	curl_easy_setopt(curl, CURLOPT_READFUNCTION, fread_buffer);
>  	curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
>  
> +	if (mark_seen) {
> +		curl_easy_setopt(curl, CURLOPT_UPLOAD_FLAGS, CURLULFLAG_SEEN);
> +	} else {
> +		curl_easy_setopt(curl, CURLOPT_UPLOAD_FLAGS, 0L);
> +	}
> +

Why so many braces around single-statement blocks?

According to

https://github.com/curl/curl/blob/master/docs/libcurl/symbols-in-versions

CURLULFLAG_SEEN first appeared in 8.13.0; INSTALL says we require 7.61.0
or later, so this may be OK.