Once you’ve got your server up and running the last thing you want to be doing is logging onto it every 5 minutes to check everything is ok. I instead want my server to be able to email me for any important events.
Whilst you can install and configure a fully featured email system you really don’t need to do so if all you want to do is send emails and not receive them too. I use msmtp which is a simple Mail Transfer Agent (MTA).
It’s easy enough to install:
sudo apt-get install msmtp msmtp-mta
Then you need a configuration file at /etc/msmtprc. Set it up with the following:
sudo touch /etc/msmtprc sudo chmod 600 /etc/msmtprc
Then edit the file however you like with the following:
# A system wide configuration is optional. # If it exists, it usually defines a default account. # This allows msmtp to be used like /usr/sbin/sendmail. account default # The SMTP smarthost. auth on host smtp.gmail.com port 587 user [email protected] from [email protected] password senderpassword tls on tls_starttls on tls_trust_file /etc/ssl/certs/ca-certificates.crt # Alias file for local emails aliases /etc/aliases # Syslog logging with facility LOG_MAIL instead of the default LOG_USER. syslog LOG_MAIL
Now your system can send mail using the sendmail command or msmtp.
In order to receive emails directed at root or postmaster or localuser, you also need to add an alias file at /etc/aliases with the following contents:
root: [email protected] default: [email protected]