Integrations · Mail servers and panels

Check outgoing recipients in Haraka

A plugin for Haraka mail servers that checks the recipients of the mail your users send out, while it is being submitted. By default it only logs each result: every recipient goes on as if the plugin were not there, so it never refuses a recipient unless you turn that on. When a check cannot be made in time, the API answers with an error or a setting is wrong, the recipient goes on unchecked and the mail goes out as usual. It never asks the sender to try again later.

It is one npm package, haraka-plugin-email-validation (plugin name email-validation), with no dependencies of its own and one settings file. Download it as a zip: haraka-plugin-email-validation-1.0.0.zip, which unpacks into a folder haraka-plugin-email-validation-1.0.0/. Haraka 3 on Node.js 22 or 24 (tested with Haraka 3.4.2 on Node.js 24).

What gets checked

Only outbound mail: the client logged in (SMTP AUTH), or the relay plugin's ACL lets it relay, before it starts the message. Recipients at your own domains are not checked: the ones in Haraka's host_list and host_list_regex, and any you list in local_domains (add the domains other plugins deliver for). Mail from other servers to your users is never checked, nor is mail Haraka sends by itself, such as bounces. The plugin's hooks run before those of your other plugins, wherever its line sits in config/plugins, so a plugin that accepts every recipient of a logged-in user does not skip the check.

Set it up

  1. Create an API key for the server on the API keys page with the permission Validate addresses and a daily credit cap.

  2. Unzip the download on the server, make the package in its folder and install it into your Haraka folder (here /etc/haraka), as root:

    unzip haraka-plugin-email-validation-1.0.0.zip
    cd haraka-plugin-email-validation-1.0.0 && npm pack
    cd /etc/haraka && npm install --ignore-scripts /path/to/haraka-plugin-email-validation-1.0.0/haraka-plugin-email-validation-1.0.0.tgz
    cp node_modules/haraka-plugin-email-validation/config/email-validation.ini config/
    chown root:haraka config/email-validation.ini && chmod 640 config/email-validation.ini

    The last line makes the settings file readable by Haraka's group only (the group Haraka runs as, from smtp.ini) before the key goes in; the plugin refuses a key in a file that others can read.

  3. In config/email-validation.ini, remove the ; before api_key = and put the key on that line (a key alone on a line would land in Haraka's log, which prints lines it cannot parse). Or leave the line commented out and set EV_API_KEY for the Haraka process from a file only root can read (under systemd, EnvironmentFile=, not Environment=).

  4. Add one line, email-validation, to config/plugins and restart Haraka. The log says [email-validation] settings loaded: mode=log ...; an [ERROR] line from [email-validation] names a wrong setting instead, and the plugin then checks nothing.

  5. From a client that logs in, try a test address without sending a message: swaks --server your.haraka.host:587 --tls --auth --auth-user you --from you@your-domain --to no_mailbox@sandbox.email-validation.org --quit-after RCPT ends the session after RCPT TO, so the check runs and nothing is sent. The log shows check rcpt=… sender=… status=invalid reason=no_mailbox source=api reply=cont.

Try it on a test server before a production one.

Test addresses on sandbox.email-validation.org return the result their name says, cost nothing and contact no mail server, so you can see every mode work before you spend a credit. Never send a whole message to one: log mode lets every message go out (reject mode too, for a status it does not refuse), and the bounce would hurt your server's sender reputation.

Modes

ModeSetWhat happens
Log (default)nothinga log line per checked recipient, and the plugin always answers Haraka next()
Rejectmode = rejectas log, and a recipient whose status is in reject_statuses (default invalid and disposable) is refused with a 550 text you can edit

Reject mode is off by default, because a refused recipient is mail that does not go out and no check is perfect. It refuses only the statuses you list, never a recipient that could not be checked (nor an unknown result that only says our side could not finish the check: reason timeout or internal_error), and valid never is. The other recipients still get the message, and your user sees the refusal at once in their mail program instead of a bounce later:

550 5.1.1 This address cannot receive mail (no_mailbox), so it was not sent. Check the address

Each status has its own text (reject_reply_invalid, reject_reply_disposable, reject_reply_catch_all, reject_reply_unknown); each must start with 550. If you use Haraka's delay_deny plugin, add email-validation to its excluded_plugins in config/delay_deny.ini, or reject mode refuses nothing. Haraka reloads the settings file by itself a few seconds after you save it; a file with a wrong setting keeps the previous settings.

For each checked recipient the plugin also adds a result that other plugins can read (transaction.results, under email-validation: pass, fail or skip with the status or reason, never an address).

What it costs

Each check the plugin sends costs at most 1 credit, as with any validation request; unknown results, errors, malformed addresses and test addresses are free. A check of an address checked before also costs 1 credit (repeat checks), so the plugin keeps its own cache, and an answer from it costs nothing. Credits come in one-time packs, as little as $0.15 per 1,000 with the 50,000,000-credit pack (smaller packs cost more per credit), and new accounts get 500 free credits (100 when you sign up with a free email provider such as Gmail, Outlook or Yahoo, another personal mailbox such as a paid one like Fastmail or one from your internet provider, or an address from a relay or alias service).

Four limits bound what it spends:

  • The cache: each result is reused until its time is up (30 days for valid and disposable, 7 days for invalid and catch_all, 30 minutes for unknown). It lives in memory, so a restart starts it empty.
  • Per sender: 30 checks at once, then 120 an hour, for each sender (the login, else the relaying host's IP address) in each Haraka process. Past that, their recipients go out unchecked, so a hijacked account spends at most that much of your credits per process before its checks stop.
  • Per day: at most 1,000 checks a day (UTC) for all senders together (daily_api_calls). The count is kept in memory, so a restart of Haraka starts it again.
  • The key's daily credit cap, which the API enforces whatever happens on your server, restarts included.

Every limit can be changed in config/email-validation.ini.

Privacy

The plugin sends each outside recipient's address, and nothing else of the message, in the body of a POST to https://api.email-validation.org (or https://api-eu.email-validation.org with region = eu, see EU data residency), never in a URL and to no other host. Its cache holds a keyed hash of each address, never the address, and nothing is written to disk. Its log lines never hold the API key or an address: recipients and senders appear as short hashes. Haraka's own log names recipients as it always does; its level and destination are yours to set.

When something fails

Every failure lets the recipient through (next()), and the log line's reason says why: pending (the API had not answered within answer_within = 3 seconds: the check finishes in the background and is cached for the next message), slow_api, sender_limit, daily_cap, busy, paused, api_limit (the API asked to slow down; the plugin waits as long as Retry-After says), no_credits, key_refused, api_error, timeout, network_error, bad_response or internal_error. After an answer that later checks would get too, such as a refused key or no credits left, the plugin stops calling the API for a while instead of slowing every message down. It keeps its own wait at least 1 second under Haraka's hook timeout, so Haraka never answers 450 plugin timeout because of it, and a wrong setting never stops Haraka: the plugin logs it and checks nothing. To switch it off, remove email-validation from config/plugins and restart Haraka.

Uninstall

Remove email-validation from config/plugins, restart Haraka, run npm uninstall haraka-plugin-email-validation in the Haraka folder, delete config/email-validation.ini and revoke the key on the API keys page.

More on Haraka

Updated · Maintained by: Email Validation LLC

Need help? Contact support, or ask the help chat. Something wrong or missing on this page? Tell us