Task Session email setup guide: connect Gmail, Outlook, and SMTP accounts

This guide explains how to connect business email accounts in Task Session using Gmail APIOutlook/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?

  • 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

  1. Open Google Cloud Console.
  2. Create/select a project for your CRM email integration.
  3. Enable Gmail API.

Step 2: Configure OAuth consent screen

  1. Go to APIs & Services ? OAuth consent screen.
  2. Select External (or Internal for Workspace-only organizations).
  3. Add app details and authorized domain.
  4. Add required scopes (typically Gmail read/send scopes used by your system).

Step 3: Create OAuth Client ID

  1. Go to Credentials ? Create Credentials ? OAuth client ID.
  2. Application type: Web application.
  3. 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).
  4. Copy Client ID and Client Secret.

Step 4: Add credentials in Task Session

  1. Open Email Settings in Task Session.
  2. Select provider Gmail.
  3. Paste Client ID and Client Secret.
  4. 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

  1. Open Azure Portal.
  2. Go to Microsoft Entra ID ? App registrations ? New registration.
  3. Choose supported account type (single tenant or multi-tenant as required).

Step 2: Add redirect URI

  1. In app registration, open Authentication.
  2. 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

  1. Open Certificates & secrets.
  2. Create new client secret and copy value immediately.

Step 4: API permissions

  1. Open API permissions.
  2. Add Microsoft Graph delegated permissions required for mail read/send/sync.
  3. Click Grant admin consent if organization policy requires it.

Step 5: Connect from Task Session

  1. Select provider Outlook in Email Settings.
  2. Paste Application (Client) ID, Tenant ID (if required), and Client Secret.
  3. 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.com or 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

  1. Enable account sync toggle.
  2. Select folders to sync (at least INBOX; optionally SENTIMPORTANT).
  3. Choose sync start date range (for first import).
  4. Run manual sync from inbox page.
  5. 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.log for 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.