Prerequisites
- Your domain is set up and DNS-verified in UGMail
- A valid Bearer token from Settings → API Connection at my.ugmail.co
- Python 3.7+ (for the examples below)
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 UGMail’s SMTP server listens on port
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.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.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.

