# Sendmail Recipient Checks

URL: https://email-validation.org/docs/guides/sendmail/
Updated: 2026-11-27

> Documentation index: https://email-validation.org/llms.txt

A mail filter (milter) for Sendmail that checks the recipients of the mail your users send out, at `RCPT TO`. By
default it only logs each result and accepts every recipient, so it never refuses one unless you turn that on. When a
check cannot be made in time, the API answers with an error or the filter is not running, Sendmail carries on and the
mail goes out as usual.

It has three parts: **ev-milter**, the filter Sendmail talks to over a Unix socket (Python 3 standard library: no
libmilter or pymilter to install); **ev-helper**, the same small daemon as in the [Exim guide](https://email-validation.org/docs/guides/exim/),
which holds the API key, the cache and the limits and makes the checks; and one `INPUT_MAIL_FILTER` line for your
`sendmail.mc`. Download them as one zip: [ev-sendmail-1.0.0.zip](https://email-validation.org/downloads/sendmail/ev-sendmail-1.0.0.zip), which
unpacks into a folder `ev-sendmail/`. Sendmail 8.14 or later with milter support (8.18 targeted), systemd 247 or later.

This filter was built from Sendmail's milter protocol and tested against stand-ins; it has not yet run on a real
Sendmail server, so try it on a test server first.

## What gets checked

Only outbound mail: the client logged in (SMTP AUTH, Sendmail's `{auth_authen}`), or connects from an address in
`relay_hosts` (by default this machine, so messages submitted with the `sendmail` command, which reach the server
through Sendmail's submission program on 127.0.0.1, are checked too). Recipients Sendmail delivers itself (its local
mailers) and any domain you list in `skip_domains` are not checked. Mail from other servers to your users is never
checked.

## Set it up

1. Create an API key for the server on the [API keys page](https://email-validation.org/app/api-keys/) with the permission **Validate
   addresses** and a [daily credit cap](https://email-validation.org/docs/authentication/#limits).
2. Put the key in `/etc/ev-helper/api-key` without showing it: as root in bash, run `install -d -m 0755 /etc/ev-helper`
   and `(umask 077; read -rs -p 'API key: ' key && printf '%s\n' "$key" > /etc/ev-helper/api-key; echo)`, then
   paste the key at the prompt (it is not shown and stays out of your shell history). Then, from the unpacked
   `ev-sendmail/` folder, run `install -D -m 0644 helper/ev_helper.py /usr/local/lib/ev-helper/ev_helper.py` and
   `install -m 0644 helper/ev-helper.conf /etc/ev-helper/`, then run
   `python3 -I /usr/local/lib/ev-helper/ev_helper.py --check-config`.
3. Copy `systemd/ev-milter.sysusers` to `/etc/sysusers.d/ev-milter.conf` and run `systemd-sysusers` (it creates the
   group `ev-helper-clients`). Install `systemd/ev-helper.socket` and `systemd/ev-helper.service` in
   `/etc/systemd/system/`, and `systemd/ev-helper-sendmail.conf` with
   `install -D -m 0644 systemd/ev-helper-sendmail.conf /etc/systemd/system/ev-helper.socket.d/sendmail.conf` (it gives
   the helper's socket to that group instead of Exim's). Run `systemctl daemon-reload` and
   `systemctl enable --now ev-helper.socket`.
4. Run `install -D -m 0644 milter/ev_milter.py /usr/local/lib/ev-milter/ev_milter.py` and
   `install -D -m 0644 milter/ev-milter.conf /etc/ev-milter/ev-milter.conf` (the service runs as its own user, so the
   settings file must stay readable), add your relay hosts to `relay_hosts` if you have any, and run
   `python3 -I /usr/local/lib/ev-milter/ev_milter.py --check-config`. Install `systemd/ev-milter.socket` and
   `systemd/ev-milter.service` in `/etc/systemd/system/` and run `systemctl enable --now ev-milter.socket`.
5. Try it without sending mail: `python3 -I /usr/local/lib/ev-milter/ev_milter.py --test no_mailbox` asks the helper
   about the free test address `no_mailbox@sandbox.email-validation.org` and prints its status and what the filter
   would do.
6. Add the line in `sendmail/ev-milter.mc` to your `sendmail.mc`, below any other `INPUT_MAIL_FILTER` lines:

   ```text
   INPUT_MAIL_FILTER(`ev-milter', `S=local:/run/ev-milter/ev-milter.sock, T=C:5s;S:5s;R:10s;E:30s')
   ```

   Rebuild `sendmail.cf` (on Debian and Ubuntu `sendmailconfig`, on AlmaLinux and Rocky `make -C /etc/mail`) and
   restart Sendmail. The line has no `F=` flag on purpose: when the filter is down or does not answer, Sendmail
   carries on as if it were not there. That also means a Sendmail that cannot reach the socket skips the filter
   without a word, so check the log line in the next step: with SELinux enforcing (AlmaLinux and Rocky), Sendmail may
   need a local policy module to connect to `/run/ev-milter/ev-milter.sock`, and if your Sendmail sets `RunAsUser`,
   give that user's group the socket (`SocketGroup=` and `SocketMode=0660` in `ev-milter.socket`).
7. Try a recipient in a session that logs in and ends after `RCPT TO`, so nothing is sent:
   `swaks --server localhost --port 587 --auth-user <user> --to no_mailbox@sandbox.email-validation.org --quit-after RCPT`,
   then read the log line with `journalctl -u ev-milter`. Never send a whole message to a test address: log mode lets
   it out and the bounce hurts your sender.

## Modes

- **Log only** (`mode = log`, the default): every recipient is accepted, and each checked one gets a line in the
  journal with Sendmail's queue id, a short hash of the address (never the address), its status and reason.
- **Reject** (`mode = reject`): a recipient whose status is `invalid` with a reason in `reject_reasons` is refused at
  `RCPT TO` with `550 5.1.1` and `reject_text`; the message still goes to the other recipients. Defaults:
  `reject_reasons = no_mailbox no_dns no_inbound_mail unroutable`, and `reject_disposable = no` (set it to `yes` to
  refuse disposable addresses too). A recipient that could not be checked, `unknown`, `catch_all` and `valid` are
  never refused.

## What it costs

Each check the helper sends costs at most 1 credit, as with any [validation request](https://email-validation.org/docs/api/validate/); `unknown`
results, errors, malformed addresses and test addresses are free. A check of an address checked before also costs 1
credit ([repeat checks](https://email-validation.org/docs/api/validate/#repeat-checks)), so the helper keeps its own cache, and an answer from it
costs nothing. Credits come in one-time [packs](https://email-validation.org/pricing/), 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).
The helper's cache, its limit per sender (the login, else the client's address), its daily limit for all senders and
the key's daily credit cap bound what it spends, as the [Exim guide](https://email-validation.org/docs/guides/exim/#costs) explains; every limit
but the last can be changed in `/etc/ev-helper/ev-helper.conf`.

## Privacy

The helper 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` in `ev-helper.conf`, see [EU data residency](https://email-validation.org/docs/eu-data-residency/)), never in a
URL and to no other host. The filter has no network access and never sees the key. Neither log holds the key or an
address: recipients appear as short hashes, with Sendmail's queue id.

## When something fails

Every failure accepts the recipient, and the log line's reason says why: `helper_timeout` (no answer from the helper
within `helper_timeout = 4` seconds), `helper_unavailable` (its socket is missing or it hung up), `bad_answer`, or
the helper's own reasons (`pending`, `sender_limit`, `daily_cap`, `no_credits`, `key_refused`, `api_error` and the
others the [Exim guide](https://email-validation.org/docs/guides/exim/#failures) lists). When the filter itself is stopped or slow, Sendmail
skips it (no `F=` flag; `R:10s` stays above the filter's own wait). To switch it all off at once, run
`systemctl stop ev-milter.socket ev-milter.service`, or remove the line from `sendmail.mc` and rebuild.

## Related

- [Exim](https://email-validation.org/docs/guides/exim/)
- [Postfix](https://email-validation.org/docs/guides/postfix/)
- [Statuses and reasons](https://email-validation.org/docs/statuses/)

## More on Sendmail

- [Sendmail integration](https://email-validation.org/integrations/sendmail/)
