git send-email not working on macOS?

I just spent 2 hours trying to send a patch to a mailing list via git send-email on my MacBook Pro, and kept getting this error:

$ git send-email --to="<mailing_list>" HEAD^ Unable to initialize SMTP properly. Check config and use --smtp-debug. VALUES: server=smtp.migadu.com encryption=tls hello=localhost.localdomain port=465 at /usr/local/Cellar/git/2.30.2/libexec/git-core/git-send-email line 1566, <FIN> line 1.
Code language: Shell Session (shell)

If you include --smtp-debug=1 in your command, you might see something like this:

$ git send-email --to="<mailing_list>" HEAD^ --smtp-debug=1 Net::SMTP>>> Net::SMTP(3.11) Net::SMTP>>> Net::Cmd(3.11) Net::SMTP>>> Exporter(5.73) Net::SMTP>>> IO::Socket::IP(0.39) Net::SMTP>>> IO::Socket(1.39) Net::SMTP>>> IO::Handle(1.39) Net::SMTP: Net::Cmd::getline(): unexpected EOF on command channel: at /usr/local/Cellar/git/2.30.2/libexec/git-core/git-send-email line 1539. Unable to initialize SMTP properly. Check config and use --smtp-debug. VALUES: server=smtp.migadu.com encryption=tls hello=localhost.localdomain port=465 at /usr/local/Cellar/git/2.30.2/libexec/git-core/git-send-email line 1566, <FIN> line 1.
Code language: Shell Session (shell)

After spending 2 hours trying to find a fix for this online, the solution turns out to be simple: set smtpEncryption to ssl in your git config.

See, I recently moved my email provider from Mailbox.org to Migadu, and as per Migadu documentation I set smtpEncryption to tls. No amount of tweaking configs, git send-email parameters, or updating perl packages seemed to fix the issue.

Finally, when I notice that my previous config used ssl instead of tls I tried to change the value and that worked!

So, if whoever lands here is having the same issue, just try setting smtpEncryption to ssl instead of tls and see if that works. Even if your email provider says to use tls.

Example configuration:

[sendemail] smtpServer = smtp.migadu.com smtpUser = <smtp_username> smtpEncryption = ssl smtpServerPort = 465
Code language: TOML, also INI (ini)

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.