sSMTP is a light STMP agent, it allows to send emails from command line.
sudo apt install ssmtp
Apply configuration:
sudo vim /etc/ssmtp/ssmtp.conf
mailhub=smtp.mail.com:25 rewriteDomain=mail.com FromLineOverride=YES #UseTLS=YES #AuthUser=user@mail.com #AuthPass=secretpasswd
Note: Security/Authentication info can be enabled, depending of upstream server requirements
When adding email password in configuration file, make sure to protect that file
sudo chmod 600 /etc/ssmtp/ssmtp.conf
ssmtp some.one@somewhere.com << EOF
From: sSMTP <ssmtp&here.com>
To: Some One <some.one&somewhere.com>
Subject: Helo Some One
Content-Type: text/html
Mime-Version: 1.0
<html><body>
<h1>This is an automatic email</h1>
<p>sSMTP says <b>hello</b></p>
</body></html>
.
EOF
openssl can be used to connect to mail server
openssl s_client -starttls smtp -connect smtp.gmail.com:587 -crlf <<EOF
EHLO tognoli.fr
AUTH login
$(printf user@server | base64)
$(printf passwd | base64)
mail from:openssl.client@gmail.com
rcpt to:some.one@somewhere.com
Data
From: openssl.client@gmail.com
To: some.one@somewhere.com
Subject: A new email
Sent from openssl.
.
EOF
curl can be used to send emails