Skip to content
Tutorials Center
My learning

Topics

Git Reference ยท Remotes and Collaboration

git send-email command

Reference for git send-email: configure SMTP, send format-patch series with a cover letter, use --dry-run, threading, --to/--cc and the sendemail.* settings.

git send-email sends patch files, usually the output of git format-patch, as emails through an SMTP server or a local sendmail program. It sets the threading headers so that a series arrives as one conversation, adds recipients, and can ask for confirmation before each send.

Projects that review on mailing lists (the Linux kernel, Git itself and many others) expect patches this way. The command is written in Perl and needs the Net::SMTP and Authen::SASL modules for authenticated servers. This site's runner has neither Perl nor a network, so the examples below prepare and inspect everything that send-email consumes without sending a message.

Terminal
git send-email [options] <file|directory|revision-range>...

Try it

Bash Configure and prepare a series

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Bash Threading headers come from the sender

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Syntax

Terminal
git send-email [--to=<addr>] [--cc=<addr>] [--bcc=<addr>] [--from=<addr>]
               [--smtp-server=<host>] [--smtp-encryption=tls|ssl]
               [--compose] [--annotate] [--dry-run] [--thread] [--confirm=<mode>]
               [--in-reply-to=<message-id>] [--8bit-encoding=<enc>] <patches>
Option Description
--to, --cc, --bcc Recipients. May repeat. sendemail.to and friends provide defaults.
--from=<address> Sender. Defaults to the committer identity, then sendemail.from.
--smtp-server=<host or path> An SMTP host, or the full path of a sendmail-compatible program (default /usr/sbin/sendmail, then localhost).
--smtp-server-port, --smtp-encryption, --smtp-user, --smtp-pass Connection details. Use a credential helper instead of storing the password in config.
--compose Open the editor for a cover letter before sending.
--annotate Open each patch in the editor for last-minute notes.
--dry-run Do everything except actually send, and print what would happen.
--confirm=(always|never|cc|compose|auto) When to ask before sending.
--thread, --no-thread Add In-Reply-To and References so patches are replies to the first message (default on).
--in-reply-to=<id> Attach the series to an existing conversation, for example when sending a new version.
--suppress-cc=<category> Stop adding automatic Cc addresses (author, self, sob, cc, bodycc, misc-by, cccmd, all).
--cc-cmd=<command> Command that prints extra Cc addresses for each patch.
--validate, --no-validate Run the sendemail-validate hook and basic checks (default on).
--identity=<name> Use the named sendemail.<name>.* group of settings.

Usage notes

  • Passing revisions. You can give a range like base..HEAD instead of files; send-email then runs format-patch for you.
  • Test first. --dry-run shows recipients and subjects. A common habit is to send the series to yourself before the list.
  • Threading and versions. Send version 2 as a new thread with -v2 patches, or reply into the old one with --in-reply-to if the project prefers that.
  • Gmail and other providers require app passwords or OAuth; plain account passwords are rejected. Use smtpEncryption with port 587 (tls) or 465 (ssl).
  • Dependencies. Without Net::SMTP::SSL or Authen::SASL the command fails at connect time with a message naming the module. Install the Perl packages from your system.
  • Before sending the sendemail-validate hook can reject a series; see sendemail-validate.
  • Mail clients are not needed; send-email speaks SMTP directly.