this post is about going back to basics, how to send an email from shell, even though that’s basic however still its one of the things you need once a while and when you do usually you have to google it cause you forgot all about it, so here it goes.
basically sending mail from shell is easy, you need one of the following packages to do it:
All packages build on top of mail, however they provide simpler interfaces that can be easily integrated into scripts, basically mailx and mail are really similar, sending an email using either only requires the following
echo “email body”| mailx -s “subject” firstname.lastname@example.org
sendmail provides more functionality with an easier way to set the from address (to avoid being caught in the recipients proxy) by modifying its config file, also you can easily send files using it.
sendmail -v user@domainname < test.mail
Even simpler if you want a simpler way to use a from email address use the following command