The moment it happens
Get a message when an email permanently fails
Each hard failure or spam complaint shows up with the recipient and reason, so you can follow up.
- Runs
- The moment it happens
- Apps
- Mailgun
- AI
- Not needed
- Access
- private API key to register webhook
Send this to your assistant
Create a ClickRuntime automation: when Mailgun reports a permanent failure or a spam complaint, post the recipient, subject and reason to #email-ops in Slack.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
A new customer signs up, never gets the verification email and quietly leaves. An invoice to your biggest account bounces because their finance contact left the company, and nobody notices until the payment is late. When Mailgun cannot deliver a message permanently, the failure is recorded in logs that no one reads, and the person who needed that email has no idea it never arrived.
Mailgun can call ClickRuntime as soon as a message fails permanently. The call is verified using Mailgun's signature, so only genuine events are accepted, and a message goes to your channel naming the recipient and the reason for the failure. It reacts immediately, with no polling.
It is most valuable for transactional email such as invoices, onboarding and password resets, where one undelivered message has a real cost.
What you get out of it
Lost customers are noticed in time
A person who never received the welcome email can still be rescued if support hears about it within the hour. They can call, correct the address or send the message from another channel.
Late payments are avoided
When an invoice bounces, finance can contact the customer by phone the same day. Without the alert, the invoice may sit undelivered for weeks and the payment slips past its due date.
Typos in addresses get fixed
Many permanent failures come from a mistyped domain such as gmial.com. Seeing them as they happen lets you correct the record and resend, rather than leaving a user locked out.
Only genuine events trigger a message
Checking Mailgun's signature means a fake request cannot post to your channel. You can trust that every notification reflects a real delivery problem. Fake requests are simply rejected, so the channel only shows events that came from Mailgun itself.
Suppression lists stay healthy
Knowing which addresses fail permanently helps you remove or fix them, keeping your bounce rate low. That protects the reputation of your sending domain for the messages that matter. Cleaner lists also mean fewer wasted sends over time.
Support gets context before the call
When a customer writes in to say an email never arrived, support can search the channel and see the exact error. That turns a vague complaint into a concrete fix.
How it works
What happens, step by step
Each time Mailgun records a hard failure or a spam complaint, it tells ClickRuntime straight away.
The automation checks the message really came from Mailgun.
A message goes to #email-ops with the recipient, the email's subject and the reason, so you can follow up.
Before it runs live
- Connect Mailgun
- Paste your automation's link into the other app's webhook settings
What you get
Build your own
Need it to work differently?
Your own rules
Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.
Any number of apps
One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.
AI where it helps
Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.
On a schedule or on each event
Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.
Changes you can ask for
- Act only on the items that match your own rules, and skip the rest
- Add an AI step, for example to summarize, sort or draft a reply
- Add another app, for example also send it to Slack
- Combine it with other Mailgun steps into one automation
Under the hood
The code that runs this automation
import hashlib, hmac
from clickruntime import on_event, credentials, notify
@on_event
def handle(event):
body = event.json or {}
sig = body.get("signature", {})
expected = hmac.new(credentials.secret("MAILGUN_WEBHOOK_SIGNING_KEY").encode(),
f"{sig.get('timestamp')}{sig.get('token')}".encode(), hashlib.sha256).hexdigest()
if not hmac.compare_digest(expected, sig.get("signature", "")):
return {"rejected": "bad signature"}
data = body["event-data"]
if not (data["event"] == "complained" or (data["event"] == "failed" and data.get("severity") == "permanent")):
return {"skipped": data["event"]}
subject = data.get("message", {}).get("headers", {}).get("subject", "(no subject)")
reason = data.get("delivery-status", {}).get("description") or data.get("reason") or data["event"]
notify.slack(f"Mailgun {data['event']}: {data['recipient']}\nSubject: {subject}\nReason: {reason}",
channel="#email-ops")
return {"posted": True}FAQ
Common questions
What counts as a permanent failure in Mailgun?
Can I get alerts only for important emails?
What does the alert tell me about the failure?
What permissions does it need?
Does it need AI?
How many runs does it use?
Can I change how it works?
Related
You might also like
Get warned when your bounce rate climbs
You hear the same day if today's bounces pass your limit, once rather than every hour.
See how it worksGet yesterday's delivery numbers each morning
One email shows accepted, delivered, bounced and complained counts for each sending domain.
See how it worksPost new orders and sign-ups to Slack
When something happens in your shop, app or form, the details land in the right channel straight away.
See how it worksKeep exploring
Set up “Get a message when an email permanently fails” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.