Ubuntu Linux Email Notification on Hard Disk S.M.A.R.T Errors

This is a short guide on setting up sendmail command on Ubuntu to work with smartmontools to monitor SMART statuses of drives and send email notifications on any failures.

1. Setup sendmail to relay to an external SMTP server (Gmail, hotmail, your own host).

sudo apt-get install postfix


myhostname = yourhostname
relayhost = [yourhosturl]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_use_tls = yes


[yourhosturl]:587 username:password
sudo chmod 400 /etc/postfix/sasl_passwd
sudo postmap /etc/postfix/sasl_passwd
sudo service postfix restart

2. Test sendmail.

echo -e "Subject: it works\nYAY!" | sendmail [email protected] \
-F yourhostname

3. Setup smartmontools to monitor drives and send notifications on failure.

sudo apt-get install smartmontools


/dev/sda -H -l error -l selftest -f -s (S/../../1/01) -m \
[email protected] -M exec /usr/share/smartmontools/smartd-runner


sudo service smartmontools restart


This entry was posted in Uncategorized and tagged . Bookmark the permalink.

4 Responses to Ubuntu Linux Email Notification on Hard Disk S.M.A.R.T Errors

  1. Max says:

    This was super helpful, thanks!

  2. Will C says:

    This still works! I think… How do I add a -M test to the /etc/smartd.conf? I’d like it to email every time the server is restarted. I’ve tried every iteration but it complains “Your system does not have /usr/bin/mail. Install the mailx or mailutils package”.

  3. Will C says:

    I got it working. Instead of installing postfix directly, mailutils needs to be installed so that the appropriate symlinks are created. During installation, select no profile and then just use the /etc/postfix/main.cf you provided and the rest of the instructions just worked.

    I did append the -M test to the end of /etc/smartd.conf command you provided. It now sends a test email appropriately.

Leave a Reply

Your email address will not be published. Required fields are marked *