SMTP (Simple Mail Transfer Protocol) or SMTP (Secure Simple Mail Transfer Protocol) is a program used to deliver emails from a local computer to a configured mailhost (mailhub — Here Gmail will be used.). It is sometimes paired with other libraries e.g Mailutils, Mutt, etc.
Installing Packages.
For SSMTP
# apt-get install ssmtp
For Mailtulis
# apt-get install mailutils
For Mutt:
# apt-get install mutt
Confirm that all packages have been correctly installed
edit the SSMTP configuration file.
# nano /etc/ssmtp/ssmtp.conf
edit the contents of your ssmtp.conf file

Outgoing mail server (SMTP server) or mailhub=smtp.gmail.com:587
[email protected]
AuthUser=your Gmail address([email protected])
AuthPass=your generate gmail app password UseTLS=YES
UseSTARTTLS=YES FromLineOverride=NO

Now you are all set to send emails from the command line. Use the command below to test it out.
echo "Testingclear!" | mail -s "Test Email" y[email protected]

The email setup is done and working properly!!!!