How to Connect Email to AI Agent
Connect your Flametree AI agent to email systems using IMAP/SMTP protocols to enable automated communication through email channels.
Prerequisites
- Email Account with IMAP/SMTP access enabled
- SMTP server credentials for sending emails
- IMAP server credentials for receiving emails
- 2-Factor Authentication (2FA) enabled on your email account
- App password or OAuth credentials (strongly recommended)
- Admin access to your Flametree account
- Dedicated email account (recommended) to avoid conflicts and ensure consistent message handling
Setting Up Email Integration
Step 1: Prepare Email Account
-
Enable IMAP/SMTP Access
- For Gmail: Enable Less secure app access or use App Passwords
- For Outlook: Ensure IMAP is enabled in account settings
- For corporate emails: Contact IT admin for server details
tipFor reliable message handling, use a dedicated email account for the agent, for example
support@company.com. This helps avoid conflicts with personal or shared business inboxes. -
Generate App-Specific Password
- Gmail: Google Account > Security > 2-Step Verification > App passwords
- Outlook: Account Security > Additional security options > App passwords
- Yahoo: Account Security > Generate and manage app passwords
If authentication fails:
- Verify username and password
- Ensure 2FA is configured with an app password
- Check that IMAP/SMTP access is enabled
Step 2: Collect Email Server Information
If you use Gmail, Outlook/Office 365, Yahoo, or Exchange, jump straight to Popular Email Provider Settings for ready-made server addresses and ports.
You can provide a single value or set up multiple accounts. Save these values from your email provider:
| Parameter | Description | Example |
|---|---|---|
| Username | Full email address | user@example.com |
| Password | Account or app password | your_app_password |
| IMAP Server | Incoming mail server | imap.gmail.com |
| IMAP Port | IMAP server port | 993 (SSL) |
| SMTP Server | Outgoing mail server | smtp.gmail.com |
| SMTP Port | SMTP server port | 587 (TLS) or 465 (SSL) |
If connection fails:
- Verify server URLs and ports
- Ensure your network allows outbound SMTP/IMAP connections
- Try alternative SMTP ports (587 or 465)
Configuring Flametree Integration
Step 1: Create Email Integration
-
Navigate to Channels
- Go to Settings > Channels
- Open Email (IMAP/SMTP)
- Select Add +
-
Fill Configuration
tipFor Gmail, Outlook/Office 365, Yahoo, or Exchange, see Popular Email Provider Settings for ready-made values
Field Description Required Example Value Source Name Custom integration name ✅ Support Email Connector Your choice Description Integration purpose ❌ Customer support email integration Your choice Address Email address used by the channel ✅ support@company.com Your email account Password Password for the email address ⚠️ Non-OAuth only your_app_password Your email account IMAP Server Incoming mail server ✅ imap.gmail.com Email provider settings IMAP Port IMAP server port. Use 993for SSL unless your provider requires another port.✅ 993 Email provider settings SMTP Server Outgoing mail server ✅ smtp.gmail.com Email provider settings SMTP Port SMTP server port. Use 587for TLS or465for SSL unless your provider requires another port.✅ 587 Email provider settings Enable OAuth Enables OAuth authentication for the whole channel ❌ false Your email account OAuth refresh token Refresh token for OAuth authentication ⚠️ OAuth only refresh_token_here OAuth provider console OAuth token URI Token endpoint URI ⚠️ OAuth only https://oauth2.googleapis.com/token OAuth provider docs OAuth client ID OAuth client ID ⚠️ OAuth only client_id_here OAuth provider console OAuth client secret OAuth client secret ⚠️ OAuth only client_secret_here OAuth provider console Inbox check interval [env CHECK_INTERVAL] Interval in seconds for checking the inbox. ❌ 15 Your choice Field notes
-
Multiple values: For Address, Password, IMAP Server, IMAP Port, SMTP Server, SMTP Port, and OAuth credential fields, you can enter comma-separated values. Keep the same order across related fields. Example:
first@mail.com, second@mail.com. -
Enable OAuth: OAuth applies to the whole channel. All accounts in one integration must use the same authentication method.
-
Address: When multiple accounts are connected, Flametree sends outbound emails through them in a fixed repeating sequence. After the first email, each recipient stays linked to the same sender account.
-
Inbox check interval [environment variable CHECK_INTERVAL]: Use a value that matches the channel priority:
15seconds — Critical support channels60seconds — Standard business email300seconds — Low-priority or bulk email
-
-
Click Save to create the integration.
-
Click Start in the upper-right corner to start the channel.
Step 2: Connect to AI Agent
-
Open Agent Configuration
- Navigate to your target AI agent's settings
- Go to Communication channels section
-
Assign Channel
- Select your email integration from the list
- Toggle Inbound ON if this agent should reply to incoming emails; leave it OFF for outbound (send-only) flows. When the same mailbox is connected to multiple agents, only one should have Inbound ON
- Save the agent configuration
-
Restart the agent: click Stop agent then Start agent to apply the changes.
If emails are not received, verify IMAP configuration and inbox check interval. Also ensure the channel is active.
Popular Email Provider Settings
| Provider | SMTP Server | SMTP Port | IMAP Server | IMAP Port | Security |
|---|---|---|---|---|---|
| Gmail | smtp.gmail.com | 587 | imap.gmail.com | 993 | TLS/SSL |
| Outlook/Office 365 | smtp.office365.com | 587 | outlook.office365.com | 993 | TLS/SSL |
| Yahoo | smtp.mail.yahoo.com | 587 | imap.mail.yahoo.com | 993 | TLS/SSL |
| Exchange | mail.company.com | 587 | mail.company.com | 993 | TLS/SSL |
Configuration Options
Configure additional email settings through Set Environment Variables.
Additional Account-Specific Variables
The values can be single or comma-separated for multiple accounts.
| Variable | Description | Default |
|---|---|---|
EMAIL_NAME | Display name shown in the From field. Comma-separate for multiple accounts | None |
IMAP_MAILBOX | IMAP folder to read mail from (e.g. INBOX, Support) | INBOX |
SMTP_ATTEMPTS | Number of retries before giving up on a send | 5 |
SMTP_DELAY | Pause between SMTP retry attempts (seconds) | 5 |
FULL_EMAIL_ADDRESS | Full sender string Name <address@x.com>. Overrides EMAIL_NAME | None |
FROM_TEMPLATE | Format for the From header (placeholders: name, address) | {} <{}> |
MESSAGE_CONTENT_TYPE | MIME type of outgoing body (text/plain or text/html) | text/plain |
Channel-Level Variables
| Variable | Description | Default |
|---|---|---|
EMAIL_RETRY_LIMIT | Number of email client request attempts before graceful exit | 3 |
EMAIL_MAX_ATTACHMENT_BYTES | Maximum size of inbound attachments (bytes). Set to 0 to disable limiting | 10485760 (10 MB) |
Security Considerations
Credential Security
- Use app passwords instead of main account passwords
- Enable 2FA on email accounts
- Rotate credentials regularly
- Use environment variables for sensitive configuration
- Prefer OAuth authentication when available
Email Security
- TLS/SSL encryption for all connections
- Validate sender identity before processing