imap-send: add ability to list the available folders
Various IMAP servers have different ways to name common folders.
For example, the folder where all deleted messages are stored is often
named "[Gmail]/Trash" on Gmail servers, and "Deleted" on Outlook.
Similarly, the Drafts folder is simply named "Drafts" on Outlook, but
on Gmail it is named "[Gmail]/Drafts".
This commit adds a `--list` command to the `imap-send` tool that lists
the available folders on the IMAP server, allowing users to see
which folders are available and how they are named. A sample output
looks like this when run against a Gmail server:
Fetching the list of available folders...
* LIST (\HasNoChildren) "/" "INBOX"
* LIST (\HasChildren \Noselect) "/" "[Gmail]"
* LIST (\All \HasNoChildren) "/" "[Gmail]/All Mail"
* LIST (\Drafts \HasNoChildren) "/" "[Gmail]/Drafts"
* LIST (\HasNoChildren \Important) "/" "[Gmail]/Important"
* LIST (\HasNoChildren \Sent) "/" "[Gmail]/Sent Mail"
* LIST (\HasNoChildren \Junk) "/" "[Gmail]/Spam"
* LIST (\Flagged \HasNoChildren) "/" "[Gmail]/Starred"
* LIST (\HasNoChildren \Trash) "/" "[Gmail]/Trash"
For OpenSSL, this is achived by running the 'IMAP LIST' command and
parsing the response. This command is specified in RFC6154:
https://datatracker.ietf.org/doc/html/rfc6154#section-5.1
For libcurl, the example code published in the libcurl documentation
is used to implement this functionality:
https://curl.se/libcurl/c/imap-list.html
Signed-off-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
3168514e6b
commit
067a91b03f
@@ -10,6 +10,7 @@ SYNOPSIS
|
||||
--------
|
||||
[verse]
|
||||
'git imap-send' [-v] [-q] [--[no-]curl] [(--folder|-f) <folder>]
|
||||
'git imap-send' --list
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
@@ -54,6 +55,8 @@ OPTIONS
|
||||
using libcurl. Ignored if Git was built with the NO_OPENSSL option
|
||||
set.
|
||||
|
||||
--list::
|
||||
Run the IMAP LIST command to output a list of all the folders present.
|
||||
|
||||
CONFIGURATION
|
||||
-------------
|
||||
@@ -123,7 +126,8 @@ it. Alternatively, use OAuth2.0 authentication as described below.
|
||||
|
||||
[NOTE]
|
||||
You might need to instead use: `folder = "[Google Mail]/Drafts"` if you get an error
|
||||
that the "Folder doesn't exist".
|
||||
that the "Folder doesn't exist". You can also run `git imap-send --list` to get a
|
||||
list of available folders.
|
||||
|
||||
[NOTE]
|
||||
If your Gmail account is set to another language than English, the name of the "Drafts"
|
||||
|
||||
Reference in New Issue
Block a user