// website builders and cms
Via APIStrapi email verification with pingutil
When a Strapi project exposes /api/auth/local/register to a public front end, anyone can script accounts with temp-mail and random addresses, and each one gets the authenticated role and a confirmation email. Strapi 5 lets you wrap the Users & Permissions auth controller in src/extensions/users-permissions/strapi-server.js, so the register action can ask pingutil about the email first and answer 400 before the original logic creates the user. If pingutil is slow or unavailable, the wrapper calls the original register as if nothing happened.
Where it connects: Users & Permissions plugin extension, wrapping the auth.register controller (POST /api/auth/local/register), Strapi 5
What goes wrong without it
- Our Next.js front end calls Strapi's register endpoint directly, and someone found it and created thousands of users on throwaway domains.
- Email confirmation is on, so every fake signup sends a confirmation email that bounces from our sender.
- The built-in rate limit slows a single IP down, but signups from rotating IPs still get through.
What you can do with Strapi and pingutil
Reject disposable and random emails at /api/auth/local/register
Inside the wrapped register action, call /v1/lookup with skip_enrichment: true and return ctx.badRequest() when verdict.is_spam is true. The original register never runs, so no user is created and no confirmation email goes out.
Keep confirmation emails off dead addresses
If you send a confirmation email, the fast check removes most throwaway domains before Strapi sends it. For mailbox-level checks, call /v1/verify instead and accept the extra seconds.
Tag business signups for the sales team
After the original register succeeds, a follow-up /v1/lookup without skip_enrichment returns category and company, which you can store on a custom user field from a background job.
Set it up
- 1
Create an API key in the pingutil dashboard and set it as PINGUTIL_KEY in the Strapi environment (.env locally, your host's secrets in production).
- 2
Create src/extensions/users-permissions/strapi-server.js (or .ts) with the code below. It wraps the auth controller factory, which is the pattern Strapi documents for overriding auth actions.
- 3
Restart Strapi so the extension loads.
- 4
POST to /api/auth/local/register with username, email (a mailinator.com address) and password, and confirm a 400 ValidationError; repeat with your own address to confirm a user is created.
- 5
Check the Strapi log for "pingutil skipped" lines; those are the fail-open cases.
'use strict';
async function isSpamEmail(email, strapi) {
if (!process.env.PINGUTIL_KEY) return false;
try {
const res = await fetch('https://pingutil.com/v1/lookup', {
method: 'POST',
headers: {
authorization: 'Bearer ' + process.env.PINGUTIL_KEY,
'content-type': 'application/json',
},
body: JSON.stringify({ input: email, skip_enrichment: true }),
signal: AbortSignal.timeout(3000),
});
if (!res.ok) return false; // 429 quota_exceeded, rate_limited, 5xx: fail open
const data = await res.json();
return Boolean(data.verdict && data.verdict.is_spam);
} catch (err) {
strapi.log.warn('pingutil skipped: ' + err.message); // timeout or network error: fail open
return false;
}
}
module.exports = (plugin) => {
// auth is a factory at extension time: wrap the factory, not plugin.controllers.auth.register.
const originalAuthFactory = plugin.controllers.auth;
plugin.controllers.auth = ({ strapi }) => {
const originalAuth = originalAuthFactory({ strapi });
const originalRegister = originalAuth.register;
originalAuth.register = async (ctx) => {
const body = ctx.request.body || {};
const email = typeof body.email === 'string' ? body.email.trim() : '';
if (email && (await isSpamEmail(email, strapi))) {
return ctx.badRequest('Please register with a permanent email address.');
}
return originalRegister(ctx);
};
return originalAuth;
};
return plugin;
};What to do with each result
| pingutil result | Action in Strapi |
|---|---|
| verdict.is_spam: true (disposable_domain, randomized_local_part) | Return ctx.badRequest(); the original register does not run. |
| verdict.low_trust: true (role_based, system_generated) | Call the original register; flag the user later if you care about role addresses. |
| category: "free" or "company" | No change at registration; use a full lookup afterwards if you want company data. |
| Timeout, 429 or 5xx | Call the original register so the user is created as usual. |
Limits to plan for
- This covers the local provider only. Users who sign in through a configured social provider go through /api/connect and the auth callback, not register.
- Strapi's guide says to call the original controller first when wrapping. Here the check runs before it on purpose, and then either rejects or hands off to the original, so the original sanitization and error handling still apply to every accepted request.
- Fast mode does not open an SMTP session, and privacy-relay addresses (Apple Hide My Email, Firefox Relay) can come back as randomized_local_part. Watch the first week of rejections.
Strapi documentation
- docs.strapi.io/cms/backend-customization/guides/customizing-users-permissions-plugin-routes
- docs.strapi.io/cms/features/users-permissions
- docs.strapi.io/cms/error-handling
Strapi is a trademark of its owner. This integration uses Strapi's documented extension points; it is not an official Strapi app.
Common questions
- Why not a lifecycle hook on plugin::users-permissions.user?
- A beforeCreate hook also fires for users created in the admin panel and by your own code, and an error thrown there surfaces as a less useful response. Wrapping auth.register limits the check to public signups and lets you return a clean 400.
- Does this work on Strapi 4?
- The extension file and the idea are the same, but the Strapi 5 docs are explicit that auth is a factory and must be wrapped as shown. On Strapi 4, check how your version exposes plugin.controllers.auth before copying the code.
Stop bad addresses in Strapi 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 Strapi setup will receive.