Skip to content

Google Workspace Email Setup

Professional-level guide for integrating Google Workspace email with Odoo, including catchall addresses, aliases, and OAuth2 authentication.

Architecture Overview

┌─────────────────────────────────────────────────────────────────────┐
│                    GOOGLE WORKSPACE EMAIL FLOW                       │
└─────────────────────────────────────────────────────────────────────┘

                         Your Domain: yourdomain.com
                    ┌───────────────┼───────────────┐
                    │               │               │
                    ▼               ▼               ▼
            ┌───────────┐   ┌───────────┐   ┌───────────┐
            │  Aliases  │   │ Catchall  │   │  Routing  │
            │           │   │           │   │   Rules   │
            │ sales@    │   │ *@domain  │   │           │
            │ support@  │   │   ↓       │   │ purchase+ │
            │ info@     │   │ catchall@ │   │ sale+     │
            └─────┬─────┘   └─────┬─────┘   └─────┬─────┘
                  │               │               │
                  └───────────────┼───────────────┘
                    ┌─────────────────────────┐
                    │   Dedicated Odoo User   │
                    │   odoo@yourdomain.com   │
                    └────────────┬────────────┘
                    ┌────────────┼────────────┐
                    │            │            │
                    ▼            ▼            ▼
              ┌──────────┐ ┌──────────┐ ┌──────────┐
              │  IMAP    │ │   SMTP   │ │  OAuth2  │
              │ Incoming │ │ Outgoing │ │   Auth   │
              └────┬─────┘ └────┬─────┘ └────┬─────┘
                   │            │            │
                   └────────────┼────────────┘
                    ┌─────────────────────────┐
                    │         ODOO            │
                    │                         │
                    │  • Fetchmail Service    │
                    │  • mail.thread routing  │
                    │  • Email sending        │
                    └─────────────────────────┘

Prerequisites

Requirement Description
Google Workspace Business Starter or higher
Admin Access Super Admin or Gmail Settings privilege
Domain Verified Your domain must be verified in Google Workspace
Odoo Access Admin access to Odoo instance

Step 1: Create Dedicated Odoo User

