apt install postfix
apt install mailutils
cd /etc/postfix
vi /main.cf
comment
#smtp_tls_security_level=may
Add
relayhost = [smtp.gmail.com]:587
myhostname = prashant-server
and comment to old one
#myhostname = prashant-server.TL-WA850RE
And at the end of line
smtp_sasl_auth_enable = yes
smtp_tls_security_level = encrypt
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
smtp_sasl_security_options = noanonymous
save the file
++++
cd sasl
touch sasl_passwd
vi sasl_passwd
add following
[smtp.gmail.com]:587 xyz@gmail.com:apppassword
then save and exit
then make the db file with following command
postmap sasl_passwd
after that you may remove the sasl_passwd as new sasl_passwd.db file has been
created and will be used for sending email
To send the email run following command
echo "This is Mail Content" | mail -s "Subject of Mail"
prashantsinharanchi@gmail.com
To send email with attachment use following command
echo "This is Mail Content" | mail -s "Subject of Mail" -A file1
prashantsinharanchi@gmail.com