Install nullmailer (very simple mail transport agent)

# preconfigure nullmailer
debconf-set-selections <<\EOF
nullmailer shared/mailname string YOUR_HOST_NAME
nullmailer nullmailer/relayhost string YOUR_SMTP_HOST smtp --auth-login --user=YOUR_SMTP_USER --pass=YOUR_SMTP_PASS
EOF
 
# install nullmailer
apt-get install -y nullmailer
 
# configure mailname
echo "YOUR_DOMAIN" > /etc/mailname
 
# send test email
echo "This is a test message from ${USER}@${HOSTNAME} at $(date)" | sendmail YOU@YOUR_MAIL.COM
 
 
# ToDo: send mail with subject?
-F Set the full name of the sender for example info@example.com
echo "Subject: Testing" | sendmail ...
 
 
# reconfigure
echo "YOUR_DOMAIN.com" > /etc/mailname
echo "smtp YOUR_SMTP_SERVER --auth-login --user=SMTP_USER --pass=SMTP_PASS" > /etc/nullmailer/remotes

Do you like this page? Then support it. Please click the AD below and visit the sponsor. Thank you!