Integrations · Email platforms
Validate your Moosend subscribers
Check the addresses of a Moosend mailing list and save each subscriber's result in five custom fields of that list, so a segment can pick the addresses that passed. A sync script you run on your own computer checks the list as one bulk list and writes the results back. By default it deletes, removes and unsubscribes no one. The script is in email-validation-moosend.zip: moosend.mjs (the sync script) and the MIT licence.
Your Moosend API key
In Moosend, open More → Settings and select API key in the menu on the left. Its access follows your user role, so use a user that may read and edit mailing lists. Moosend's 30-day free trial is enough to try it: the script uses only this key and Moosend's API, no webhook and no add-on. Moosend takes the key in the address of every call, so keep it out of shared logs. The script never prints or stores it.
What it writes
| Field | Value |
|---|---|
ev_status | valid, invalid, catch_all, unknown or disposable (statuses) |
ev_reason | why, for example accepted, no_mailbox, spamtrap |
ev_action | send, send_with_caution, remove or retry_later |
ev_checked_at | when the check ran, in UTC |
ev_address_hash | which address was checked: a hash of it, never the address |
In Moosend, custom fields belong to a mailing list. The first run creates the five on the list it checks, as hidden text fields (subscribers do not see them when they update their profile). Then segment the list on the custom field ev_action equal to send (or also send_with_caution to keep catch-all addresses) and send your campaigns to that segment. Spam traps and complainers are valid with the action remove, so trust ev_action, not ev_status. Subscribers not checked yet have no ev_action and are not in the segment, so run the script before a campaign.
Each write sends every other field of the subscriber back as it was. If Moosend's answer shows a subscriber changed in any other way, the script stops at once. A result counts only for the address it was written for: if you change a subscriber's address in Moosend, the next run checks the new address.
Run the sync script
It needs Node 22.18 or later (nothing to install: it has no dependencies), an API key of ours from the API keys page with the permission Bulk lists (off by default: turn it on when you create the key), and the Moosend API key above.
cd email-validation-moosend # the unzipped folder
export EV_API_KEY=… MOOSEND_API_KEY=…
node moosend.mjs --lists # the mailing lists: id, subscribed count, name
node moosend.mjs --list <list id> --dry-run # counts what it would check; spends and writes nothing
node moosend.mjs --list <list id> # checks and writes the five fieldsIn Windows PowerShell (5.1 or 7):
cd email-validation-moosend # the unzipped folder
$env:EV_API_KEY = "…"; $env:MOOSEND_API_KEY = "…"
node moosend.mjs --lists # the mailing lists: id, subscribed count, name
node moosend.mjs --list <list id> --dry-run # counts what it would check; spends and writes nothing
node moosend.mjs --list <list id> # checks and writes the five fieldsTry it free first, on a test list: in Moosend, make a new mailing list (Audience → Email lists). Before you add anyone, set it to single opt-in (the list → Set your settings → Opt-in settings): Moosend sends its verification email for double opt-in lists only. Make sure no automation of yours mails new subscribers of that list. Then add one subscriber by hand, our test address no_mailbox@sandbox.email-validation.org: it is free, and it receives no mail. Run the script on the test list: the subscriber gets ev_status invalid and ev_action remove. Then delete the test list, and run it on your real list, --dry-run first.
- Only subscribed members are checked, and only those without a result for their current address (or with
unknown).--include-unsubscribedalso checks unsubscribed members (bounced and removed ones never),--revalidatechecks them all again. --region euchecks and keeps the list in the EU, with the same key.node moosend.mjs --setup --list <list id>only creates the five fields on that list.--host sitecoresendcalls the same API atapi.sitecoresend.io, Moosend's newer name (Sitecore Send).
The script does not ask before it spends: each distinct address uses one credit; unknown results, duplicates, malformed and test addresses are free. It prints subscriber ids, job ids and counts, never an address or a key.
Unsubscribe the bad addresses (optional)
Add --unsubscribe invalid,disposable to also unsubscribe those subscribers from the list (any of invalid, catch_all, unknown and disposable; valid is refused). It acts only on a result for the subscriber's current address, reads the subscriber again first, and counts one only when Moosend then shows it unsubscribed. If you name unknown, a subscriber whose ev_reason is timeout or internal_error still stays subscribed: that check failed on our side, and the next run checks the address again. unknown is a temporary status, so unsubscribing on it may drop good addresses. Moosend unsubscribes the subscriber from that one list. To undo one, add the subscriber to the list again in Moosend, only for someone who wants your mail.
Run it again
Run the same command again after any stop (no credits, a closed laptop, a Moosend outage or rate limit, a new API key, the bulk list still running): it resumes the same bulk list and never pays twice (within the 30 days a list is kept). Run it from the same folder each time (or pass the same --state FILE): the file it keeps there holds the bulk list it is working on, never an address or a key. When every subscriber is written, the file is removed and the next run checks only subscribers without a result, so you can run it on a schedule, for example daily with cron, with both keys set. Only one run at a time works on the same file.
Moosend counts its rate limits per API key in 10-second windows and publishes none for the reads and writes the script makes. The script sends 5 requests a second by default (--rate N, at most 10), and each written subscriber takes up to three: writing back 10,000 subscribers takes about 100 minutes. For unsubscribes Moosend publishes 20 per 10 seconds, and the script sends them at 2 a second. If Moosend answers that the limit is reached, the script waits and tries again. The check itself runs on our side and is not slowed by Moosend.
Exit codes: 0 done, 1 a write failed or the run stopped (run it again), 2 wrong arguments, 75 the bulk list was still running when the script stopped waiting (run it again later).
Good to know
- New subscribers. There is no relay for Moosend: run the script on a schedule, and each run checks only the subscribers added since.
- Ending the access. Delete the script's folder with its state file. Moosend's docs do not say whether generating a new API key ends the old one.
- Free checks. Results with the status
unknownare free, and so are malformed addresses, duplicates and test addresses.