Why use UGMail for SaaS provisioning
- No per-user fees — provision unlimited mailboxes under a flat plan without per-seat charges eating into your margins
- Instant provisioning — mailboxes are live within seconds of the API call, so there’s no delay in your onboarding experience
- Full API control — create, update, and delete mailboxes programmatically without touching a dashboard
- Standard protocols — every provisioned mailbox works over SMTP and IMAP, so it integrates with any email client or library your users might choose
Prerequisites
- Your domain(s) are set up and DNS-verified in UGMail
- A valid Bearer token stored as a server-side environment variable (
UGMAIL_TOKEN)
1
Set up your domain in UGMail
Before you can provision mailboxes, the domain you want to use (e.g.,
mail.yourapp.com) must be registered in UGMail and have its MX, SPF, and DKIM records configured. Follow the Set Up Your First Domain guide to complete this one-time step.2
Call the UGMail API in your onboarding webhook or trigger
Add a mailbox provisioning step to the server-side function or webhook that runs when a new user completes sign-up. The function below is a drop-in example you can adapt to your stack — it provisions the mailbox and returns the connection settings your application needs.Call this function from your sign-up handler, post-payment webhook, or any other trigger that marks a user as fully onboarded. The returned object contains everything the user or your application needs to start sending and receiving email.
3
Store the provisioned credentials securely
After provisioning, persist the mailbox credentials in your database alongside the user record. Store the password in encrypted form — never in plaintext. If your stack uses a secrets manager, you can store only a reference to the secret rather than the value itself.At minimum, record:
- The provisioned email address
- A reference to (or encrypted copy of) the password
- The SMTP and IMAP connection settings
4
Return connection settings to the new user
Surface the SMTP and IMAP settings in your post-onboarding UI so users can configure their email client or integrate their new mailbox into their own application. A clear connection settings screen reduces support requests significantly.
The username for both protocols is the full email address (e.g.,
alice@yourapp.com) and the password is the one you set during provisioning.Next steps
Manage Aliases
Add team-level addresses like support@ that route to individual user inboxes.
Provision a Mailbox
Explore all the options available when creating a single mailbox via the API.

