Skip to content

Instantly share code, notes, and snippets.

Last active March 11, 2024 23:26
Show Gist options
  • Save jasonkarns/4354421 to your computer and use it in GitHub Desktop.
Save jasonkarns/4354421 to your computer and use it in GitHub Desktop.
Git send-email using Gmail
  1. Configure git.
# ~/.config/git/config
  confirm = auto
  smtpServer =
  smtpServerPort = 587
  smtpEncryption = tls
  smtpUser = <gmail email address>
  1. Configure Authentication.

I believe the simplest setup is to create an application-specific password in Google dedicated to git.

Google Account -> Security -> Signing in to Google : App passwords

This password must be configured in git, but should be kept outside of your main gitconfig (which is likely versioned via a dotfile repo?). To do that, I use git's [include] directive.

# ~/.config/git/config
  path = config.local # (relative or absolute path to the other config file)
# ~/.config/git/config.local
  smtpPass = <app-specific-password>

Alternatively, check out which supports authenticating to GMail with OAuth2.

  1. Determine your revlist.

To send a single commit, just use the sha. To send a range of commits, you can use start_sha..end_sha. Most likely, you'll want to send the commits made to a branch that are missing in upstream. For that, you would use: upstream/branch_name..branch_name You can also use relative numbers to indicate the "previous X commits". e.g. git send-email -3

  1. Send email:
git send-email <revlist> --to <>
  1. If you receive an error like this:
Can't locate Net/SMTP/ in @INC (@INC contains: ...

You may need to upgrade/install the Net::SMTP::SSL or IO::Socket::SSL packages:

sudo -H cpan Net::SMTP::SSL
sudo -H cpan IO::Socket::SSL
  1. Advanced: configure multiple identites. You may configure multiple smtp servers and switch between them with identities.
[sendemail "gmail"]
  smtpUser =
  smtpServer =

[sendemail "outlook"]
  smtpUser =
  smtpServer =
  identity = outlook
Copy link

hitmoon commented Jul 16, 2021

After a great deal of effort, I got it all working. See my full instructions on Stack Overflow now, here:

great work !

Copy link

bensuperpc commented Aug 21, 2021

On Manjaro (21.08), git config: ~/.gitconfig
And need these packages: perl-mime-tools perl-authen-sasl

Copy link

ghost commented Mar 7, 2022

I had to turn on "less secure apps" at to make this work.

This will no longer work after May 30, as of Google said to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment