Email Integration

Connect Gmail or Outlook for two-way email sync with your CRM contacts.

Two-Way Sync

Import emails and send directly from Pivor

Contact Matching

Only syncs emails from/to your CRM contacts

Automatic Sync

Emails sync every 5 minutes in the background

Per-User Config

Each user connects their own email account

Quick Setup

Add OAuth credentials to your .env file:

# Gmail (Google Cloud Console)
GOOGLE_CLIENT_ID=your-client-id
GOOGLE_CLIENT_SECRET=your-client-secret

# Outlook (Azure Portal)
MICROSOFT_CLIENT_ID=your-client-id
MICROSOFT_CLIENT_SECRET=your-client-secret
MICROSOFT_TENANT_ID=common

Setting up Gmail

1

Create a Google Cloud Project

  1. 1. Go to Google Cloud Console
  2. 2. Click the project dropdown at the top
  3. 3. Click New Project
  4. 4. Name it "Pivor CRM" and click Create
2

Enable the Gmail API

  1. 1. Go to APIs & ServicesLibrary
  2. 2. Search for "Gmail API"
  3. 3. Click Enable
3

Configure OAuth Consent Screen

  1. 1. Go to APIs & ServicesOAuth consent screen
  2. 2. Select External and click Create
  3. 3. Fill in: App name, Support email, Developer email
  4. 4. Add scopes:
gmail.readonly gmail.send userinfo.email
4

Create OAuth Credentials

  1. 1. Go to CredentialsCreate CredentialsOAuth client ID
  2. 2. Select Web application
  3. 3. Add redirect URI:
https://your-domain.com/email/oauth/google/callback
  1. 4. Copy Client ID and Client Secret to your .env

Setting up Outlook

1

Register an Application in Azure

  1. 1. Go to Azure Portal
  2. 2. Search for App registrations
  3. 3. Click New registration
  4. 4. Name: "Pivor CRM", Account type: "Any organizational + personal"
  5. 5. Redirect URI (Web):
https://your-domain.com/email/oauth/microsoft/callback
2

Copy Application ID & Create Secret

  1. 1. Copy the Application (client) ID from overview
  2. 2. Go to Certificates & secrets
  3. 3. Click New client secret
  4. 4. Copy the Value immediately (it won't show again!)
3

Configure API Permissions

  1. 1. Go to API permissions
  2. 2. Click Add a permissionMicrosoft GraphDelegated
  3. 3. Add these permissions:
User.Read Mail.Read Mail.Send offline_access

If required, click Grant admin consent

Using Email Integration

Connecting Your Email

  1. 1 Navigate to Settings (bottom of sidebar)
  2. 2 Click Connect Gmail or Connect Outlook
  3. 3 Authorize access in the OAuth popup window
  4. 4 Your account will show as Connected

Sending Emails

  1. 1 Open a Contact page
  2. 2 Click the Send Email button
  3. 3 Compose your message with subject and body
  4. 4 Click Send - email is sent via your connected account

How Sync Works

Every 5 min

Background sync runs automatically to fetch new emails

Contact-based

Only syncs emails from/to addresses in your CRM contacts

Per-user

Each user's emails sync to their own assigned contacts

Troubleshooting

Emails Not Syncing

  • Check the Settings page for sync error messages
  • Verify the contact has a correct email address set
  • Try clicking "Sync Now" manually on the Settings page
  • Ensure the queue worker is running:
php artisan queue:work

OAuth Connection Failed

  • Verify your credentials are correctly set in .env
  • Check that redirect URIs match exactly (including https://)
  • Ensure all required API permissions are granted in the console
  • For Microsoft, ensure admin consent is granted if required

Tips for Success

  • Test with a single contact first before bulk importing
  • Use a process manager like Supervisor for production queue workers
  • Monitor the storage/logs/laravel.log for sync issues