Integrations · Email platforms
Check Sender subscribers before you send
Check a Sender (sender.net) list before a campaign, each new subscriber Sender tells you about, and each sign-up before Sender gets it. One module with no dependencies, copied into your own code, plus a small tool for your terminal: it reports the subscribers of a group or segment whose addresses cannot receive mail and, when you ask, adds them to a group of yours (leave that group out of your campaigns) or unsubscribes them. By default only a definite invalid is blocked; everything else stays as it is.
Download it: email-validation-sender.zip holds the module as TypeScript (email-validation-sender.ts) and as JavaScript (email-validation-sender.mjs), the list tool (sender.mjs) and the MIT licence.
What you need
- An API key of ours from the API keys page with Validate addresses (on by default).
- A Sender API access token: in Sender, Account settings → API access tokens (app.sender.net/settings/tokens), Create API token, then copy it before you leave the page. Sender's API is on every plan, the Free plan included.
- For the list tool: Node 22.18 or later.
- For the module: your own code, in anything with
fetch(Node, Bun, Deno, Cloudflare Workers). Copyemail-validation-sender.tsinto a TypeScript project, oremail-validation-sender.mjsinto a JavaScript one. - For the new-subscriber receiver only: Sender's account webhooks, which are on the Standard plan and above (Sender offers Free accounts a 14-day trial of its Pro plan).
Our key goes only to our API, the Sender token only to api.sender.net. Nothing is logged, and an error never holds a key, a token or an address.
A list before a campaign
import { cleanList } from './email-validation-sender.ts'; // .mjs in JavaScript; no extension in TypeScript under a bundler
const sender = { apiToken: process.env.SENDER_API_TOKEN };
const report = await cleanList({ apiKey: process.env.EV_API_KEY, sender, group: 'eZVD4w' });
// report.blocked: [{ email, status: 'invalid', reason: 'no_mailbox', source: 'check', subscribers: 1 }, …]
await cleanList({ apiKey: process.env.EV_API_KEY, sender, group: 'eZVD4w', apply: true, blockedGroup: 'b2vAR1' });These are two runs, and each one checks the list (and uses its credits): on a real list, run the apply call alone once you trust the report.
group reads one group's subscribers, segment one segment's; with neither, every subscriber is read. A group's id is in Sender's GET /groups answer (for example b2vAR1). Subscribers who cannot get campaign mail now (unsubscribed, bounced, spam reported) are not checked. The read stops at 100,000 subscribers (maxSubscribers).
Nothing changes in Sender unless apply is true and something is blocked. Then each blocked subscriber joins blockedGroup (a group of yours, for example "Blocked by email-validation.org": leave it out of your campaigns; they stay subscribed), or, with action: 'unsubscribe', is unsubscribed. Automations are not started. Nothing is ever deleted, and a run that would change every address in the list refuses (would_empty_list).
Try it free first
Check a sandbox address without Sender ever getting it:
import { subscribeChecked } from './email-validation-sender.ts';
const r = await subscribeChecked(
{ email: 'no_mailbox@sandbox.email-validation.org' },
{ apiKey: process.env.EV_API_KEY, sender: { apiToken: process.env.SENDER_API_TOKEN } },
);
console.log(r.outcome); // 'blocked': the address is invalid (no_mailbox), and Sender was not calledSandbox checks are free, and that domain receives no mail: never send a campaign to it, or to any address you made up. A send to an address that cannot receive mail bounces and counts against your sending reputation.
Your list from a terminal
To see the tool work, make a test group in Sender holding two subscribers, no_mailbox@sandbox.email-validation.org and accepted@sandbox.email-validation.org (the tool refuses to set aside every address of a list, so one must pass), and a second group for the blocked ones. Keep both groups out of every campaign and automation until you have deleted those test subscribers. Then:
cd email-validation-sender # the unzipped folder
export EV_API_KEY=… SENDER_API_TOKEN=…
GROUP_ID="…" # the test group's id
BLOCKED_ID="…" # the group for blocked subscribers
node sender.mjs --group "$GROUP_ID" # report only: changes nothing
node sender.mjs --group "$GROUP_ID" --apply --blocked-group "$BLOCKED_ID" # adds them to that group
node sender.mjs --group "$GROUP_ID" --apply --action unsubscribe # or unsubscribes themIn Windows PowerShell (5.1 or 7):
cd email-validation-sender # the unzipped folder
$env:EV_API_KEY = "…"; $env:SENDER_API_TOKEN = "…"
$GroupId = "…" # the test group's id
$BlockedId = "…" # the group for blocked subscribers
node sender.mjs --group $GroupId # report only: changes nothing
node sender.mjs --group $GroupId --apply --blocked-group $BlockedId # adds them to that group
node sender.mjs --group $GroupId --apply --action unsubscribe # or unsubscribes themThen delete the two test subscribers. Use --segment ID instead of --group for a segment. Other options: --block invalid,disposable, --region eu, --concurrency N (default 4, at most 10), --include-inactive, --max N. The report prints the blocked addresses to your terminal only; nothing is written to a file.
A report checks every distinct active address in the list (each one credit), so it costs the same as a clean: run it with --apply once you are ready. Running it again checks the list again and adds the same subscribers to the group again, which changes nothing. Sender limits API calls per minute for each account, so the tool spaces its calls and waits out Sender's pause: a large list runs to the end at Sender's pace.
Exit codes: 0 done (also when our API refused the key, ran out of credits or rate limited the checks: the report says so, and after a refused key nothing is changed); 1 Sender refused or failed, or every address would go (the message says how many were changed before it stopped); 2 wrong arguments or a missing key.
Each new subscriber
createSenderHook is a receiver for Sender's account webhooks: it checks each new subscriber's address and adds a blocked one to your group (or unsubscribes them). It answers web requests, so put it behind a route in a Next.js, Remix, Hono, Bun, Deno or Cloudflare Workers app:
import { createSenderHook } from './email-validation-sender.ts';
export const POST = createSenderHook({
apiKey: process.env.EV_API_KEY,
secret: process.env.SENDER_WEBHOOK_SECRET, // Account settings → Webhooks → Signing secret
sender: { apiToken: process.env.SENDER_API_TOKEN },
blockedGroup: 'b2vAR1', // or action: 'unsubscribe' / 'none'
});In Sender, open Account settings → Webhooks, choose Add webhook, enter your receiver's HTTPS address and pick the topic subscribers/new (every new subscriber) or groups/new-subscriber (one group). The signing secret is below the webhooks table. The receiver refuses a delivery whose signature is missing or wrong, and ignores other payloads (groups, campaigns, bounces) and subscribers who cannot get campaign mail.
Sender waits 10 seconds for an answer and tries again after a failure, so the receiver does its work within 8 seconds. When it cannot (Sender's own rate limit, a passing error), it answers 503 and Sender sends the delivery again. After a large import, run the list tool on the group instead of relying on every delivery.
A sign-up on your own server
const { outcome } = await subscribeChecked(
{ email: form.email, firstname: form.firstName, groups: ['eZVD4w'] },
{ apiKey: process.env.EV_API_KEY, sender: { apiToken: process.env.SENDER_API_TOKEN } },
);
// 'subscribed' | 'blocked' | 'not_an_address'It checks the address, then creates the subscriber in Sender unless it is blocked. A blocked address, and anything that is no address (a link, a name, empty), never reaches Sender.
How it behaves
- Blocks only
invalidby default.blockaddsdisposable,catch_allorunknown, for exampleblock: ['invalid', 'disposable'];validcannot be blocked. Anunknownfrom our side (a timeout) is never blocked. - Fails open. No key, a timeout (6 seconds per check by default,
timeoutMs), a network error, a rate limit or any error answer keeps the address: the subscriber is created, or left as they are. - Credits. Each check uses one credit (
unknownresults, malformed and sandbox addresses are free). Each distinct address is checked once per run, however many subscribers carry it. Within one process a definite answer is remembered for a day, at most 1,000 answers per key (the oldest go first), so a second run over a larger list is checked and charged again. - EU.
region: 'eu'(or--region eu) checks in the EU. - An earlier verdict. With
verdictField(a text field of yours in Sender, for exampleev_status, plus a second one with_forafter its name), the receiver andsubscribeCheckedwrite each definite answer there, and the list tool (--verdict-field ev_status) uses it when a new check gives no answer, only for the address it judged. Create both fields in Sender first.