Ad support for Oauth2 and fix message-id bug in outlook
cover Ad support for Oauth2 and fix message-id bug in outlook
This pull request introduces 2 changes:
1. It adds support for Oauth2 authentication, which is now compulsory my Microsoft. This patch has been rebased to the latest version from the original version at
https://lore.kernel.org/git/[email protected]/
2. The second patch makes the script reply to the message id set by the outlook, since outlook has its own proprietary way to handle message ids, and does not allow user to set their own. As a result, threads were breaking.
Aditya Garg (1):
send-email: retrieve Message-ID from outlook SMTP server
Julian Swagemakers (1):
send-email: implement SMTP bearer authentication
Documentation/git-send-email.adoc | 5 ++- git-send-email.perl | 75 ++++++++++++++++++++++++++++++- 2 files changed, 78 insertions(+), 2 deletions(-)
base-commit: 4bbb303af69990ccd05fe3a2eb58a1ce036f8220
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1949%2FAdityaGarg8%2Fmaster-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1949/AdityaGarg8/master-v1
Pull-Request: https://github.com/git/git/pull/1949
Signature · 1 line
gitgitgadget
PATCH 1/2 send-email: implement SMTP bearer authentication
From: Julian Swagemakers <[email protected]>
Manually send SMTP AUTH command for auth type OAUTHBEARER and XOAUTH2. This is necessary since they are currently not supported by the Perls Authen::SASL module.
The bearer token needs to be passed in as the password. This can be done with git-credential-oauth[0] after minor modifications[1]. Which will allow using git send-email with Gmail and oauth2 authentication:
[credential]
helper = cache --timeout 7200 # two hours
helper = oauth
[sendemail]
smtpEncryption = tls
smtpServer = smtp.gmail.com
smtpUser = [email protected]
smtpServerPort = 587
smtpauth = OAUTHBEARER
As well as Office 365 accounts:
[credential]
helper = cache --timeout 7200 # two hours
helper = oauth
[sendemail]
smtpEncryption = tls
smtpServer = smtp.office365.com
smtpUser = [email protected]
smtpServerPort = 587
smtpauth = XOAUTH2
[0] https://github.com/hickford/git-credential-oauth
[1] https://github.com/hickford/git-credential-oauth/issues/48
--- Documentation/git-send-email.adoc | 5 ++- git-send-email.perl | 64 ++++++++++++++++++++++++++++++- 2 files changed, 67 insertions(+), 2 deletions(-)
Documentation/git-send-email.adoc +4 -1
@@ -213,7 +213,10 @@ SMTP server and if it is supported by the utilized SASL library, the mechanism is used for authentication. If neither 'sendemail.smtpAuth' nor `--smtp-auth` is specified, all mechanisms supported by the SASL library can be used. The special value 'none' maybe specified to completely disable authentication -independently of `--smtp-user` +independently of `--smtp-user`. Specifying `OAUTHBEARER` or `XOAUTH2` will +bypass SASL negotiation and force bearer authentication. In this case the +bearer token must be provided with `--smtp-pass` or using a credential helper +and `--smtp-encryption=tls` must be set. --smtp-pass[=<password>]:: Password for SMTP-AUTH. The argument is optional: If no
git-send-email.perl +63 -1
76 lines not on this page · raw message
Signature · 1 line
gitgitgadget
PATCH 2/2 send-email: retrieve Message-ID from outlook SMTP server
In reply to Aditya Garg via GitGitGadgetFrom: Aditya Garg <[email protected]>
Outlook does not accept the Message-ID header in the email body. Instead it saves it in its own proprietary X-Microsoft-Original-Message-ID header and a random Message-ID is set my the server. As a result, replying to threads does not work.
The $smtp->message variable in this script for outlook is something like this:
2.0.0 OK <Message-ID> [Hostname=Some-hostname]
This contains the Message-ID set by Microsoft in the first <>.
This patch retrieves the Message-ID from this server response and sets it in the email headers instead of using the self generated one.
--- git-send-email.perl | 11 +++++++++++ 1 file changed, 11 insertions(+)
git-send-email.perl +11 -0
@@ -1799,6 +1799,17 @@ EOF $smtp->datasend("$line") or die $smtp->message; } $smtp->dataend() or die $smtp->message; + + # Retrieve the Message-ID from the server response in case of Outlook + if ($smtp_server eq 'smtp.office365.com' || $smtp_server eq 'smtp-mail.outlook.com') { + if ($smtp->message =~ /<([^>]+)>/) { + $message_id = "<$1>"; + print __("Outlook: Retrieved Message-ID: $message_id\n"); + } else { + warn __("Warning: Could not retrieve Message-ID from server response.\n"); + } + } + $smtp->code =~ /250|200/ or die sprintf(__("Failed to send %s\n"), $subject).$smtp->message; } if ($quiet) {
Signature · 1 line
gitgitgadget