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
- Go to Google Admin Console
- Navigate to Directory → Users
- Click Add new user
- 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.
- Go to Google Admin Console
- Navigate to Apps → Google Workspace → Gmail → Default routing
- 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:
- Go to Apps → Google Workspace → Gmail → Routing
- Scroll to Catch-all address
- Click Configure
- 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
- Go to Directory → Users
- Click on odoo@yourdomain.com
- Click Add Alternate Emails
- Add aliases:
Alias Limit
Google Workspace allows up to 30 aliases per user.
Step 4: Set Up Pattern-Based Routing (Recommended)
Instead of catchall, use pattern routing for better spam control.
Create Routing Rules
- Go to Apps → Google Workspace → Gmail → Routing
- 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$ |
Google deprecated "Less Secure Apps" in 2024. Use OAuth2 for secure authentication.
Create Google Cloud Project
- Go to Google Cloud Console
- Click Select a project → New Project
- Create project:
| Field |
Value |
| Project name |
Odoo Mail Integration |
| Organization |
Your organization |
- Go to APIs & Services → OAuth consent screen
- Select Internal (for Google Workspace) or External (for Gmail)
- Fill in:
- Click Save and Continue
- Add scopes:
https://mail.google.com/
https://www.googleapis.com/auth/gmail.send
https://www.googleapis.com/auth/gmail.readonly
Create OAuth Credentials
- Go to APIs & Services → Credentials
- Click Create Credentials → OAuth client ID
- Configure:
| Field |
Value |
| Application type |
Web application |
| Name |
Odoo OAuth |
| Authorized redirect URIs |
https://yourodoo.com/google_gmail/confirm |
- Copy Client ID and Client Secret
Install Google Gmail Module in Odoo
- Go to Apps
- Search for Google Gmail
- Install the module
- Go to Settings → General Settings
- Enable Custom Email Servers under Discuss
- Enter OAuth credentials:
| Field |
Value |
| Client ID |
(from Google Cloud) |
| Client Secret |
(from Google Cloud) |
- Click Save
- Go to Settings → Technical → Outgoing Mail Servers
- 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 |
- Click Connect your Gmail account
- Authorize the connection
- Go to Settings → Technical → Incoming Mail Servers
- Create new server:
| Field |
Value |
| Name |
Gmail OAuth2 IMAP |
| Server Type |
Gmail OAuth Authentication |
| Username |
odoo@yourdomain.com |
| Gmail OAuth Authentication |
Checked |
- Click Connect your Gmail account
- Click Test & Confirm
Step 6: Configure Odoo Alias Domain
- Go to Settings → General Settings
- Under Discuss, set Alias Domain:
yourdomain.com
- Click Save
Step 7: Verify Fetchmail Cron
- Go to Settings → Technical → Scheduled Actions
- Find Mail: Fetchmail Service
- Verify:
| Setting |
Value |
| Active |
Checked |
| Interval |
5 minutes |
Testing the Setup
Test 1: Outgoing Email
- Create a Purchase Order
- Send RFQ to a test vendor email
- Verify email is received
- Check email headers for correct Reply-To
Test 2: Incoming Email (Reply Routing)
- Reply to the RFQ email from vendor
- Wait for fetchmail (or run manually)
- Check if reply appears in PO chatter
Test 3: Catchall
- Send email to
random123@yourdomain.com
- 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 |
| 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
- Go to Admin Console → Reporting → Email Log Search
- Search for specific email addresses
- 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
Sources