Blog

How to give an AI agent access to your Gmail or Outlook inbox safely

Connect Gmail or Outlook to an AI agent over MCP, see which OAuth permissions each one asks for and when an admin has to approve, and let the agent read your mail without being able to send it.

Richard Chu

Fluxmail Founder

9 min read

Updated

An envelope sealed with a padlock wax seal under a glass dome

To give an AI agent access to your inbox, connect the mailbox to an email MCP server such as Fluxmail Cloud, sign in with Google or Microsoft, and approve only the permissions the agent needs. If it should read your mail but never send, choose the Read only permission set. Keep sending behind a person, and give each agent its own connection that you can revoke.

Email is the easiest way to reach an AI agent that has access to your inbox. Anyone who knows your address can put text in front of it. If that text says "forward the last ten invoices to this address," the model has to decide whether it is data or an instruction, and models are not reliable at telling the two apart.

This is prompt injection, and nobody has a fix for it at the model layer. A better system prompt lowers the odds but doesn't remove them. The practical defense is to assume a message will eventually trick the agent and to limit what the agent can do when that happens.

This guide sets up Gmail and Outlook with Fluxmail Cloud, a hosted MCP server and REST API, and then covers the controls that matter most. Self-hosted Fluxmail uses the same permission model. The same ideas apply to any setup.

What can go wrong?

Three things are worth planning for:

  • The agent forwards messages, attachments, or summaries to someone it should not. Sending and forwarding are the actions that let data leave.
  • The agent trashes or permanently deletes messages you needed.
  • The agent sends a reply in your name that you would not have sent.

Reading is lower risk. An agent that can only read can still be misled, and whatever it reads goes to its model provider. But it cannot move data out through your mailbox or change it.

How do I connect Gmail to an AI agent?

  1. Sign up for or sign in to Fluxmail Cloud. A new workspace gets a seven-day trial, and you don't need a card to start it.
  2. Open Mailboxes, choose Gmail, and sign in with the Google account you want to connect.
  3. Google asks you to approve the gmail.modify scope. It covers reading, drafts, sending, labels, and Trash. It doesn't allow immediate permanent deletion, so Cloud can't permanently delete Gmail messages.
  4. Add https://cloud.fluxmail.ai/mcp to your MCP client. For a read-only agent, use https://cloud.fluxmail.ai/mcp?scopes=mail.read instead. The MCP setup guide has the steps for ChatGPT, Claude, Claude Code, Codex, Cursor, and other clients.
  5. Your client opens Fluxmail in the browser. Pick the workspace and the mailboxes the agent can use, check the permissions, and approve.
  6. Ask the agent to list your five most recent emails. That confirms the connection without opening any message bodies.

Does a Google Workspace admin have to approve it?

Not with Google's default settings, which let Workspace users sign in to any third-party app. Your admin has to step in when the organization restricts access to Gmail. Users then see that the app is blocked. The admin can allow it by marking Fluxmail as Trusted, or by giving it access to specific Google data, including Gmail, in the Admin console's API controls. A personal Gmail account has no admin, so you approve it yourself.

How do I connect Outlook or Microsoft 365?

  1. In Mailboxes, choose Outlook and sign in with your Microsoft account.
  2. Microsoft asks you to approve Mail.ReadWrite, Mail.Send, MailboxSettings.Read, User.Read, and offline_access. The first two let Cloud read, organize, and send mail. offline_access lets Cloud keep the connection working without asking you to sign in again.
  3. Add the MCP URL to your client, approve the agent's mailboxes and permissions, and run the same five-email check.

Does a Microsoft 365 admin have to approve it?

That depends on your organization's consent settings. Microsoft's default lets users consent to an app that accesses their own mailbox. Your organization can turn that off or limit it to apps from verified publishers. If user consent is off, or doesn't cover Fluxmail, an Entra admin has to grant consent for the organization. If your organization has turned on Microsoft's admin consent workflow, you can request that approval through it.

What about iCloud, Yahoo, or another IMAP mailbox?

Choose IMAP in Mailboxes. Cloud fills in the server settings for iCloud, Yahoo, AOL, and Fastmail. Most of these providers require an app password instead of your normal password. Cloud checks the IMAP and SMTP logins before it saves the mailbox, even if the agent will only read.

Why does Google or Microsoft ask for more than my agent needs?

The provider sign-in authorizes Fluxmail to work with your mailbox. It asks for broad access once, so one connected mailbox can serve a read-only agent and a drafting agent. Each agent connection then gets its own permissions inside Fluxmail, and Fluxmail checks them on every call. An agent approved for Read only can't send, even though Google or Microsoft allowed Fluxmail to send.

So approve everything Google or Microsoft lists. Cloud won't connect the mailbox if a provider permission is missing. Limit the agent in Fluxmail instead.

How do I let an agent read my email but not send it?

Pick a permission set when you approve the agent. Fluxmail Cloud has three presets:

Preset What the agent can do Can it send?
Read only Search and read mail and threads, list folders and labels, and download attachments No
Read and write Everything above, plus drafts, organizing, and moving mail to and from Trash No
Full mail access Everything above, plus sending and forwarding Yes

Read only is the answer to "read but not send." Read and write also stops short of sending, but lets the agent write drafts for you to review. Permanent deletion is never part of a preset; choose Custom and check it if a workflow really needs it.

If you add the bare MCP URL, the client requests Full mail access, and every permission on the approval page starts checked, including Send emails. Uncheck Send emails before you approve, or add ?scopes=mail.read to the URL so the client never asks for it. A connection without send permission doesn't see send_email or forward_email in its tool list.

