Add an interactive setup wizard for the Gmail API, OAuth consent screen, audience, test users, client creation, browser authorization, and git send-email configuration. Add a doctor command, private atomic credential storage, clearer command errors, and callback lifecycle tests. Update the README to match the complete guided flow. Signed-off-by: Christian Stewart <christian@aperture.us>
SendGmailAPI
Send emails with git send-email over the Gmail API.
Introduction
SendGmailAPI is a Go application that allows you to send emails using the Gmail
API. It's particularly useful for developers who want to use git send-email
with their Gmail account, bypassing the need for SMTP configuration.
Gmail rewrites long lines in unencoded plain-text messages. SendGmailAPI avoids that rewrite by converting plain-text message bodies to quoted-printable MIME. The transport lines remain within the MIME limit, and the recipient's mail client reconstructs the original patch lines.
Quick start
Install the command:
go install github.com/paralin/sendgmailapi@latest
Start the interactive setup wizard:
sendgmailapi setup
The wizard opens each Google Cloud page and pauses while you complete these steps:
- Select or create a Google Cloud project and enable the Gmail API.
- Configure the OAuth consent screen in Google Auth Platform. Enter the app name and contact email, choose Internal only for the intended Google Workspace organization, or choose External, then finish and save the initial app configuration.
- After saving the app, open Data Access, click Add or remove scopes,
select
https://www.googleapis.com/auth/gmail.send, click Update, and save the Data Access changes. - For an External app in Testing, open Audience and add your Gmail address under Test users. Google may expire refresh tokens after seven days while the app remains in Testing. Move it to Production for lasting authorization; Google may show an unverified-app warning or require verification.
- Create a Web application OAuth client. Add
http://localhost:8090under Authorized redirect URIs exactly as shown. - Download the client JSON. The wizard finds it in
~/Downloads, or asks for its path. - Sign in to Google and approve the
gmail.sendpermission. - Let the wizard configure
git send-email.
Use the same Google Cloud project for the Gmail API, consent screen, audience,
and OAuth client. Enter an app name such as SendGmailAPI, and select your
email address for the user-support and developer-contact fields.
You can also give the downloaded file directly:
sendgmailapi setup ~/Downloads/client_secret_....json
If the Google consent screen is in testing mode, add your Gmail account as a
test user before signing in. The wizard stores the OAuth client and token with
private file permissions under ~/.config/sendgmail/.
Check the setup without sending mail:
sendgmailapi doctor
Send patches
After setup, use git send-email normally:
git send-email --to recipient@example.com outgoing/*.patch
SendGmailAPI runs as the configured sendmail command. It converts plain-text messages to quoted-printable MIME before calling the Gmail API, so Gmail does not wrap long patch lines.
Other commands
Send an RFC 5322 message directly:
cat message.eml | sendgmailapi
Inspect the Gmail-safe MIME without sending it:
sendgmailapi encode < message.eml
Show command help:
sendgmailapi help
The legacy -setup and -encode-only flags remain available.
License
MIT