A simple Bash daemon to monitor Postfix delivery failures (bounced, deferred, reject) in real time and send alerts to your Telegram chat. It tails /var/log/mail.log with tail -F, filters only failed deliveries, and pushes formatted notifications via the Bot API.
- Real-time alerts for
bounced/deferred/rejectevents only - Lightweight daemon via
tail -F+systemd(no state files) - Interactive installer prompts for Bot Token & Chat ID
- Clean helper script (
telegram_notify.sh) for Telegram API calls - Automatic restart under
systemdon failure - Test message on install to confirm setup
- OS: any Linux with
systemd - Tools:
bash,curl,jq,systemctl - Telegram Bot:
- Create via BotFather β get Bot Token
- Retrieve your Chat ID
sudo git clone https://github.com/Anton-Babaskin/postfix-telegram-notifier.git /opt/postfix-telegram-notifier \
|| (cd /opt/postfix-telegram-notifier && sudo git pull)
cd /opt/postfix-telegram-notifier
sudo bash install.sh
You will be prompted for your Bot Token and Chat ID. A test alert (ββ Helper test OKβ) will arrive in Telegram.
Verify the daemon:
systemctl status postfix-telegram-notify.service
-
Manual test:
sudo bash -c 'printf "%s %s postfix/smtp[99999]: TEST_OK: to=you@domain.com, status=deferred (TEST)\n"
"$(date "+%b %e %H:%M:%S")" "$(hostname -f)"
>> /var/log/mail.log'β you should receive a β
β οΈ Delivery issue β¦ TEST_OKβ alert. -
Live logs:
journalctl -u postfix-telegram-notify.service -f
-
Log path
Edit theLOG=/var/log/mail.logline in/usr/local/bin/postfix-telegram-notify.shif your mail log is elsewhere. -
Filter logic
Adjust theif [[ β¦ ]]test in the script to catch other Postfix patterns.
MIT License β see LICENSE.
- Fork & clone
- Create a branch:
git checkout -b feature-name - Commit & push
- Open a pull request
β If this tool helps you, please give it a star!