Send patches from git send-email through Gmail using the Gmail API instead of SMTP.
https://github.com/cyrozap/sendgmail.git
sendgmail is a tool that enables git send-email to send patches from a Gmail account without using SMTP.
This tool has been modified from its original version. This new version, inspired by siketyan/sendgmail, uses the Gmail users.messages.send API to send the email instead of using SMTP. This has the following advantages:
[!CAUTION]
Unfortunately, it seems that sending patches via the Gmail API has some of the same limitations as sending via the Web UI.
Namely, that some patches will get mangled by Gmail's insistence on line-wrapping certain long lines in plaintext emails.
To avoid sending corrupted patches to public mailing lists,sendgmailautomatically detects patches that are likely to be mangled by Gmail and will refuse to send them.
sendgmailgo install github.com/cyrozap/sendgmail@latest
This will install sendgmail to $GOPATH/bin/sendgmail.
sendgmail).sendgmail project.sendgmail.sendgmail, or leave it as-is.sendgmail -setup on the same computer that your browser is logged in to, set the URI to http://localhost:8080/oauth2callback.sendgmail -setup to listen on that port for your browser to send it the authorization code.sendgmail -setup is not able to listen on port 8080 on your computer.127.0.0.1 or [::1]) as the host instead of localhost, if you prefer.sendgmail -setup on a different computer from the one that your browser is on, set the URI to https://google.github.io/gmail-oauth2-tools/html/oauth2.dance.html.sendgmail -setup.sendgmail configuration directory:CONFIG_DIR="${XDG_CONFIG_HOME:-${HOME}/.config}/sendgmail"
mkdir -p "$CONFIG_DIR"
chmod 700 "$CONFIG_DIR"
# Move the credentials file (must be named "config.json")
mv path/to/credentials.json "$CONFIG_DIR"/config.json
chmod 600 "$CONFIG_DIR"/config.json
gmail.send API scopegmail.send and press the Enter/Return key.Run the following command to perform the OAuth2 authorization:
# Replace with your Gmail address
$GOPATH/bin/sendgmail -sender=USERNAME@gmail.com -setup
Follow the remaining steps in your browser.
If you set the Authorized redirect URI to a local URL, then at the end of the process the token will automatically be sent to sendgmail.
If you instead set it to .../oauth2.dance.html, then you'll have to copy the code and paste it where prompted by sendgmail.
[!NOTE]
This assumes you've completed the OAuth2 setup.
Add the following section to .gitconfig in your home directory:
[sendemail]
smtpServer = /full/path/to/sendgmail # From $GOPATH/bin/sendgmail or custom path
smtpServerOption = -sender=USERNAME@gmail.com