This guide explains how to connect business email accounts in Task Session using Gmail API, Outlook/Microsoft Graph API, and SMTP/IMAP. It is written for admins and technical managers who need a complete but practical setup path.
Table of Contents
- Overview: which connection type should you use?
- Prerequisites
- Gmail connection setup (Google Cloud API)
- Outlook connection setup (Microsoft Graph API)
- SMTP/IMAP connection setup (cPanel, FastHost, custom mail server)
- Sync settings and first sync checklist
- Troubleshooting common errors
- Security best practices
Overview: which connection type should you use?
- Gmail API: best when your mailbox is on Google Workspace/Gmail. Most reliable for OAuth and large mailbox access.
- Outlook API: best for Microsoft 365 / Exchange Online mailboxes using Graph OAuth.
- SMTP/IMAP: best for custom providers (cPanel, FastHost, Zoho, private mail hosts) where OAuth is not available.
Prerequisites
- Admin access to your Task Session panel.
- Public HTTPS domain (OAuth callbacks require HTTPS in most providers).
- Email account credentials and provider admin access (Google/Microsoft developer console for API-based setup).
- Correct server time and timezone on hosting (important for OAuth token validation).
Gmail connection setup (Google Cloud API)
Step 1: Create Google Cloud project
- Open Google Cloud Console.
- Create/select a project for your CRM email integration.
- Enable Gmail API.
Step 2: Configure OAuth consent screen
- Go to APIs & Services ? OAuth consent screen.
- Select External (or Internal for Workspace-only organizations).
- Add app details and authorized domain.
- Add required scopes (typically Gmail read/send scopes used by your system).
Step 3: Create OAuth Client ID
- Go to Credentials ? Create Credentials ? OAuth client ID.
- Application type: Web application.
- Add authorized redirect URI from your Task Session email settings page, e.g.:
https://yourdomain.com/ajax/email/google_callback.php(use exact URI shown by your system). - Copy Client ID and Client Secret.
Step 4: Add credentials in Task Session
- Open Email Settings in Task Session.
- Select provider Gmail.
- Paste Client ID and Client Secret.
- Click Connect and approve consent screen.
Step 5: Verify Gmail connection
- Save account and run manual sync.
- Check inbox listing and send a test email.
- If needed, verify logs in
logs/email_sync.log.
Outlook connection setup (Microsoft Graph API)
Step 1: Register app in Azure
- Open Azure Portal.
- Go to Microsoft Entra ID ? App registrations ? New registration.
- Choose supported account type (single tenant or multi-tenant as required).
Step 2: Add redirect URI
- In app registration, open Authentication.
- Add Web redirect URI from Task Session, e.g.:
https://yourdomain.com/ajax/email/outlook_callback.php(exact URI from your settings page).
Step 3: Create client secret
- Open Certificates & secrets.
- Create new client secret and copy value immediately.
Step 4: API permissions
- Open API permissions.
- Add Microsoft Graph delegated permissions required for mail read/send/sync.
- Click Grant admin consent if organization policy requires it.
Step 5: Connect from Task Session
- Select provider Outlook in Email Settings.
- Paste Application (Client) ID, Tenant ID (if required), and Client Secret.
- Click Connect and complete Microsoft login/consent.
SMTP/IMAP connection setup (cPanel, FastHost, custom mail server)
Use this option for non-Google/non-Microsoft mailboxes.
Required values
- Email address (e.g.
[email protected]) - SMTP host (e.g.
mail.yourdomain.comor provider host) - SMTP port (usually 465 SSL or 587 STARTTLS)
- SMTP security type (SSL/TLS/STARTTLS)
- SMTP username/password
- IMAP host (for inbox sync)
- IMAP port (usually 993 SSL)
- IMAP security type
Configuration example (typical)
- SMTP host:
mail.yourdomain.com - SMTP port:
465+ SSL - IMAP host:
mail.yourdomain.com - IMAP port:
993+ SSL
Important note for SMTP accounts
Sending and syncing are separate operations:
- SMTP handles sending.
- IMAP handles reading/syncing inbox/sent folders.
- If send works but sync fails, IMAP credentials/host/port are usually wrong.
Sync settings and first sync checklist
- Enable account sync toggle.
- Select folders to sync (at least
INBOX; optionallySENT,IMPORTANT). - Choose sync start date range (for first import).
- Run manual sync from inbox page.
- Verify:
- New messages appear in list
- Thread opens correctly
- Reply/forward sends correctly
Troubleshooting common errors
1) “Sync error occurred. Refreshing inbox…”
- Check
logs/email_sync.logfor account-specific error lines. - Check IMAP credentials and security type.
- Confirm hosting allows outbound IMAP/SMTP connections.
2) SMTP send error / invalid address
- Ensure recipients are valid and separated correctly.
- Verify sender mailbox authentication and SMTP host/port.
3) OAuth redirect URI mismatch
- Use exact callback URI shown in Task Session settings.
- Protocol/domain/path must match exactly in Google/Azure console.
4) Sender name not shown
- Some providers return only email address (no display name) in IMAP headers.
- System may fallback to derived name from local-part.
Security best practices
- Use dedicated integration app credentials (do not reuse personal app keys).
- Rotate secrets periodically.
- Use least-privilege API scopes.
- Keep server and SSL certificates updated.
- Restrict admin access and review account activity logs regularly.
With correct provider setup, OAuth/API registration, and IMAP/SMTP values, Task Session can reliably send and sync business emails across Gmail, Outlook, and custom hosted domains.

