How to send email from OS X command line

Solution 1:

Sendemail works great with Gmail and all other SMTP servers I have ever tried:

brew update
brew install sendemail
man sendemail

Edit: Thanks for the edit/link/clarification, @patrick.

I also wanted to clarify that I have always used sendemail flawlessly on Debian-based systems, but encountered TLS error after upgrading from OS X Mountain Lion to Mavericks when Mavericks was first released. I don't recall if I even tried to uninstall/re-install from a "Mavericks bottle", but I believe the problem actually had to do with Google updating their accepted handshake protocols or whatnot around this time.

The fix was easily-found by Googling and involved editing a line in the sendemail config to [I believe] remove a reference to SSL and replace it with TLS 1.1 (or something of the sort).

I'm sure sendemail itself has been upgraded since then to account for this, because I believe I have used it successfully since then on both OS X Yosemite and El Capitan with Gmail without having to make any weird modifications to the configuration.

It truly is a great program, and I cannot give it enough praises. If any of you are familiar with blat for Windows, sendemail is like that, except much more powerful and very easy to use.