---
title: AI for Every Mail Provider
date: '2026-11-10'
description: 'A design for bringing Mailingest''s spam filter, categories and AI cards to Gmail and Microsoft 365, with no need to move the mail. Two doors, one rule.'
author: Pablo Fernandez
tags:
  - Email
  - AI
  - Gmail
  - Microsoft 365
  - Mailingest
source: 'https://www.pablofr.com/blog/ai-for-every-mail-provider'
---
Everything [Mailingest](/blog/giving-an-inbox-to-each-agent) does to a message (the spam filter, the [Gmail-style categories](/blog/gmail-style-tabs-for-any-inbox), the [cards on top of an email](/blog/moving-email-ai-to-the-server)) only happens to mail that lives in a Mailingest mailbox. The people I'd most like to offer it to already have Google Workspace or Microsoft 365, and a small business, a school or an NGO does not move its email to get a nicer inbox. Nor should it.

So the design I wrote today brings the processing to mail that stays where it is. There are two ways to connect, and they look like two versions of the same product until you hit one rule that neither Google nor Microsoft will bend: nobody gets to change an email after it has been delivered. That rule decides almost everything below. This is a proposal, not a feature: nothing is built yet, and six decisions are still open. The screenshots are Gmail-style mock-ups rendered from the real card templates, with made-up mail.

## Two doors

The first door is the API. The customer's admin signs in with Google or Microsoft, grants access, and Mailingest reads new mail through the [Gmail API](https://developers.google.com/workspace/gmail/api/guides/push) or [Microsoft Graph](https://learn.microsoft.com/en-us/graph/change-notifications-overview) as it arrives. No DNS changes; the design estimates five minutes to set up.

The second door is a gateway, which is what Proofpoint, Mimecast and Barracuda sell. The customer points their domain's MX record at Mailingest, so every message from the internet reaches us first, and we pass it on to Gmail or Microsoft 365 once it's been processed. It takes DNS changes and a connector on the provider's side: somewhere between half an hour and a day.

| | API | Gateway (MX) |
| --- | --- | --- |
| Setup | sign in with Google or Microsoft | point MX at Mailingest, add a connector |
| Spam and dangerous attachments | after delivery: moved or deleted | before delivery: refused or held |
| Categories | Gmail labels or Outlook categories | headers the provider turns into labels with a rule |
| The AI card inside the email | not possible | inserted before delivery |
| If Mailingest is down | mail arrives anyway, processed later | the backup MX delivers it unfiltered |

Two rows in that table are the whole argument: where spam is stopped, and whether the card can be in the email at all.

## The rule nobody will bend

