Postfix is a popular, secure mail transfer agent (MTA) for sending emails from your server.
Install
apt update\napt install postfix -ySelect "Internet Site" when prompted. Enter your domain name as the system mail name.
Configuration
Edit /etc/postfix/main.cf:
myhostname = mail.example.com\nmydomain = example.com\nmyorigin = $mydomain\nmydestination = $myhostname, localhost.$mydomain, localhost, $mydomain\ninet_interfaces = allRestart
systemctl restart postfixTest
echo "Test email" | mail -s "Test" your@email.com