I am working on a KornShell (ksh) script running on a Solaris server that will send out an email when and error condition is met. I am sending the email via mailx
On macOS Sierra, creating ~/.mailrc with smtp setup did the trick:
set smtp-use-starttls
set smtp=smtp://smtp.gmail.com:587
set smtp-auth=login
set smtp-auth-user=youremail@gmail.com
set smtp-auth-password=yourpass
Then to send mail from CLI:
echo "your message" | mail -s "your subject" to_email@gmail.com