Skip to content

Commit b9c0f0d

Browse files
committed
Merge branch 'ag/imap-send-resurrection' into seen
* ag/imap-send-resurrection: imap-send: add ability to list the available folders imap-send: display the destination mailbox when sending a message imap-send: display port alongwith host when git credential is invoked imap-send: fix minor mistakes in the logs imap-send: enable specifying the folder using the command line imap-send: fix memory leak in case auth_cram_md5 fails imap-send: add PLAIN authentication method to OpenSSL imap-send: add support for OAuth2.0 authentication imap-send: fix bug causing cfg->folder being set to NULL
2 parents 54e9793 + 08d9420 commit b9c0f0d

File tree

3 files changed

+429
-56
lines changed

3 files changed

+429
-56
lines changed

Documentation/config/imap.adoc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
imap.folder::
22
The folder to drop the mails into, which is typically the Drafts
3-
folder. For example: "INBOX.Drafts", "INBOX/Drafts" or
4-
"[Gmail]/Drafts". Required.
3+
folder. For example: 'INBOX.Drafts', 'INBOX/Drafts' or
4+
'[Gmail]/Drafts'. Required if `--folder` argument is not used. If
5+
set and `--folder` is also used, `--folder` will be preferred.
56

67
imap.tunnel::
78
Command used to set up a tunnel to the IMAP server through which
@@ -40,5 +41,6 @@ imap.authMethod::
4041
Specify the authentication method for authenticating with the IMAP server.
4142
If Git was built with the NO_CURL option, or if your curl version is older
4243
than 7.34.0, or if you're running git-imap-send with the `--no-curl`
43-
option, the only supported method is 'CRAM-MD5'. If this is not set
44-
then 'git imap-send' uses the basic IMAP plaintext LOGIN command.
44+
option, the only supported methods are 'PLAIN', 'CRAM-MD5', 'OAUTHBEARER'
45+
and 'XOAUTH2'. If this is not set then `git imap-send` uses the basic IMAP
46+
plaintext LOGIN command.

Documentation/git-imap-send.adoc

Lines changed: 59 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,24 @@ git-imap-send - Send a collection of patches from stdin to an IMAP folder
99
SYNOPSIS
1010
--------
1111
[verse]
12-
'git imap-send' [-v] [-q] [--[no-]curl]
12+
'git imap-send' [-v] [-q] [--[no-]curl] [(--folder|-f) <folder>]
13+
'git imap-send' --list
1314

1415

1516
DESCRIPTION
1617
-----------
17-
This command uploads a mailbox generated with 'git format-patch'
18+
This command uploads a mailbox generated with `git format-patch`
1819
into an IMAP drafts folder. This allows patches to be sent as
1920
other email is when using mail clients that cannot read mailbox
2021
files directly. The command also works with any general mailbox
21-
in which emails have the fields "From", "Date", and "Subject" in
22+
in which emails have the fields 'From', 'Date', and 'Subject' in
2223
that order.
2324

2425
Typical usage is something like:
2526

26-
git format-patch --signoff --stdout --attach origin | git imap-send
27+
------
28+
$ git format-patch --signoff --stdout --attach origin | git imap-send
29+
------
2730

2831

2932
OPTIONS
@@ -37,6 +40,11 @@ OPTIONS
3740
--quiet::
3841
Be quiet.
3942

43+
-f <folder>::
44+
--folder=<folder>::
45+
Specify the folder in which the emails have to saved.
46+
For example: `--folder=[Gmail]/Drafts` or `-f INBOX/Drafts`.
47+
4048
--curl::
4149
Use libcurl to communicate with the IMAP server, unless tunneling
4250
into it. Ignored if Git was built without the USE_CURL_FOR_IMAP_SEND
@@ -47,6 +55,8 @@ OPTIONS
4755
using libcurl. Ignored if Git was built with the NO_OPENSSL option
4856
set.
4957

58+
--list::
59+
Run the IMAP LIST command to output a list of all the folders present.
5060

5161
CONFIGURATION
5262
-------------
@@ -102,20 +112,56 @@ Using Gmail's IMAP interface:
102112

103113
---------
104114
[imap]
105-
folder = "[Gmail]/Drafts"
106-
host = imaps://imap.gmail.com
107-
108-
port = 993
115+
folder = "[Gmail]/Drafts"
116+
host = imaps://imap.gmail.com
117+
118+
port = 993
109119
---------
110120

121+
Gmail does not allow using your regular password for `git imap-send`.
122+
If you have multi-factor authentication set up on your Gmail account, you can generate
123+
an app-specific password for use with `git imap-send`.
124+
Visit https://security.google.com/settings/security/apppasswords to create it.
125+
Alternatively, use OAuth2.0 authentication as described below.
126+
111127
[NOTE]
112128
You might need to instead use: `folder = "[Google Mail]/Drafts"` if you get an error
113-
that the "Folder doesn't exist".
129+
that the "Folder doesn't exist". You can also run `git imap-send --list` to get a
130+
list of available folders.
114131

115132
[NOTE]
116133
If your Gmail account is set to another language than English, the name of the "Drafts"
117134
folder will be localized.
118135

136+
If you want to use OAuth2.0 based authentication, you can specify `OAUTHBEARER`
137+
or `XOAUTH2` mechanism in your config. It is more secure than using app-specific
138+
passwords, and also does not enforce the need of having multi-factor authentication.
139+
You will have to use an OAuth2.0 access token in place of your password when using this
140+
authentication.
141+
142+
---------
143+
[imap]
144+
folder = "[Gmail]/Drafts"
145+
host = imaps://imap.gmail.com
146+
147+
port = 993
148+
authmethod = OAUTHBEARER
149+
---------
150+
151+
Using Outlook's IMAP interface:
152+
153+
Unlike Gmail, Outlook only supports OAuth2.0 based authentication. Also, it
154+
supports only `XOAUTH2` as the mechanism.
155+
156+
---------
157+
[imap]
158+
folder = "Drafts"
159+
host = imaps://outlook.office365.com
160+
161+
port = 993
162+
authmethod = XOAUTH2
163+
---------
164+
119165
Once the commits are ready to be sent, run the following command:
120166

121167
$ git format-patch --cover-letter -M --stdout origin/master | git imap-send
@@ -124,6 +170,10 @@ Just make sure to disable line wrapping in the email client (Gmail's web
124170
interface will wrap lines no matter what, so you need to use a real
125171
IMAP client).
126172

173+
In case you are using OAuth2.0 authentication, it is easier to use credential
174+
helpers to generate tokens. Credential helpers suggested in
175+
linkgit:git-send-email[1] can be used for `git imap-send` as well.
176+
127177
CAUTION
128178
-------
129179
It is still your responsibility to make sure that the email message

0 commit comments

Comments
 (0)