Connect Google Workspace
What you need
- A Google Workspace administrator account.
- Your relay address: Administration > Integrations, card SMTP BCC relay, Set up, Your relay address. It looks like
[email protected]. Always copy the full address.
Two parts:
- Routing rule: archives every new message. Required.
- Connector: syncs users, groups and domains and imports existing Gmail mail. Optional. It does not replace the routing rule.
Create the routing rule
- In EasyMailArchive, open Administration > Integrations.
- On the SMTP BCC relay card, click Set up.
- Under Your relay address, click Copy.
- Open Gmail routing in the Google Admin console (Apps > Google Workspace > Gmail > Routing).
- At Routing, click Add another rule (or Configure if there is no rule yet).
- Under Messages to affect, tick Inbound, Outbound and Internal - sending and Internal - receiving.
- Under For the above types of messages, do the following, choose Modify message.
- Under Also deliver to, tick Add more recipients, click Add and paste the relay address.
- Click Save.
- Back in EasyMailArchive, click Done. You see "SMTP BCC source created."
Changes in Google take up to an hour.
Test the rule
- Wait until the rule is active.
- Send a mail from a Workspace mailbox to an outside address.
- Send a mail from outside to a Workspace mailbox.
- Send a mail between two Workspace mailboxes.
- Enter each subject in the search bar of your archive.
- Under Administration > Dashboard, the Compliance status card shows "Active, 3 emails archived".
Optional: Google Workspace connector
1. Prepare Google Cloud
- Create a Google Cloud project, or pick an existing one.
- In that project, enable the Admin SDK API: click Enable.
- In the same project, enable the Gmail API: click Enable.
- Open Service accounts and click Create service account. Give it a name. It needs no roles.
- Open the service account, tab Keys, Add key > Create new key, type JSON, Create. The JSON file downloads.
- Note the Unique ID (OAuth 2 client ID). It is the numeric
client_idin the JSON file, not the email address.
Check the project selector at the top: both APIs must be enabled in the project that owns the service account.
2. Allow domain-wide delegation
- Open Domain-wide delegation in the Google Admin console (Security > Access and data control > API controls > Domain-wide delegation).
- Click Add new.
- Under Client ID, enter the numeric client ID.
- Under OAuth scopes, paste this line as it is:
https://www.googleapis.com/auth/gmail.readonly,https://www.googleapis.com/auth/admin.directory.user.readonly,https://www.googleapis.com/auth/admin.directory.group.readonly,https://www.googleapis.com/auth/admin.directory.group.member.readonly
- Click Authorize.
| Scope | Used for |
|---|---|
gmail.readonly | Import of existing mail, read-only |
admin.directory.user.readonly | User sync, read-only |
admin.directory.group.readonly | Group sync, read-only |
admin.directory.group.member.readonly | Group member sync, read-only |
3. Save the connector
- Open Administration > Integrations.
- On the Google Workspace card, click Set up. The Google Workspace setup dialog opens.
- Under Service account JSON key, click Choose JSON key file... and pick the downloaded file.
- Under Admin email, enter the address of a Workspace administrator.
- Under Domains, click Add domain and enter each Workspace domain.
- Optional: enter a Test mailbox (optional), e.g. your own address.
- Click Check. A checklist shows each step as Passed, Failed or Not checked:
- Service account key valid
- Admin SDK API enabled
- Gmail API enabled
- Domain-wide delegation with all four scopes
- Admin email can act as admin
- Test mailbox can list messages
It also shows the project, Client ID and Scopes from your key. Fix any Failed step, then click Check again. - Click Save. You see "Google Workspace connector created. Initial sync started."
What the connector does
- Creates users, groups and domains from your Workspace directory.
- Syncs once a day. Sync now on the card starts a sync at once.
- Creates an import job per new user. Follow them under Administration > Import Jobs: Pending, Running, Finished, Failed.
- View logs on the card lists every sync.
Troubleshooting
Errors appear in the checklist after Check and on the Google Workspace card.
| Error | Fix |
|---|---|
| "Admin SDK API is not enabled", or from Google: "Admin SDK API has not been used in project … before or it is disabled" | Enable the Admin SDK API in the project of the service account. The card offers Enable Admin SDK API. Wait 5 minutes, then click Check again. |
| "Gmail API is not enabled", or from Google: "Gmail API has not been used in project … before or it is disabled" | Enable the Gmail API in the same project. The card offers Enable Gmail API. Wait 5 minutes, then Sync now. |
"Domain-wide delegation not set up", or from Google: unauthorized_client "Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested." | In Domain-wide delegation, check the client ID is the numeric ID of this service account and all four scopes are listed. Changes can take some minutes. |
| "Service account key invalid" | The key was deleted or the file is damaged. Create a new JSON key on the service account's Keys tab. Delete the connector on the card (archived mail stays) and set it up again with the new file. |
| "Google Workspace connection failed" | Check that Admin email is an active Workspace administrator, then test again. |
| "Service account JSON key is required." | Choose the JSON file before saving. |
| "At least one domain is required." | Click Add domain and enter your Workspace domain. |
| "The domain acme.com is already managed by another connector." | Another connector already handles this domain. Remove it there first. |
| Routing rule: mail does not arrive | All four message types ticked? Relay address complete? Wait up to an hour. See Setting Up Email Journaling. |