Skip to content
Hermesmail
Docs pages

Check sign-up domains

The domain check helps you decide whether to accept a sign-up. Send the domain, or the address someone typed into your form, to POST /domain-checks, and the answer says whether accounts from that domain should be let in. The check is a Hermesmail addition to the API and needs a key with full access. Every field of the request and the answer is on the API reference's Check a domain page, listed in the API reference.

Only the domain is used

Send either domain or email, never both. When you send a whole address in email, the API keeps the part after the last @ and drops the rest as the request arrives: the name before the @ is not stored, not written to any log and not passed to any other service. The domain is then put in one standard form before it is looked up: spaces around it and one trailing dot are removed, letters are made lower case, and a name in another script is turned into its xn-- form. The answer's domain field holds that form.

curl -sS -X POST https://api.hermesmail.app/domain-checks \
  -H "Authorization: Bearer $HERMESMAIL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "domain": "Example.TEST."
  }'

The same check, sent with the address from a form. The answer names the domain only:

curl -sS -X POST https://api.hermesmail.app/domain-checks \
  -H "Authorization: Bearer $HERMESMAIL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]"
  }'

A domain that is not a host name of two or more labels, such as an IP address, a name with a port or a link, is refused with 422 and validation_error, and nothing is looked up.

What each answer means

Every answer has the same six fields: object, domain, verdict, disposable, reason and checked_at.

  • allow: nothing we know of marks the domain as throwaway, broken or risky. Accept the sign-up as usual. disposable is false, and reason is null unless a Hermesmail operator rule allowed the domain.
  • block: we advise against accepting accounts from this domain. reason says why:
    • disposable: the domain gives out temporary inboxes that people use once and abandon. disposable is true.
    • invalid_domain: the domain does not appear able to receive email.
    • high_risk: the domain is neither temporary nor broken, but is judged too risky to accept.
    • operator_rule: the people who run Hermesmail have set a rule for this domain, and the rule decides the answer. A rule can also allow a domain.
  • unknown: we have no answer for the domain right now. disposable and checked_at are null, and reason is unavailable.

checked_at is when the answer was obtained. Answers are kept and reused, so two checks of the same domain can carry the same time.

Let unknown answers through

An unknown answer means we have no answer for that domain right now. It says nothing against the domain, so do not refuse a sign-up on it: treat it as you treat allow, and check the domain again later if it matters to you. An unknown answer counts nothing against your allowance.

A sign-up form example

This example runs when someone submits a sign-up form. It refuses the sign-up only when the answer is block. An allow or unknown answer lets the sign-up through, and so does a check that does not work at all, such as one refused because the allowance is used up, so a problem with the check never stops a real person from joining.

// Decides whether a sign-up may go ahead, from the domain of the address typed into the form.
const baseUrl = process.env.HERMESMAIL_BASE_URL ?? 'https://api.hermesmail.app';

async function screenSignUp(address) {
  try {
    const response = await fetch(`${baseUrl}/domain-checks`, {
      method: 'POST',
      headers: {
        Authorization: `Bearer ${process.env.HERMESMAIL_API_KEY}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({ email: address }),
      signal: AbortSignal.timeout(5000),
    });
    // A check that did not work (the allowance used up, say) turns nobody away.
    if (!response.ok) return { accept: true, reason: null };
    const check = await response.json();
    // Only block refuses: unknown means the check could not finish, not that the domain is bad.
    return { accept: check.verdict !== 'block', reason: check.reason };
  } catch {
    return { accept: true, reason: null };
  }
}

const outcome = (result) => (result.accept ? 'accepted' : 'refused');
const first = await screenSignUp('[email protected]');
const second = await screenSignUp('[email protected]');
console.log(
  JSON.stringify({
    first_sign_up: outcome(first),
    second_sign_up: outcome(second),
    second_reason: second.reason,
  }),
);

Your monthly allowance

Each allow or block answer counts as one check against your team's monthly allowance. An unknown answer and a refused request count nothing. How many checks each plan includes is shown on the pricing page. Once the allowance is used up, or when a plan includes no checks, the API answers 429 with domain_check_quota_exceeded, explained on the errors page, and looks nothing up. A used-up allowance starts again with the next billing period.