Setup smtp on your Mac and send mail from the command line
Install msmtp
and create a directory which will hold the ssl-certificates.
brew install msmtp mkdir -p ~/Dropbox/Public/ssl-certs
Create a system-wide config-file in /usr/local/Cellar/msmtp/1.6.6/etc/msmtprc
#file /usr/local/Cellar/msmtp/1.6.6/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 ~/Dropbox/Public/thawte_certs/thawte_Primary_Root_CA.pem # Set a default account # You need to set a default account for Mail account default : example@gmail.com # end msmtprc
Set up to use msmtp
echo set sendmail="/usr/local/bin/msmtp" > ~/.mailrc
Save your Gmail password in your keychain:
- open Keychain Access application on mac
- create new password item:
File > New Password Item
- Keychain Item Name: smtp://smtp.gmail.com
- Account Name (exactly as used in msmtprc): <address>@gmail.com
- Password: <gmail_password>