Thursday, October 28, 2010

git-send-email on Mac OS X with SMTP SSL

If you are using MacPorts, then you can get git just by typing sudo port install git-core. That gives you a pretty usable git installation. What this however does not give you is out-of-the-box working git-send-email when you are using SMTP with SSL or TLS.

To get it working, first install the needed Perl modules that are available from MacPorts:

sudo port install p5-authen-sasl p5-mime-base64 p5-io-socket-ssl

The only missing module now is p5-net-smtp-ssl. Since it's not in MacPorts, you will have to use CPAN to install it (thanks for how to do it goes to this article):

sudo -H cpan Net::SMTP::SSL

(This was the first time I was using cpan, so I gave it green light when it asked whether to set up as much as possible automatically.)

Now git-send-email should work with SMTP SSL, provided you have configured your git appropriately. An imaginary person would have a config like this (e.g. in his/her .git/config in the repository directory)

[sendemail]
chainreplyto = false
from = John Smith <john.smith@company.com>
to = project-patches@lists.company.com
suppresscc = self
smtpserver = smtp.company.com
smtpserverport = 33141
smtpuser = smithj
smtpencryption = tls

Then if you are on a topic branch you created just for this feature/bug fix, you can send the patches to the configured mailing list as:

git send-email master..

And if you want just one line for each email sent, just add the -q flag after send-email. Happy sending!

P.S.: What I was getting at first was "Command unknown: 'AUTH' at /opt/local/libexec/git-core/git-send-email line 1093, line 1." This was due to misspelling in the configuration file - I used "smtencryption" instead of "smtpencryption" key.