Here is description how to install mail transfer agent.
- install mail, msmtp, msmtp-mta:
sudo apt install msmtp msmtp-mta mailutils
- copy-paste and enter your mail settings in file
/etc/msmtprc
(file below msmtprc , settings defaut for gmail) - Set msmtp as default mail-mta agent, edit file:
/etc/mail.rc
, and add at end of file lineset mta=/usr/bin/msmtp
- check it by running (you'll have to log-out and log-in in ssh/console to reload settings):
echo "Test mail" | mail -s "Testing mail" "your.mail@domain.com"
Hint, if you want use gmail mail, create Application Passwords in Account settings -> Security (this is available when 2-Factor Authentication is enabled). If you don't have 2-FA enabled, then enable 'Less secure app access' and in Gmail settings (gear icon above email list -> Settings) enable POP/IMAP forwarding. This should enable access to account that you want send from notifications.
WARNING: Enabling any of those on your primary account might get you hacked (if you pi get hacked, intruder will have your gmail password! or use your account to sending SPAM), so I'd advice crerate a new email only for sending notifications 😄