How-Tos

How-To: Send Server Alerts Two Ways So One Email Outage Can’t Hide Them

Leave a comment

Last week’s Microsoft 365 outage stopped a hotel’s pool safety alert from getting through. Any alert that matters shouldn’t depend on one mail provider. Here’s the simple pattern I use for my own scripts.

1. Pick a second channel

Push services like ntfy (which you can self-host), Gotify or Pushover take a simple HTTP POST. That gives you a path that doesn’t touch email at all.

2. Wrap both in one function

alert() {
  msg="$1"
  echo "$msg" | mail -s "ALERT: $(hostname)" you@example.com
  curl -fsS -d "$msg" https://ntfy.example.com/your-topic || logger -t alert "push failed: $msg"
}
alert "Disk on /var is 95% full"

Swap in your own address and topic. Use a long, random topic name, or turn on access control if you self-host, because anyone who knows a public topic can read it.

3. Test the failure, not just the success

Break one path on purpose (a bad SMTP relay, or a wrong push URL) and make sure the other still arrives. Then schedule a weekly “I’m alive” test alert so a silent channel gets noticed.

God Bless, and Use the Source!

References & Further Reading

Subscribe (RSS) Follow How-Tos via RSS

Leave a note

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.