Thursday, February 19, 2009

Configuring git send-email to use Gmail SMTP

Lately, I am using git for tracking my work on upstream sources.

When I decided to actually send one patch to a project's mailing list, I found it natural to attempting it the git's way, which is by using the git send-email command.

Now, it turned out I had to overcome some hurdles to be actually able to send the email from my Fedora 10, using Gmail as the outgoing SMTP server.

First problem, if you previously installed git with yum install git that does not include the send-email command; fix this with yum install git-email.

Then, add the correct configuration variables with the following:

$ git config --global sendemail.smtpserver smtp.gmail.com
$ git config --global sendemail.smtpserverport 587
$ git config --global sendemail.smtpencryption tls
$ git config --global sendemail.smtpuser your_email@gmail.com


Now it's ready: the command git send-email patch-name will ask you for some info about the email sender (you can change the From: field) and recipient, your Gmail password and then it will send the email.

Optionally, it is possible to skip the password prompt by adding it to the configuration with:
$ git config --global sendemail.smtppass your_password

Lastly, I found a packaging bug so that git-email does not pull some perl libraries required for this to work, so I had to manually install perl-Authen-SASL (yum install perl-Authen-SASL).

UPDATE: The packaging bug is now fixed, and the commands were updated to also work Fedora 11.