Skip to main content
AI agents increasingly need to interact with the outside world through email — sending task completion notifications, triggering follow-up workflows, or parsing replies to drive the next action. UGMail makes it straightforward to give each agent its own dedicated mailbox with a real email address, so your agents can send and receive email just like a human user would. Because UGMail charges no per-mailbox fees, you can provision a unique address for every agent in your fleet without worrying about cost.

Prerequisites

1

Create a dedicated mailbox for the agent

Provision a mailbox for your agent using the Management API. Give it a descriptive address that identifies the agent’s role or identity.
Store the agent’s password securely in your application’s secrets manager or environment variables — your agent code will need it at runtime.
2

Connect the agent via SMTP to send email

Use Python’s built-in smtplib library to send email from your agent. The example below wraps the SMTP logic in a reusable function you can call from anywhere in your agent’s code.
UGMail’s SMTP server listens on port 587 with STARTTLS. Always call smtp.starttls() before authenticating to ensure credentials are never sent in plaintext.
3

Read replies via IMAP

If your agent needs to act on email replies — for example, to continue a conversation, parse an approval, or trigger a downstream workflow — connect to UGMail’s IMAP server and poll the inbox for unseen messages.
IMAP runs on port 993 with SSL/TLS — imaplib.IMAP4_SSL handles the secure connection automatically. Call check_agent_inbox() on a schedule (e.g., every 30 seconds) or integrate it into your agent’s event loop to process replies as they arrive.
Consider generating a unique, high-entropy password for each agent mailbox rather than reusing passwords across agents. Store each password in your secrets manager (e.g., AWS Secrets Manager, HashiCorp Vault, or a .env file that is never committed to source control). This way, if one agent is compromised, you can rotate just its credentials without affecting others.
Send responsibly. Even with unlimited mailboxes, email providers judge your domain’s reputation based on sending patterns. Avoid sending bulk email from agent addresses — use dedicated transactional email infrastructure for high-volume sends, and reserve your agent mailboxes for low-volume, genuinely transactional messages. Respect bounce signals and unsubscribe requests to protect your domain’s deliverability.

Connection settings reference

Next steps

SaaS Onboarding

Automatically provision a mailbox for every new user during sign-up.

Manage Aliases

Route multiple addresses to a single agent inbox using aliases.
Last modified on July 17, 2026