There are two programs that I am aware of which will easily allow you to configure your Mac to send email from the command line.

I have written up HOWTOs for both of them:


mailsend
msmtp


Of the two, I suggest msmtp.

Configuration is complicated enough that I'm not sure if I should replicate all of the steps here, but I will mention that if you use
Homebrew
you can install msmtp using

brew install msmtp --with-macosx-keyring

Then the rest is just a matter of setting up the related configuration files

The first is /usr/local/etc/msmtprc

# Begin msmtprc
# Set default values for all following accounts.
defaults
tls on
logfile ~/.msmtp.log

# A first gmail address
account example@gmail.com
host smtp.gmail.com
port 587
protocol smtp
auth on
from example@gmail.com
user example@gmail.com
tls on
tls_starttls on

# this next line is crucial: you have to point to the correct security certificate for GMail.
# If this doesn't work, check the mstmp documentation
# at http://msmtp.sourceforge.net/documentation.html for help
#
# This next line should all be on one long line:
tls_trust_file /path/to/Thawte Roots/Thawte SSLWeb Server Roots/thawte Premium Server CA/Thawte Premium Server CA.pem

# Set a default account
# You need to set a default account for Mail
account default : example@gmail.com

# end msmtprc


Note that tls_trust_file line should point to wherever you have downloaded and installed the certificates from https://www.thawte.com/roots/index.html.

I put mine in ~/Dropbox/Thawte Roots so that I can have it on all of my Macs.

Then you need a ~/.mailrc file to say where the msmtp binary is located. If you use brew it will be /usr/local/bin/msmtp so the file would look like this:

set sendmail="/usr/local/bin/msmtp"


The last but crucial step is making sure your Keychain has the information exactly in the format that msmtp will expect it:



I think that covers most of the details. See http://www.tuaw.com/2010/05/04/msmtp-a-free-tool-to-send-email-from-terminal/ if you want a few more specifics.

How to send an email from command line?
We are currently investigating moving our current MySQL 5.5 Master > 5 x Slaves (with Statement Based Replication, apx 250GB data and growing) to a HA clustering option. Mainly to provide greater resilience, write scaling, and easier to carry out admin stuff like Optimising tables without taking the master offline.

We have ruled out (for the moment) MySQL ndb Cluster as it would require too many changes to our current database structure (large number of BLOB fields amongst other problems).

So we are looking at either Galera Cluster or Percona Cluster as the alternatives, as the they seem to do what we want, without 'too' steep a learning curve.

We would want to start off by setting the Cluster up as a Slave to the main Master (for testing etc), before moving over to the Cluster as our Primary system in the future. Is this possible? Reading through the documentation doesn't seem to really talk about this side of things (unless I've missed it).
