Integrations · E-commerce
Validate your Shopware customers
Check the email addresses of your Shopware 6 shop's customers and write each result into four customer custom fields, so a dynamic product group, a rule or an export can leave out the addresses you should not mail. A script you run on your own computer reads every customer through Shopware's Admin API, checks the addresses (up to 50 one by one, more as one bulk list) and writes the results back. It never deletes, merges or changes a customer's address. Download it: email-validation-shopware.zip holds shopware.mjs (the script) and the MIT licence.
What you need
- A computer with Node 22.18 or later. Nothing to install: the script has no dependencies, and nothing is installed in your shop.
- An API key of ours from the API keys page with Validate addresses, and the permission Bulk lists (off by default: turn it on when you create the key) for more than 50 customers.
- A Shopware 6 shop reachable over HTTPS (the Admin API is part of Shopware itself) and an integration of it: in the Administration, Settings → System → Integrations → Create integration. Give it a name and a role (below), then save the access key ID and the secret access key: Shopware shows the secret only once.
- The integration's role: in Settings → System → Users & Permissions → Roles, a role whose detailed privileges are
customerread and update and, for the first run,custom_field_set,custom_fieldandcustom_field_set_relationread and create. (The integration's Administrator switch also works, but gives it everything.)
Try it free first
Every definite result uses one credit (unknown results, malformed and test addresses are free), so try it on a test shop that holds only test customers, never on your live one. Give one test customer the address no_mailbox@sandbox.email-validation.org (sandbox checks are free; that domain receives no mail, so send it nothing), then:
cd email-validation-shopware # the unzipped folder
export SHOPWARE_URL=https://… SHOPWARE_ACCESS_KEY_ID=… SHOPWARE_SECRET_ACCESS_KEY=… EV_API_KEY=…
node shopware.mjs --dry-run # creates nothing, checks nothing, writes nothing: only counts
node shopware.mjs # creates the four fields if missing, checks and writesIn Windows PowerShell (5.1 or 7):
cd email-validation-shopware # the unzipped folder
$env:SHOPWARE_URL = "https://…"; $env:SHOPWARE_ACCESS_KEY_ID = "…"; $env:SHOPWARE_SECRET_ACCESS_KEY = "…"; $env:EV_API_KEY = "…"
node shopware.mjs --dry-run # creates nothing, checks nothing, writes nothing: only counts
node shopware.mjs # creates the four fields if missing, checks and writesSHOPWARE_URL is your shop's address, https:// only, with its subfolder if it has one, without /api. The test customer's ev_status field says invalid and ev_reason says no_mailbox. Run it once more: it reports nothing to check, because every result was written. Then delete the test customer.
Run it
node shopware.mjs --dry-run # how many customers would be checked; free
node shopware.mjs # checks and writesUp to 50 addresses are checked one by one; more go out as one bulk list. A customer whose address already has a result is skipped (an unknown result is checked again), so a daily run checks only new and changed addresses. If a run stops, run the same command again from the same folder: it resumes the same bulk list and never pays twice (within the 30 days a list is kept). The state file (.ev-shopware-<shop id>.json) lives in that folder: run each shop, and each staging copy of it, from its own folder. It prints ids and counts, never an address or a key.
Options:
--region eu: checked in the EU, lists and results kept there, with the same key.--revalidate: check again addresses that already have a result.--rate N: Admin API requests a second (default 4, at most 20; Shopware sets no Admin API limit of its own, so the default keeps a small server free for your visitors). When the shop answers busy (429) or with a server error, the script waits what the shop asks (a few seconds when it does not say), up to a minute per wait, and tries again; if it still fails after four tries, it stops and the same command resumes.--state FILE: a state file of your own choosing.
Exit codes: 0 done; 1 a write failed or the run stopped (run it again: nothing is paid twice); 2 wrong options; 75 the bulk list was still being checked when the script stopped waiting (run it again later to collect it).
What it writes
Four text custom fields on customers, in the set ev_email_validation, created by the first run when they are missing (shown on the customer's page in the Administration, not writable by shoppers):
| Field | Holds |
|---|---|
ev_status | valid, invalid, catch_all, unknown or disposable |
ev_reason | the reason, for example no_mailbox or accepted |
ev_checked_at | when it was checked |
ev_address_hash | a hash of the address the result belongs to, so a changed address is checked again |
Spam traps and complainers are valid with a warning reason: see what each status means. Each result is written by customer id, and only while the customer, read again right before the write, still holds the address that was checked. The write sends only these four custom fields, and Shopware merges custom fields key by key, so the customer's other custom fields stay as they are. Each write is a change of the customer, so an extension or webhook listening for changed customers hears of it. A result that could not be written is kept in a file next to the state file and written by the next run without a new check.
End the access
Delete the integration in Shopware (Settings → System → Integrations) and our key on the API keys page. The four fields stay on your customers until you delete the set in Shopware (Settings → System → Custom fields).