sudo apt install mailutils
sudo apt-get install ssmtp
cat /etc/ssmtp/ssmtp.confmailhub=email.firm.com:25 <smpt server>
Then there are multiple ways to it
cat tempTo: harshal.patil@adyne.comSubject: Some Notifying EmailMIME-Version: 1.0Content-Type: text/plainBody of your email goes here. Hello world
cat temp | sendmail -i -t
echo -e "To: harshal.patil@firm.com\nSubject: Subject\nContent-type: text/html" | cat - /stage/qspc/projects/sas/tools/sas_slippage_outliers.html | sendmail -i -t
52 07 * * 1-5 echo "To: harshal.patil@firm.com, harshal.patil@firm.com \nSubject: Slippage Outliers $(date +\%F) \nContent-type: text/html\n\n" > /tmp/email_body.txt;cat /stage/qspc/projects/sas/tools/sas_slippage_outliers.html >> /tmp/email_body.txt;cat /tmp/email_body.txt | /usr/sbin/sendmail -i -t > /stage/qspc/logs/sendmail/$(date +\%d).log 2>&1
If wanted to attach as a file (when html contains graphs):
(cat /stage/qspcadmin/logs/sendmail/intraday_liquidation.header ; uuencode /stage/qspcadmin/projects/sas/tools/intraday_liquidation.html intraday_liquidation.html) | /sbin/sendmail -i -t
where
$ cat /stage/qspcadmin/logs/sendmail/intraday_liquidation.header
#To: harshal.patil@firm.com, a.b@firm.com
To: harshal.patil@firm.com
Subject: Intraday Strategy Liquidation
(echo "From: sender@example.com"echo "To: recipient@example.com"echo "Subject: Embedded Image"echo "MIME-Version: 1.0"echo 'Content-Type: multipart/related; boundary="boundary123"'echo ""echo "--boundary123"echo "Content-Type: text/html; charset=UTF-8"echo ""echo '<html><body>'echo '<p>Here is an embedded image:</p>'echo '<img src="cid:myimage" width="600" height="400">'echo '</body></html>'echo ""echo "--boundary123"echo "Content-Type: image/jpeg"echo 'Content-Transfer-Encoding: base64'echo 'Content-Disposition: inline; filename="image.jpg"'echo 'Content-ID: <myimage>'base64 image.jpgecho "--boundary123--") | sendmail -t