send mail using telnet from script

If you have no other option but to use telnet with authentication to send mail 🙂

 ( echo "ehlo"
sleep 1
auth login
sleep 1
$(echo username |base64)
sleep 1
$(echo password |base64)
sleep 1
mail from: from-address
sleep 1
rcpt to: recepient
sleep 1
data
sleep 1
subject: test 
test mail
. 

exit ) |telnet server port