MSysGit:UsingSendEmail
OBSOLETE CONTENT
This wiki has been archived and the content is no longer updated. Please visit git-scm.com/doc for up-to-date documentation.
Contents |
Introduction
When submitting patches to git and/or msysgit, the preferred method is to inline the patch into an e-mail to the mailing list. This can be done through the send-email tool that comes with git.
Prerequisites
This guide assumes the following:
- Git for Windows / msysgit 1.6.4 (or later).
- An e-mail account that supports SMTP.
Details
git send-email for Windows currently supports sending e-mail through MSMTP, a command-line tool for sending mail. In order to do this, you need to configure msmtp to send e-mail through your e-mail provider's smtp-server. MSMTP is included in the msysgit distribution.
Configuring MSMTP
The msmtp configuration should be located in $HOME/msmtprc.txt (bash) or %USERPROFILE%\msmtprc.txt (cmd.exe). If the file doesn't exist, create it. The details on how to setup this configuration file can be found in the MSMTP Documentation.
Example MSMTP configuration for GMail
# setup some defaults defaults tls_trust_file c:/msysgit/mingw/bin/curl-ca-bundle.crt logfile ~/.msmtp.log # create an account called "default" account default # setup server host and port host smtp.gmail.com port 587 # enable TLS tls on # set FROM address from username@gmail.com # setup authentication auth on user username@gmail.com
Replace "username" with your own GMail username.
Testing MSMTP
Execute the command echo "test" | msmtp user@host
on the command line (where "user@host" should be your own e-mail address). This should work both from bash and cmd.exe. If you've set up msmtp to use authentication, you should get a password promtp. The program should exit cleanly, and an e-mail (with empty subject and the body "test") should have been sent to your e-mail account. If you don't get any e-mail, please consult the MSMTP Documentation.
Configuring git send-email
The Git for Windows installer should setup sendemail.smtpserver to "/mingw/bin/msmtp.exe". This can be verified by executing the command git config sendemail.smtpserver
. If this hasn't been set up yet, execute git config --global sendemail.smtpserver /mingw/bin/msmtp.exe
Testing git send-email
Go to a git-repo, and execute the following command:
git send-email --suppress-cc=all --to user@host HEAD^
(where user@host is replaced with your e-mail address). This should send the most recent patch from that repo to your e-mail account.
Troubleshooting
Unable to initialize SMTP
Unable to initialize SMTP properly. Is there something wrong with your config? at C:\msysgit/libexec/git-core/git-send-email line 929, <FIN> line 4.
This error is caused by git send-email
when it's trying to send the e-mail directly, and not through ESMTP. This can be caused either by lacking git-config, or by your git installation not being up to date.