Install Send Only SMTP Server
Setup a Postfix Send Only SMTP Server
Note that in recent years, this has become increasingly more unreliable due to many cloud providers blocking outbound SMTP by default.
But, if you still want to try, then the commands for Ubuntu are
sudo apt install mailutils
A postfix config screen should appear,
Choose internet site from the choices.
Enter the mail servers name, I will use my existing Prometheus domain I've already setup.
Then configure postfix by calling
sudo nano /etc/postfix/main.cf
scroll to the bottom, and set
inet_interfaces = loopback-only
inet_protocols = ipv4
restart postfix
sudo systemctl restart postfix
try sending an email from the command line,
echo "This is the body" | mail -s "This is the subject" -a "FROM:root@your-domain.tld" your@email-address
Check your SPAM folder.