Allow Smartmontools to send emails via Gmail, using exim

Allow Smartmontools to relay mail via Gmail utilising the robust lightweight Exim mail transfer agent.

Install exim:

apt-get install exim4-base exim4-config
apt-get install exim4

configure Exim

dpkg-reconfigure exim4-config

Exim configuration:

1-smarthost

2-localhost

3-127.0.0.1

4-Other_destinations

5-relay_for

6-smtp.gmail.comb

7-Hide_local_mail_name_in_outgoing_mail

8-Keep_number_of_DNS-queries_minimal

9-mbox_format_in

10-split_config

Edit your credentials:

john@mylocalmachine:/home/john# cat /etc/exim4/passwd.client
# password file used when the local exim is authenticating to a remote
# host as a client.
#
# see exim4_passwd_client(5) for more documentation
#
# Example:
### target.mail.server.example:login:password
*.google.com:youraddress@domain.com:YOURPASSWORD

Secure your credentials:

chmod 640 /etc/exim4/passwd.client

This two step process ensures Exim4’s configuration is updated and the deamon is restarted:

update-exim4.conf
invoke-rc.d exim4 restart

Benign error starting exim, on my system:

ALERT: exim paniclog /var/log/exim4/paniclog has non-zero size, mail system possibly broken
rm /var/log/exim4/paniclog

Confirm that Exim is operational via:

echo testing | mail -s Bla myemail@somewhere.com

Checking that smart monitoring is enabled at boot (on Debian based systems):

sysv-rc-conf

Sysv

Installing the below mailutils will allow the smartd daemon to send emails via exim (configured for gmail relay) :

apt-get install mailutils

Adjust your Smartmontools configuration so it sends out an email on start up and when a problem is encountered with one of your disks.

# cat /etc/smartd.conf
/dev/sg1 -a -d sat -o on -S on -s (S/../.././02|L/../../6/03) -m address@domain.com -M exec /usr/share/smartmontools/smartd-runner
/dev/sg2 -a -d sat -o on -S on -s (S/../.././02|L/../../6/03) -m address@domain.com -M exec /usr/share/smartmontools/smartd-runner
/dev/sg3 -a -d sat -o on -S on -s (S/../.././02|L/../../6/03) -m address@domain.com -M exec /usr/share/smartmontools/smartd-runner
/dev/sg4 -a -d sat -o on -S on -s (S/../.././02|L/../../6/03) -m address@domain.com -M exec /usr/share/smartmontools/smartd-runner
/dev/sg4 -H -m address@domain.com -M test

You will need the below line to send out a test email on smartd start up.

/dev/sg4 -H -m address@domain.com -M test
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s