Email alerts via Mandril API (Python)

I have a QNAP NAS (TS-212) which runs a variety of jobs for me, most notably all my backups to external USB drive(s) and other assorted tasks: I often find myself `tailing` logs to check they ran without issues – this works, but it’s tedious and error conditions (eg, a malfunctioning disk) may go unnoticed for days.

As the QNAP can run Python, I decided to write a simple script, using Mandrill Email API to send me an alert should anything go awry.

The code was pretty straightforward, and there are a number of niceties that could be added (most notably, the use of Jinja templates for the HTML body) – however, what I knocked together in a couple of hours’ evening coding I thought was good enough to share to others who may have the same need.

Github GistPython Email alerts via Mandril Email API

Remember to install Mandrill’s Python SDK:

pip install mandrill

To run the script, simply use:

$ ./ -f ./.mandrill -m "This is a test" -d -s "Test Test Test"

to see all the options use “

$ ./ --help

and to see logs (to stdout) use the “-v“ option:

$ ./ -f ./.mandrill -m "This is a test" -d -s "Test" -v

Leave a Reply

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

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

Facebook photo

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

Connecting to %s

%d bloggers like this: