All work

Entry 02 of 03

Work

Email Alerts

Tell the right person when a job needs attention

  • Python
  • smtplib
  • SMTP
Read the walkthrough
  1. Detect the failed job
  2. Prepare the alert
  3. Send it to the team

Overview

I connect a job's result to an email rule. If the result matches the rule, a Python script creates a short alert and sends it to the configured recipients. This example reports an export that stopped because its input file was missing.

What it covers

  • Event triggers
  • Recipient routing
  • Message templates
  • SMTP delivery

Inside the alert

A useful subject identifies the job that stopped. The message body gives the reason and the next thing to check, so the recipient can act without searching through a general activity feed.

Send a useful failure alert

  1. Pick one failure condition, such as an export with a missing input file, and decide who should receive the alert.
  2. In Python, build a message with the job name in the subject and the failure reason and next check in the body.
  3. Use smtplib with your SMTP service to send a test failure to the intended inbox, then verify that a successful job sends no alert.