I have a number of servers that I look after in various places on the intertubes. I like to have things like MDADM (Linux software RAID manager) be able to mail me when the something goes wrong like a disk dies etc.
Some of these machines are in places without reliable SMTP servers for me to send mail through and I’ve tried running my own postfix and delivering the mail directly, but invariably I run into situations where the servers that I’m trying to deliver mail to don’t like DSL IPs… and not getting a mail about a dead disk is kinda a big issue.
I also don’t trust a lot of ISP’s SMTP, and some of my servers move around, so one day it’ll be behind a DSL IP and the next behind a Verizon IP (where it can’t talk to smtp.dslprovider.net etc).
My solution is quite simple, use google. (This guide is for Ubuntu but I’m sure you’ll figure it out with other distros)
- Create a gmail account for monitoring. I do this because I don’t want my gmail password floating around in plaintext on various machines.
- Install the ca-certificates package
$ sudo aptitude install ca-certificates
$ sudo update-ca-certificates - Install msmtp
$ sudo apt-get install msmtp
- Configure msmtp
$ sudo vim /etc/msmtprc
Set it to something like
account gmail
host smtp.gmail.com
from myemailaddress@gmail.com
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
user notifyemailaddress@gmail.com
password mys3cr3tp455w0rd
port 587account default : gmail
- Create a sendmail simlink
$ sudo ln -s /usr/bin/msmtp /usr/sbin/sendmail
- Run a test
$ echo “This is a an awesome test email” | msmtp youremail@domain.com
- If you want mdadm to mail you when something goes wrong
$ sudo vim /etc/mdadm/mdadm.conf
and put your email address on the line that reads something like
MAILADDR youremail@domain.com
- And then run a mdadm test by running
$ sudo mdadm –monitor –scan –test –oneshot
- If everything is working according to plan you should receive an email. You can now rest assured that any future MDADM issues will get to you.
Oh I’ve gone cross eyed 😉
Thanks, this has been immensely useful and lived up to its “Quick and Easy” title!
@Ian, please tell me you stumbled upon this while googling… That would make me feel like a hero considering all the times I come across your articles!