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.

11 comments:

  1. This was handy, thanks - you might want to update commands though, as new version of git 1.6.2.5 (F11) moves all git subcommands to be separate, as in 'git config' rather than 'git-config'

    ReplyDelete
  2. Thank you very much, this article really helped me!
    The same packaging bug I have found in my OpenSUSE, by the way.

    ReplyDelete
  3. Thanks for the post. It is very handy for quick reference, but particularly for explaining this to somebody else.

    ReplyDelete
  4. Same problem and solution for debian/squeeze

    sudo apt-get install git-email

    cpan Authen::SASL

    ReplyDelete
  5. how do i access this via a proxy ?
    I can reach smtp.gmail.com/587 but only by staying behind a proxy.

    ReplyDelete
  6. You saved me a lot of time!
    Thank you!

    ReplyDelete
  7. My kudos also for this writeup!

    I got the following error on my ubuntu (and expect the same on debian linux):
    Can't locate Net/SMTP/SSL.pm ...

    Fixed with:
    sudo apt-get install libnet-smtp-ssl-perl

    ReplyDelete