← Back to Agent

Email Configuration

Connect this agent to an email account so it can send and receive emails autonomously.

Table of Contents

Overview

For Everyone

The Email tab connects your agent to a real email account. Once connected, the agent can read incoming emails, compose replies, and send messages autonomously. You can use any email provider — Gmail, Microsoft 365, Yahoo, Zoho, Fastmail, or any custom IMAP/SMTP server.

For Developers

Email configuration is managed through /bridge/agents/:id/email-config endpoints. The system supports three providers: imap (generic IMAP/SMTP with presets), microsoft (Azure AD OAuth), and google (Google OAuth). OAuth flows open a popup window; completion is detected via postMessage. Connection testing hits /email-config/test. Re-authorization for scope changes is available for Google OAuth.

How It Works

  1. Choose a connection method — Email + Password (IMAP/SMTP), Microsoft OAuth, or Google OAuth.
  2. Enter the required credentials or configure OAuth.
  3. Click Save Configuration.
  4. For OAuth methods, click Authorize to open the sign-in popup.
  5. Click Test Connection to verify everything works.

The status badge in the header shows the current state: Not Connected, Configured, Awaiting Authorization, Connected, or Error.

Connection Methods

Three connection methods are presented as selectable cards:

MethodBest ForRequirements
Email + Password EasyAny email providerEmail address + app password
Microsoft OAuth MediumMicrosoft 365 / Outlook orgsAzure AD app registration
Google OAuth MediumGoogle Workspace orgsGoogle Cloud project with Gmail API

IMAP/SMTP Setup

The simplest method. Select your email provider from the preset dropdown to auto-fill server settings:

Important: Use app passwords, not regular passwords. With 2FA enabled (which it should be), regular passwords won't work. Create app passwords from your provider's security settings.

Microsoft OAuth

For Microsoft 365 organizations:

  1. Go to Azure Portal → App Registrations
  2. Create a new registration with redirect URI: {your-domain}/api/engine/oauth/callback
  3. Under Certificates & Secrets, create a Client Secret
  4. Under API Permissions, add: Mail.ReadWrite, Mail.Send, offline_access
  5. Enter the Application (Client) ID, Client Secret, and Tenant ID
  6. Save, then click Authorize to sign in with the agent's Microsoft account

Google OAuth

For Google Workspace organizations:

  1. Go to Google Cloud Console → Credentials
  2. Create an OAuth 2.0 Client ID (Web application) with redirect URI: {your-domain}/api/engine/oauth/callback
  3. Enable the Gmail API in your project
  4. Enter the Client ID and Client Secret
  5. Save, then click Authorize to sign in with the agent's Google account

A "Re-authorize (Update Scopes)" button appears for connected Google accounts when you need to add new API permissions.

Organization Email Config

If your organization has configured a shared OAuth application (Microsoft or Google), a green banner appears at the top. In this case, the Client ID and Secret are inherited automatically — you just need to authorize each agent's individual account.

Client Organization Email

When an agent belongs to a client organization (has a client_org_id), an info banner appears showing the organization name and context. This indicates:

Tip: If you manage multiple organizations, check the org banner to confirm you're configuring the right agent's email for the right organization.

Testing the Connection

After saving, click Test Connection. A successful test shows:

A failed test shows the specific error message. Common issues: wrong password, firewall blocking IMAP, app password not created.

Key Concepts

Best Practices

Troubleshooting

ProblemSolution
Connection test fails with "Authentication failed"Regenerate the app password. Ensure you're using an app password, not the account password.
"Awaiting Authorization" badge won't clearClick the Authorize button to open the OAuth popup. Make sure popups aren't blocked.
OAuth popup shows an errorVerify the redirect URI matches exactly. Check that API permissions are granted in Azure/Google.
Agent can receive but not sendFor IMAP/SMTP: check the SMTP host and port. For M365: ensure Mail.Send permission is granted.
"Last Error" banner appearsThe error message gives the specific issue. Common: token expired (re-authorize), password changed, account locked.
AgenticMail Enterprise Documentation Report an issue