Through the Gmail API you can [modify a message's labels](https://developers.google.com/workspace/gmail/api/reference/rest/v1/users.messages/modify), move it, trash it. You can't rewrite it. Microsoft Graph is explicit about it in its [reference for updating a message](https://learn.microsoft.com/en-us/graph/api/message-update): the body is "updatable only if isDraft = true". A delivered email is not a draft.

That's a good rule. An inbox where any connected app can quietly rewrite what someone sent you would be a worse inbox. But it means the API door can sort and filter, and can't put anything in the email. The card has to live somewhere else: in a side panel, the add-ons Gmail and Outlook both allow, and in a daily digest of what matters (bills coming due, parcels arriving, bookings coming up).

![A Gmail-style message view of a shipping email from Alpine Trails Co. The email body is plain and unchanged; beside the subject there's an Updates label next to Inbox. On the right, a Mailingest side panel shows the card: Arriving today, a progress bar on Out for delivery, the order and UPS tracking numbers, Track package and View order buttons, then Remind me and Is this wrong?](/blog/ai-for-every-mail-provider/api.webp "Through the API: the label goes on the email, the card goes beside it. The email itself is exactly what the shop sent.")

It works, and for many customers it'll be enough. But an add-on only shows up in the clients that run add-ons, which is roughly where the whole Mailingest idea started: AI that depends on the app you happen to read with.

## Standing in front of the mailbox

The gateway is the only way to put the card in the email, because it gets the message before delivery, when it's still ours to add to. Mail that arrives through it gets the whole processing a Mailingest mailbox gets today, and then, instead of being stored, it's handed to the customer's Gmail or Microsoft 365.

```
  incoming
  internet ──▶ MX: Mailingest ──▶ spam, viruses, lists, lookalikes,
                                  category, card ──▶ ARC seal ──▶ Gmail / M365

  outgoing
  Gmail / M365 ──▶ smarthost: Mailingest ──▶ remove card, sign ──▶ internet
```

*In gateway mode Mailingest sits on both sides of the customer's mailbox: in front of it for incoming mail, and behind it for what the customer sends.*

Inserting the card has a price. The sender's [DKIM](https://www.rfc-editor.org/rfc/rfc6376.html) signature covers the body, so the moment the gateway adds a block to it, the signature no longer matches, and a provider checking it would see a message that was tampered with on the way. Which it was, by us, on purpose.

The answer is [ARC](https://www.rfc-editor.org/rfc/rfc8617.html), a standard written for exactly this: an intermediary that changes a message records what the authentication results were when it received it, and seals that record with its own signature. The provider then has to trust the sealer. Microsoft 365 has a list of [trusted ARC sealers](https://learn.microsoft.com/en-us/defender-office-365/email-authentication-arc-configure) and [enhanced filtering for connectors](https://learn.microsoft.com/en-us/exchange/mail-flow-best-practices/use-connectors-to-configure-mail-flow/enhanced-filtering-for-connectors), which makes it look past the gateway to the real sender's IP. Gmail has an [inbound gateway setting](https://support.google.com/a/answer/60730) for the same purpose: you list the gateway's IPs, and Gmail looks for "the first public IP address that's not in the Gateway IP list" in the `Received` headers. Every signup would come with a step-by-step guide for each provider and an automatic check that the connector is set up right, because a gateway the provider doesn't trust makes mail look worse, not better.

![The same shipping email in a Gmail-style client, received through the gateway: the Mailingest card is inside the email, above the shop's message, with the progress bar, order and tracking numbers, buttons, and a footer saying the summary may contain mistakes and is removed when you reply or forward](/blog/ai-for-every-mail-provider/gateway.webp "Through the gateway: the card is part of the email, so it's there in every client, add-ons or not.")

## Mail for people who don't exist

A gateway accepts mail on behalf of a server it can't see into, and that creates a problem a mailbox never has. If it accepts a message for `nobody@customer.com` and the customer's server later refuses it, the gateway has to send a bounce, to the sender address on the message. Spam forges that address. So the bounce goes to a stranger whose address was borrowed, which is [backscatter](https://en.wikipedia.org/wiki/Backscatter_(email)), and a gateway that does it ends up on blocklists.

The fix is to know who exists before saying yes, and the design has two ways:

- **Ask the customer's server:** during the SMTP conversation, before accepting, open a connection to the destination and see whether it takes `RCPT TO` for that address (a callout), with a cache so it isn't asked for every message.
- **Sync the directory:** read the customer's users, aliases and groups through Google's Directory API or Microsoft Graph. It needs the same sign-in as the API door, and it brings something the callout can't: each person's language, so the categories' folders and the card come in it.

The recommendation is both: the directory when there's a sign-in, the callout when there isn't.

## The back door

A customer can keep a second MX record, with a lower priority, pointing straight at Google or Microsoft. If Mailingest is down, the internet's mail servers try the next MX, and mail still arrives, unfiltered. That's the safety net, and the guide recommends it.

It's also a known trick in the other direction. Spammers send to the lowest-priority MX on purpose, hoping it's the one with no filter in front, and here it would be exactly that. So the guide explains the trade instead of hiding it: a backup MX means you never lose mail when we're down, and it means some spam can walk around the filter while we're up. And when it's the customer's server that isn't answering, mail waits in Mailingest's queue and is retried for up to five days, like any delivery, and the customer gets a notice.

## The card that leaks on reply

This is the decision I haven't made, and it's the interesting one. When a Mailingest mailbox replies to or forwards a message, the card is removed on the way out, because it was written for the person who received the mail and its links ("Is this wrong?", "Turn off summaries") carry a token for that mailbox. You can see the promise in the card's own footer in the screenshot above.

In gateway mode, replies leave from Gmail or Microsoft 365, not from us. Unless the customer also sends through Mailingest, the card goes out quoted in the reply, tokens and all, to whoever is on the thread. There are three ways out, and none is free:

- **All outgoing mail goes through Mailingest**, as a smarthost, the way Mimecast does it. The card comes off exactly as it does today. It's the cleanest, and it adds a step to signup and makes us the customer's outgoing mail as well as incoming.
- **A card with nothing personal in it** when the customer doesn't send through us: the links open a page that asks you to sign in, with no token. Nothing leaks that could be used, but the card still shows up in forwards.
- **No card in the email** without our outgoing path: the category and the verdict go in headers, and the card goes in the daily digest.

My recommendation in the design is the first for anyone who wants the card in the email, and the third for everyone else: an email that carries something it shouldn't to a third party is worse than an email without the card.

## One router, three endings

None of this is a second product. A Mailingest mailbox, the gateway and the API go through the same router and the same steps: spam, lists, attachments, category, card. Only the last step changes:

| Where the mail came from | What happens at the end |
| --- | --- |
| A Mailingest mailbox | stored in Mailingest's IMAP, as today |
| The gateway | delivered to the customer's server, with headers and the card |
| The API | labels and actions applied through the API, the card kept for the panel |

So every rule added to the filter, every category description that gets better, works for all three at once. In gateway mode the mail itself isn't kept, only the decisions (without the content), the cards and whatever is held in quarantine, which needs a web page of its own now that there's no mailbox to hold it in.

The order follows from the rule. The gateway comes first for Google Workspace and Microsoft 365, because it reuses the most and it's the only way to put the card in the email. Then the API, the easy door with no DNS change, which for Gmail also means Google's [security assessment](https://support.google.com/cloud/answer/13465431) for restricted scopes, weeks of process with a cost of its own. Then the add-ons and the digest that make the API door show cards at all. A rule that keeps apps from rewriting your mail is a rule I'd defend for my own inbox, and the price of respecting it is that the best version of this product has to stand in front of the mailbox instead of reaching into it.
