Integrations · CRM
Validate emails of new Givebutter contacts
Check the address of every new Givebutter contact. Givebutter calls a small receiver of yours each time it creates a contact (a new donor, a ticket buyer, a contact added by hand); the receiver checks the contact's addresses with your API key, tells you which ones cannot receive mail and, if you want, tags that contact in Givebutter so you can filter it out of your next email.
Download it: email-validation-givebutter.zip holds email-validation-givebutter.mjs (one JavaScript module) and the MIT licence.
What you need
- An API key of ours from the API keys page with Validate addresses (on by default). Keep it on your server, never in a page.
- A server that Givebutter can reach over HTTPS, in anything with
fetch(Node 22 or later, Bun, Deno, Cloudflare Workers). Copyemail-validation-givebutter.mjsnext to its code. - A Givebutter account. Webhooks and API keys are under Settings. A Givebutter API key is needed only to tag contacts.
Set up the webhook in Givebutter
- In Givebutter, open Settings, then Developers, then Webhooks, and click New webhook.
- Give it a name, enter your receiver's HTTPS address as the webhook URL, pick the event contact.created and click Create.
- Click the eye icon (View) next to the webhook and copy its signing secret into your server's environment, for example as
GIVEBUTTER_WEBHOOK_SECRET. Givebutter sends it in a header namedSignaturewith every delivery; the receiver answers 401 to any request without it. - Only to tag contacts: create a Givebutter API key (Givebutter shows it once) and keep it on your server as well. Givebutter's API reference places API keys under Settings, then Integrations, then API Keys; its help center under Settings, then Developers, then API.
Givebutter fires contact.created for a contact made by a new transaction or created by hand, not for contacts imported from a CSV file.
The receiver
Make the receiver once per process and hand it each request to the webhook URL. A Cloudflare Worker:
import { createGivebutterHook } from './email-validation-givebutter.mjs';
let hook;
export default {
fetch(request, env, ctx) {
hook ??= createGivebutterHook({
apiKey: env.EV_API_KEY,
signingSecret: env.GIVEBUTTER_WEBHOOK_SECRET,
givebutterApiKey: env.GIVEBUTTER_API_KEY, // only to tag
tag: 'email-invalid', // only to tag
onResult: (r) => {
// r.contactId, r.emails (each with where, status, reason, blocked), r.blocked, r.tagged
},
});
return hook.handle(request, ctx);
},
};With ctx (Cloudflare Workers) the receiver answers Givebutter at once and checks after the answer; on Vercel, pass { waitUntil }, imported from @vercel/functions. Without a second argument it answers when the check is done. On Node, turn your framework's request into a web Request (Node 22 has one built in) and pass the Response back.
What it does
- It checks the contact's primary email and every address in its list of emails (20 at most), each address once.
onResultgets one result per contact:contactId,firstName,lastName,emails(each address withwhere,status,reason,action,did_you_mean,blockedand, when it got no answer,error),blocked,taggedandtagError.- Tags only when you ask. Without
tag, nothing in Givebutter changes. WithtagandgivebutterApiKey, a contact with a blocked address gets that tag through Givebutter's Add tags to a contact call, and its other tags stay. Filter on the tag in Givebutter before your next email. - Every other event (transactions, tickets, campaigns, plans, refunds) is answered 200 and ignored.
Try it free first
Check one of our free test addresses with the receiver's own check, without Givebutter:
const result = await hook.check('no_mailbox@sandbox.email-validation.org');
console.log(result.status, result.blocked); // invalid trueChecks of our test addresses are free. Never send an email to them, or to any address you made up: it would bounce.
How it decides
- What is blocked.
invalidby default.block: ['invalid', 'disposable']also blocks disposable addresses, andcatch_allcan be added too.validandunknownare never blocked: act on theactionof avalidresult if you want to (spam traps and known complainers arevalidwith the actionremove). - It fails open. A timeout (6 seconds per check by default,
timeoutMs), a network error, a rate limit, no credits or any error answer leaves that address unchecked (errorsays why), never blocked, and the contact is not tagged. Nothing is retried; after a rate limit the receiver sends nothing until our API'sRetry-Afterhas passed. A missing key or secret throws when you make the receiver. - Answers are remembered. A verdict is kept for the process's life (10,000 addresses by default,
memoMaxEntries); anunknownor a failed check is asked again. - Credits. Each check uses one credit (
unknownresults, malformed and sandbox addresses are free).region: 'eu'checks in the EU, athttps://api-eu.email-validation.org. - What it answers Givebutter. 401 for a wrong or missing signing secret (the body is not read), 405 for anything but POST, 413 for a body over 64 KB, 400 for a body that is not JSON, else 200. An error thrown by your
onResultis caught. - Our key goes only to our API and the Givebutter key only to Givebutter's API. Redirects are never followed, and the receiver logs nothing.
Test it first
The receiver reads Givebutter's deliveries by the field names of Givebutter's webhooks article and API reference and has not run against a real Givebutter account. Create one contact by hand with the test address above, watch onResult, and check the webhook's Activity in Givebutter before you rely on it.