// support, community and events
Via APIDiscourse email verification with pingutil
Open Discourse communities attract spam accounts registered with temp-mail addresses, and moderators clean them up one by one after the first link drop. A webhook on user events delivers user_created to your endpoint, pingutil classifies and verifies the address, and your code adds suspicious users to a review group or suspends clear throwaways before they post much.
Where it connects: Discourse webhook for user events (X-Discourse-Event: user_created), then the Discourse admin API (get user, add to group, suspend)
What goes wrong without it
- Spammers sign up with a new 10minutemail address every day and post links before our moderators wake up.
- Our member count keeps growing but half the new accounts never confirm or post anything real.
- Digest and notification emails bounce off dead addresses and our forum mail starts landing in spam.
What you can do with Discourse and pingutil
Put throwaway sign-ups in a review group
Accounts on disposable domains or with randomized local parts go into a needs-review group. Moderators get one place to look, and you can restrict what that group can do with category permissions.
Suspend obvious junk
When verdict.is_spam is true and the mailbox check also comes back invalid, suspend the account through the admin API with a reason moderators can read later.
Protect digest deliverability
Flag invalid addresses so you can stop sending digests to them before bounces pile up against your forum mail domain.
Set it up
- 1
Create a pingutil API key (PINGUTIL_KEY) and a Discourse admin API key with a system username (DISCOURSE_API_KEY, DISCOURSE_API_USER).
- 2
Create a group such as needs-review in Discourse and note its numeric id.
- 3
In the Discourse admin panel, go to API, Webhooks, add a webhook with your payload URL, content type application/json and a secret, and select User Events.
- 4
Deploy the handler below. It checks the X-Discourse-Event-Signature header (sha256 HMAC of the raw body), ignores every user event except user_created, and looks up the email with the admin API if the payload does not include it.
- 5
Register a test account with a disposable address and confirm it lands in the review group.
- 6
Keep the built-in blocked email domains setting for domains you know you never want; pingutil covers the long tail and the new ones.
import express from 'express';
import crypto from 'node:crypto';
const app = express();
const BASE = process.env.DISCOURSE_URL!; // e.g. https://forum.example.com
const headers = { 'Api-Key': process.env.DISCOURSE_API_KEY!, 'Api-Username': process.env.DISCOURSE_API_USER!, 'content-type': 'application/json' };
async function pingutil(path: string, body: object) {
try {
const res = await fetch('https://pingutil.com' + path, {
method: 'POST',
headers: { authorization: 'Bearer ' + process.env.PINGUTIL_KEY, 'content-type': 'application/json' },
body: JSON.stringify(body),
signal: AbortSignal.timeout(30000),
});
return res.ok ? await res.json() : null; // fail open on 429 / 5xx
} catch {
return null;
}
}
app.post('/webhooks/discourse', express.raw({ type: 'application/json' }), async (req, res) => {
const sig = 'sha256=' + crypto.createHmac('sha256', process.env.DISCOURSE_WEBHOOK_SECRET!).update(req.body).digest('hex');
if (sig !== req.get('X-Discourse-Event-Signature')) return res.sendStatus(401);
res.sendStatus(200);
if (req.get('X-Discourse-Event') !== 'user_created') return;
const { user } = JSON.parse(req.body.toString('utf8'));
const email = user.email ?? (await fetch(BASE + '/admin/users/' + user.id + '.json', { headers }).then((r) => r.json())).email;
if (!email) return;
// Fast screen first (milliseconds, no mailbox check)
const lookup = await pingutil('/v1/lookup', { input: email, skip_enrichment: true });
if (!lookup || !lookup.verdict.is_spam) return;
const v = await pingutil('/v1/verify', { email });
if (v && v.status === 'invalid') {
await fetch(BASE + '/admin/users/' + user.id + '/suspend.json', {
method: 'PUT',
headers,
body: JSON.stringify({ suspend_until: '3000-01-01', reason: 'pingutil: ' + lookup.verdict.reason + ', mailbox ' + v.reason }),
});
return;
}
await fetch(BASE + '/groups/' + process.env.REVIEW_GROUP_ID + '/members.json', {
method: 'PUT',
headers,
body: JSON.stringify({ usernames: user.username }),
});
});
app.listen(3000);What to do with each result
| pingutil result | Action in Discourse |
|---|---|
| verdict.is_spam: true and status: 'invalid' | Suspend the account with a reason that names the pingutil result. |
| verdict.reason: 'disposable_domain' (mailbox not invalid) | Add the user to the needs-review group for a moderator to decide. |
| verdict.reason: 'randomized_local_part' | Add to needs-review; machine-generated handles are a strong spam signal but real people can be caught too. |
| status: 'invalid' on a non-spam address | Leave the account but stop sending digests until the user updates their email. |
| verdict.is_spam: false | No action; the user joins as normal. |
Limits to plan for
- The user events webhook fires for several user events, not only creation, so always filter on the X-Discourse-Event header.
- pingutil runs after the account exists. If you also turn on Discourse's must approve users setting, flagged users wait in the approval queue instead of posting right away.
- Blocklists miss brand-new disposable domains, and the randomized-address heuristic can flag real handles like coolcat123. Use the review group rather than suspension for anything short of a clear invalid result.
Discourse documentation
- meta.discourse.org/t/configure-webhooks-that-trigger-on-discourse-events-to-integrate-with-external-services/49045
- docs.discourse.org/
Discourse is a trademark of its owner. This integration uses Discourse's documented extension points; it is not an official Discourse app.
Common questions
- Does Discourse already block disposable email domains?
- Discourse has a blocked email domains setting, but you maintain that list yourself. pingutil checks against about 9,900 disposable domains synced weekly and also scores randomized local parts, so it catches domains you have not added yet.
- Why run a lookup before the verify call?
- The lookup with skip_enrichment: true answers in milliseconds and only costs a lookup, so most legitimate sign-ups never use a mailbox verification. Only suspicious accounts get the slower SMTP check.
Stop bad addresses in Discourse today
Sign in with your email, create an API key and paste it into the step above. Test on a few real addresses first: the live demo shows exactly what your Discourse setup will receive.