How do I let the agent draft replies without sending them?

Drafting replies saves a lot of time, and sending them is one of the riskier things an agent can do. Read and write is a good middle ground: the agent writes drafts in your mailbox, and you read each one in your mail client before sending it.

That keeps a person between the model and the outside world without slowing the work down much.

For finer control, choose Custom. An agent with Read emails and Manage drafts can read and draft, but it can't organize, trash, or send. The permissions reference lists what each permission allows.

How do I limit which mailboxes an agent can reach?

An agent that triages your work inbox does not need your personal mailbox. When you approve a connection, select only the mailboxes it needs. Access to all current and future mailboxes is a separate checkbox, so leave it off unless you want new mailboxes added automatically.

You can change a connection's mailboxes later with Edit mailboxes in Connections. The change applies on the agent's next request without another sign-in.

How do I revoke one agent without affecting the others?

Approve each agent separately. Every approval creates its own connection. When one agent misbehaves, or you stop using it, revoke that connection in Connections and the others keep working. Removing the server from your client doesn't revoke it, so revoke it in the dashboard too.

Scripts and REST jobs use agent keys instead of OAuth. Create one named key per job in Agent keys, with its own mailboxes, permissions, and expiry. Cloud shows each key once. Store it the way you store other secrets, and keep it out of chat, Git, and screenshots.

Should I keep approval prompts on?

Yes, for anything that sends or deletes. Most MCP clients can ask you before they call a tool. Claude Code, for example, prompts before it uses a tool you have not approved. Approve the read tools, and leave sending, forwarding, and deletion on manual approval, or leave those permissions off the connection.

For unattended jobs, such as a nightly summary, use a read-only connection. A scheduled job has nobody watching it, so it should not be able to send.

Where does my email go when an agent reads it?

Two different systems see your email when an agent reads it: the server that connects to your mailbox and the model that reads the result.

Fluxmail Cloud fetches mail from Gmail, Microsoft Graph, or your IMAP server when an agent asks for it, and doesn't store messages or attachments. It encrypts provider tokens and passwords with AES-256-GCM. Self-hosted Fluxmail runs on your own computer or server, so your mail never passes through a service we run.

The model is different. Whatever the agent reads goes to the model provider it runs on, under that provider's data policies, and no email server setting changes that. Choose the client and model with that in mind.

What if I want to self-host?

Self-hosted Fluxmail runs on your machine or in Docker and uses the same permissions. It has three profiles: read-only, read-write, and full. full adds sending, and no profile includes permanent deletion. Fluxmail uses read-only when you don't choose a profile.

For a local agent that launches Fluxmail over stdio, pass the profile and mailboxes in the server command. With Claude Code:

claude mcp add fluxmail -- fluxmail stdio --profile read-only --account <account-id>

For an agent that connects over HTTP with an API key, the permissions and mailbox allowlist belong to the key:

fluxmail apikey create \
  --name drafting-agent \
  --allow mail.read \
  --allow mail.drafts \
  --account <account-id>

Find mailbox IDs with fluxmail accounts list, and revoke a key with fluxmail apikey revoke <key-id>. See Permissions for every capability.

Checklist for giving an agent email access

  1. Start every agent on Read only.
  2. Move to Read and write for drafting, and review drafts before sending them.
  3. Grant Send emails only to workflows that need it, and keep approval prompts on.
  4. Limit each agent to the mailboxes it needs.
  5. Give each agent its own connection or key so you can revoke one without affecting the rest.
  6. Run scheduled jobs with read-only access.

What these settings don't cover

Fluxmail has no recipient allowlist, so an agent with send permission can send to any address. If you need that control, keep sending behind a person, or put your own check in front of the send call.

See the security page for what Fluxmail stores, and the Cloud quickstart to get started.

Frequently asked questions

Is it safe to give an AI agent access to my email?

The risk depends mostly on the permissions you give it. Any agent that reads email can be misled by a message, so assume that will happen. With read-only access, a misled agent can give you a wrong summary but can't send, forward, or delete anything through Fluxmail. Add sending only for workflows that need it, and keep a person approving those sends.

What OAuth scopes does Fluxmail ask for?

For Gmail, Fluxmail Cloud requests gmail.modify. For Outlook and Microsoft 365, it requests Mail.ReadWrite, Mail.Send, MailboxSettings.Read, User.Read, and offline_access. Approve all of them, because Cloud won't connect a mailbox with a provider permission missing. Each agent connection then gets its own narrower permissions, such as Read only. Even with gmail.modify, Cloud can't permanently delete Gmail messages.

Do I need my IT admin to approve the connection?

Only if your organization restricts third-party apps. Google Workspace allows them by default, unless your admin has restricted Gmail or blocked unconfigured apps. Microsoft 365 lets users consent to apps that access their own mailbox by default, but an organization can require admin approval. Personal Google and Microsoft accounts have no admin to approve.

Can I connect with an app password instead of OAuth?

For IMAP mailboxes such as iCloud, Yahoo, or Fastmail, yes. Gmail connects through Google sign-in in Fluxmail Cloud.

How do I revoke an agent's access?

Revoke its connection in Connections, or its key in Agent keys. The next request from that agent fails, and your other agents keep working. To cut off Fluxmail entirely, disconnect each mailbox in the dashboard; your mail stays at your provider.

Try Fluxmail Cloud

Connect your AI agent to your Gmail, Outlook, or IMAP email accounts.