Create a dedicated Google Workspace user for Odoo (don't use personal account).

In Google Admin Console

  1. Go to Google Admin Console
  2. Navigate to Directory → Users
  3. Click Add new user
  4. Create user:
Field Value
First name Odoo
Last name System
Primary email odoo@yourdomain.com
Password Strong password

Why Dedicated User?

  • Separates Odoo emails from personal emails
  • Easier to manage and audit
  • Won't break if employee leaves
  • Can set specific quotas and policies

Step 2: Set Up Catchall Email

A catchall captures emails sent to non-existent addresses at your domain.

Purpose for Odoo

When Odoo sends emails, it uses Reply-To addresses like: - purchase+123@yourdomain.com - sale+456@yourdomain.com - helpdesk+789@yourdomain.com

These addresses don't exist as real users, so you need catchall to capture replies.

Configure Catchall in Google Admin

  1. Go to Google Admin Console
  2. Navigate to Apps → Google Workspace → Gmail → Default routing
  3. Click Configure (or Add another rule)

Catchall Rule Settings

Setting Value
Name Odoo Catchall
Email messages to affect Inbound
Envelope filter Single recipient
Envelope recipient Pattern match: .*@yourdomain\.com

Under If the above expressions match:

Setting Value
Also deliver to Add more recipients
Recipient odoo@yourdomain.com
Advanced options Check "Do not deliver spam to this recipient"

Alternative: Unrecognized Addresses Only

For catchall only on non-existent addresses:

  1. Go to Apps → Google Workspace → Gmail → Routing
  2. Scroll to Catch-all address
  3. Click Configure
  4. Set Catch-all address: odoo@yourdomain.com

Spam Warning

Catchall addresses receive more spam. Google's spam filter still applies, but consider: - Enabling aggressive spam filtering - Using pattern-based routing instead (see below)

Step 3: Set Up Email Aliases

Aliases allow multiple addresses to deliver to one mailbox.

Add Aliases to Odoo User

  1. Go to Directory → Users
  2. Click on odoo@yourdomain.com
  3. Click Add Alternate Emails
  4. Add aliases:
Alias Purpose
catchall@yourdomain.com Fallback for Odoo routing
purchase@yourdomain.com Purchase Order emails
sales@yourdomain.com Sales Order emails
support@yourdomain.com Helpdesk tickets
noreply@yourdomain.com Outbound only emails

Alias Limit

Google Workspace allows up to 30 aliases per user.

Instead of catchall, use pattern routing for better spam control.

Create Routing Rules

  1. Go to Apps → Google Workspace → Gmail → Routing
  2. Click Configure for Routing

Rule 1: Purchase Order Replies

Setting Value
Name Purchase Order Routing
Email messages to affect Inbound
Envelope recipient Pattern match: ^purchase\+.*@yourdomain\.com$
Route Change envelope recipient to: odoo@yourdomain.com

Rule 2: Sales Order Replies

Setting Value
Name Sales Order Routing
Email messages to affect Inbound
Envelope recipient Pattern match: ^sale\+.*@yourdomain\.com$
Route Change envelope recipient to: odoo@yourdomain.com

Rule 3: Helpdesk Replies

Setting Value
Name Helpdesk Routing
Email messages to affect Inbound
Envelope recipient Pattern match: ^helpdesk\+.*@yourdomain\.com$
Route Change envelope recipient to: odoo@yourdomain.com

Rule 4: CRM Replies

Setting Value
Name CRM Lead Routing
Email messages to affect Inbound
Envelope recipient Pattern match: ^(crm|lead)\+.*@yourdomain\.com$
Route Change envelope recipient to: odoo@yourdomain.com

Combined Pattern (All Odoo Models)

For a single rule to capture all Odoo patterns:

Setting Value
Name All Odoo Routing
Envelope recipient Pattern match: ^(purchase|sale|helpdesk|crm|lead|project)\+.*@yourdomain\.com$

Step 5: Configure OAuth2 for Odoo

Google deprecated "Less Secure Apps" in 2024. Use OAuth2 for secure authentication.

Create Google Cloud Project

  1. Go to Google Cloud Console
  2. Click Select a projectNew Project
  3. Create project:
Field Value
Project name Odoo Mail Integration
Organization Your organization
  1. Go to APIs & Services → OAuth consent screen
  2. Select Internal (for Google Workspace) or External (for Gmail)
  3. Fill in:
Field Value
App name Odoo ERP
User support email admin@yourdomain.com
Developer contact admin@yourdomain.com
  1. Click Save and Continue
  2. Add scopes:
  3. https://mail.google.com/
  4. https://www.googleapis.com/auth/gmail.send
  5. https://www.googleapis.com/auth/gmail.readonly

Create OAuth Credentials

  1. Go to APIs & Services → Credentials
  2. Click Create Credentials → OAuth client ID
  3. Configure:
Field Value
Application type Web application
Name Odoo OAuth
Authorized redirect URIs https://yourodoo.com/google_gmail/confirm
  1. Copy Client ID and Client Secret

Install Google Gmail Module in Odoo

  1. Go to Apps
  2. Search for Google Gmail
  3. Install the module

Configure Odoo

  1. Go to Settings → General Settings
  2. Enable Custom Email Servers under Discuss
  3. Enter OAuth credentials:
Field Value
Client ID (from Google Cloud)
Client Secret (from Google Cloud)
  1. Click Save

Configure Outgoing Mail Server

  1. Go to Settings → Technical → Outgoing Mail Servers
  2. Create new server:
Field Value
Description Gmail OAuth2
SMTP Server smtp.gmail.com
SMTP Port 465
Connection Security SSL/TLS
Username odoo@yourdomain.com
Gmail OAuth Authentication Checked
  1. Click Connect your Gmail account
  2. Authorize the connection

Configure Incoming Mail Server

  1. Go to Settings → Technical → Incoming Mail Servers
  2. Create new server:
Field Value
Name Gmail OAuth2 IMAP
Server Type Gmail OAuth Authentication
Username odoo@yourdomain.com
Gmail OAuth Authentication Checked
  1. Click Connect your Gmail account
  2. Click Test & Confirm

Step 6: Configure Odoo Alias Domain

  1. Go to Settings → General Settings
  2. Under Discuss, set Alias Domain: yourdomain.com
  3. Click Save

Step 7: Verify Fetchmail Cron

  1. Go to Settings → Technical → Scheduled Actions
  2. Find Mail: Fetchmail Service
  3. Verify:
Setting Value
Active Checked
Interval 5 minutes

Testing the Setup

Test 1: Outgoing Email

  1. Create a Purchase Order
  2. Send RFQ to a test vendor email
  3. Verify email is received
  4. Check email headers for correct Reply-To

Test 2: Incoming Email (Reply Routing)

  1. Reply to the RFQ email from vendor
  2. Wait for fetchmail (or run manually)
  3. Check if reply appears in PO chatter

Test 3: Catchall

  1. Send email to random123@yourdomain.com
  2. Verify it arrives in odoo@yourdomain.com inbox

Best Practices

Security

Practice Description
Use OAuth2 Never use app passwords in production
Dedicated user Create odoo@domain, not personal email
Audit logs Enable Gmail audit logs in Admin Console
2FA Enable 2-factor authentication on Odoo user

Spam Management

Practice Description
Pattern routing Use specific patterns instead of wildcard catchall
Spam filtering Enable "Do not deliver spam" in routing rules
Monitoring Check catchall inbox weekly for false positives

Performance

Practice Description
Fetchmail interval 5 minutes is optimal (not too frequent)
Archive old emails Move processed emails to archive folder
Monitor quota Check storage usage of Odoo user

Documentation

Practice Description
Document rules Keep record of all routing rules
Change log Track changes to email configuration
Contact info Document who manages email settings

Troubleshooting

Emails Not Routing to Records

Check Solution
Fetchmail active Enable cron in Scheduled Actions
OAuth connected Re-authenticate in mail server settings
Alias domain set Set in General Settings → Discuss
Routing rules Verify patterns in Google Admin

OAuth Connection Failed

Check Solution
Redirect URI Must match exactly in Google Cloud
Scopes Add all required Gmail scopes
API enabled Enable Gmail API in Google Cloud
User type Internal for Workspace, External for Gmail

Catchall Not Working

Check Solution
Rule priority Higher priority rules may override
Propagation Wait 24 hours for rules to apply
Pattern syntax Test regex pattern
User active Odoo user must have Gmail enabled

Check Google Workspace Logs

  1. Go to Admin Console → Reporting → Email Log Search
  2. Search for specific email addresses
  3. Check delivery status and routing applied

Complete Configuration Summary

Google Admin Console

Setting Location Value
Odoo User Directory → Users odoo@yourdomain.com
Aliases User → Alternate emails catchall@, purchase@, etc.
Catchall Gmail → Default routing Route to odoo@
Pattern routing Gmail → Routing purchase+, sale+, etc.

Google Cloud Console

Setting Location Value
Project Dashboard Odoo Mail Integration
OAuth Consent APIs → OAuth consent Internal, with Gmail scopes
Credentials APIs → Credentials Web app OAuth client

Odoo

Setting Location Value
Gmail module Apps Installed
OAuth credentials General Settings Client ID + Secret
Alias domain General Settings → Discuss yourdomain.com
Outgoing server Technical → Outgoing Mail Gmail OAuth2
Incoming server Technical → Incoming Mail Gmail OAuth2 IMAP
Fetchmail cron Technical → Scheduled Actions Active, 5 min

Monthly Maintenance Checklist

  • Verify fetchmail cron is running
  • Check OAuth token is still valid
  • Review catchall inbox for issues
  • Check Google Workspace email logs for errors
  • Verify routing rules still match Odoo models
  • Check storage quota on Odoo user

Sources