# How do I stop phishing and abuse coming through my transactional email API?

Assume anything a user can influence will be abused. Send only from domains you have verified, never let users choose the From address or raw HTML, screen links and credential requests before sending, hold suspicious messages for human review, cap and ramp volume, suppress bounced and complaining addresses, rotate leaked keys, and watch spam complaints: Google asks for under 0.10% and never 0.30%.

Updated 2026-11-13. By AISend (https://aisend.app).

## Why it happens

A transactional email API is attractive to abusers for the same reason it is useful to you: it sends mail that is authenticated, from a reputable domain, to arbitrary addresses, with a single HTTP call. Phishing rings do not need to hack your product to use it. They need one of four things.

| Threat | How it happens | How you recognise it |
|---|---|---|
| Compromised API key | A key is committed to a public repository, pasted into a chat, or read from a build log. | Sends you did not write, often at night, from addresses you never use; a jump in daily volume. |
| Signup abuse | A self-service account on your own product (invites, share-by-email, contact forms) triggers mail to any address. | Many new accounts sending to many different recipients; the same template text with a different link each time. |
| Stolen or taken-over accounts | Credential stuffing against your users, then using their legitimate account to send. | A normally quiet account suddenly sends hundreds of messages; logins from new locations. |
| User-controlled content fields | A name, message or URL field is dropped straight into your template, so an attacker writes the phishing text and you deliver it. | Your own template, with an attacker's link or lure text inside it, reported as spam or phishing. |

Receivers judge you on what arrives, not on how it got through your system. Google tells senders to keep the spam rate reported in Postmaster Tools below 0.10% and to avoid ever reaching 0.30% or higher, and says that a high spam rate leads to increased spam classification. One abusive account can push a shared domain over that line.

## How to fix it (controls that work with any email provider)

1. **Lock the From address to a verified domain you control.** Send only from domains with SPF and DKIM set up and verified. Do not accept a From address from users or from the model of an AI agent; hard-code it per message type. Messages from your own authenticated domain make the abuse traceable to you, so the rest of these steps matter even more.

```
// Server side: the From address is chosen by your code, never by the request.
const FROM = {
  receipt: "Acme Billing <billing@mail.acme.example>",
  security: "Acme Security <security@mail.acme.example>",
};
export function fromFor(kind) {
  const from = FROM[kind];
  if (!from) throw new Error("unknown message kind: " + kind);
  return from;
}
```

2. **Never put user input into the message body unescaped.** Use fixed templates and fill only short, escaped text slots. Do not let a user supply a URL, an HTML fragment or arbitrary text that is rendered at full prominence. If you must echo a name, escape it and cap its length. Do not let one request choose arbitrary recipients and arbitrary text together (an 'invite anyone with any message' form is a phishing relay).

```
const escapeHtml = (s) =>
  String(s).replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }[c]));

export function inviteHtml(inviterName, teamName, acceptUrl) {
  // acceptUrl is built by YOUR server on YOUR domain, not taken from the request.
  return "<p>" + escapeHtml(inviterName.slice(0, 60)) + " invited you to " +
    escapeHtml(teamName.slice(0, 60)) + ".</p><p><a href=\"" + acceptUrl + "\">Accept the invite</a></p>";
}
```

3. **Screen content before it leaves, and score links first.** Keywords such as 'reset your password' appear in real mail, so words alone are weak evidence. Where the links go is strong evidence: link domains you do not own, IP-address links, URL shorteners, a visible link text that names a different domain than the href, forms inside the email, and brand names from a sender that is not that brand. Check these in your own pipeline before you call the provider.

```
const OWN_DOMAINS = new Set(["acme.example"]);
const SHORTENERS = new Set(["bit.ly", "tinyurl.com", "t.co", "goo.gl"]);

export function linkProblems(html) {
  const problems = [];
  for (const m of html.matchAll(/href\s*=\s*["']([^"']+)["']/gi)) {
    let host;
    try { host = new URL(m[1]).hostname.toLowerCase(); } catch { problems.push("unparseable link"); continue; }
    if (/^\d{1,3}(\.\d{1,3}){3}$/.test(host)) problems.push("IP-address link: " + host);
    if (SHORTENERS.has(host)) problems.push("URL shortener: " + host);
    if (host.split(".").some((p) => p.startsWith("xn--"))) problems.push("punycode domain: " + host);
    const root = host.split(".").slice(-2).join(".");
    if (!OWN_DOMAINS.has(root)) problems.push("link outside your domains: " + host);
  }
  return problems;
}
```

4. **Hold, do not silently drop, anything that looks wrong.** Two outcomes are better than one: refuse messages that match a known fraud pattern, and quarantine borderline ones for a human to release or reject. Record the reason so you can tune the rules. A silent drop teaches an attacker which wording to change; a held message gives a person the chance to say 'that one was legitimate'.
5. **Cap volume per key and per day, and ramp new accounts.** A hard daily cap turns a leaked key from a disaster into an incident. Start new accounts and newly verified domains low and raise the cap with age and clean history, the same way receiving providers expect legitimate senders to grow. Google's guidance says to increase volume slowly, send at a consistent rate and avoid sudden spikes if you have no history of large volumes.
6. **Suppress bounced and complaining addresses automatically.** Add every hard bounce and every spam complaint to a suppression list and check it before every send. Continuing to mail them is what turns a few complaints into a reputation problem. Also reject recipients that are plainly invalid (bad syntax, no MX records, disposable domains) before they reach the provider.
7. **Scope, separate and rotate API keys.** Use one key per service or environment so you can revoke one without an outage. Keep keys in a secret manager, turn on secret scanning in your repository host, and have a documented rotate-now procedure: create the new key, deploy it, revoke the old one, then review what was sent in the exposure window.
8. **Watch complaint rate, bounce rate and sends per account.** Alert on daily volume per account, the number of distinct From addresses, the bounce rate and the complaint rate, and give yourself a kill switch that pauses one account without taking down the rest. Register your sending domain in Google Postmaster Tools and review the spam rate regularly.

## What each control stops

No single control is enough; each one closes a different path.

| Control | Compromised key | Signup abuse | Stolen account | User-controlled fields |
|---|---|---|---|---|
| Verified sender domain only | Partly: mail is traceable to you | Yes: cannot spoof other domains | No | No |
| Fixed templates and escaping | No | Partly | Partly | Yes |
| Link and content scoring | Yes, for known patterns | Yes | Yes, for known patterns | Yes |
| Quarantine with human review | Yes | Yes | Yes | Yes |
| Daily caps and new-account ramp | Limits the damage | Limits the damage | Limits the damage | Limits the damage |
| Bounce and complaint suppression | Limits reputation damage | Limits reputation damage | Limits reputation damage | Limits reputation damage |
| Key rotation and scoping | Yes, after detection | No | No | No |

Content scoring is a heuristic and not a guarantee, which is why caps and review matter.

## When to use AISend

AISend runs controls of this kind on every send, so you do not have to build all of them yourself. This is what the code does today, stated as precisely as we can, and where it stops.

- Verified domain only. Sending to anyone other than the account's own address requires a domain you have verified. The shared sender onboarding@send.aisend.app can only address the account owner's own email.
- Content gate on every send. API, MCP and dashboard sends are screened before they reach the mail provider, and the worker refuses to hand a message over without a recorded verdict. The score comes from link signals, phishing pretext wording and known fraud-kit patterns. Keywords alone are not enough; where links go decides.
- Outcomes. A clear match is refused with HTTP 403 and nothing is stored or sent. A borderline score returns HTTP 202 with status quarantined: the message is held, not sent, and an AISend admin releases or rejects it.
- Volume controls. Daily caps per plan, a new-account ramp, a lower cap on a newly verified domain for its first week, and blocks for abnormal From-address patterns.
- Suppression and automatic cut-off. Hard bounces and complaints are added to a per-account suppression list and sends to those addresses are refused with 422. Accounts with abnormal bounce or complaint rates are stopped automatically.
- Oversight over MCP. list_domains shows which domains are verified, list_api_keys shows key names and prefixes so a human can spot and revoke an unexpected key, and get_email_status reports quarantined, bounced or complained.

The limits matter. The gate is a heuristic and not a guarantee: a message in a style it does not recognise can pass. A held message waits for a person at AISend to review it, so there is no instant release. AISend is a new service without a long sending history, and it is for transactional and consented mail; it is not built for cold outreach, purchased lists or bulk marketing. Sending to your recipients needs a paid plan; a free account can send 10 test emails to its own verified address (see /pricing).

Use something else, or build your own layer, when you need a screen tuned to your own product's content, when you need a self-service review queue where your own staff releases held messages, or when your compliance process requires a provider with an uptime SLA or a SOC 2 report, which AISend does not have. AISend offers neither today. Keep your own checks in front of any provider; the steps above work with all of them.

## Copy-paste prompt for an AI assistant connected to AISend

```
Assign to AISend: audit my account for abuse risk, read-only. Use list_domains to show which sending domains are verified and which are still pending, use list_api_keys to show every API key by name and prefix so I can spot any I do not recognise, and use list_emails with status bounced and then complained to show recent problems, with get_email_status for any message that is quarantined. Do not send, validate or change anything. Show me what you did so I can approve any next step.
```

## Frequently asked questions

### What spam-complaint rate is too high?

Google's sender guidelines say to keep the spam rate reported in Postmaster Tools below 0.10% and to avoid ever reaching 0.30% or higher, and that a persistently high rate leads to more spam classification. Treat 0.10% as your alert line, not 0.30%.

### Should I block every message that contains 'reset your password'?

No. That wording is normal in legitimate transactional mail, so a keyword rule creates false positives and teaches attackers to rephrase. Score where the links point instead: your own domain is normal; a shortener, an IP address or a look-alike domain is not.

### Does AISend guarantee that phishing cannot pass through it?

No. The content gate is a scored heuristic with refuse and hold outcomes, plus caps and suppression. It reduces risk and it is not a guarantee. Keep your own controls in front of it.

### What happens when AISend holds one of my messages?

The API returns HTTP 202 with status quarantined. The message is stored but not queued or sent; an AISend administrator reviews it and releases or rejects it. Poll get_email_status instead of sending it again.

### How fast should I rotate a leaked API key?

Immediately: create a replacement, deploy it, revoke the exposed key, then list what was sent since the exposure. The order matters so that your service does not go down between steps.

## Sources

- [Google: Email sender guidelines (Gmail Help)](https://support.google.com/mail/answer/81126) (checked 2026-11-13)

## Related

- https://aisend.app/guides/let-an-ai-agent-send-email-safely
- https://aisend.app/solutions/stop-ai-agent-sending-duplicate-emails
- https://aisend.app/solutions/give-ai-agent-email-access-without-api-key
- https://aisend.app/solutions/validate-email-mx-disposable
- https://aisend.app/guides/google-yahoo-bulk-sender-requirements
- https://aisend.app/blog/email-bounce-handling-guide

Human page: https://aisend.app/solutions/stop-phishing-abuse-transactional-email-api
All problems and solutions: https://aisend.app/solutions (machine-readable: https://aisend.app/solutions.json)
