📄 Configure Google Workspace / Gmail Email Server

Configure Google Workspace / Gmail Email Server

Use a Gmail Server

Using a Gmail server allows you to send transactional messages using a Google Workspace account. To get started, follow these steps below. 

  1. Log on to the Google API Console.
  2. Select the project beside the Google Cloud logo > Select the project
  3. If there is not project created yet, Click New Project
  4. In the New Project page, enter the following
    1. Project Name: Odoo
    2. Organization: Select the Google Workspace Organization
    3. Location: If your are using Google Workspace, select the organization name
  5. Click Create then the page will redirect you back to the overview. If the page doesn’t redirect to the User Type options, click on OAuth consent screen in the left menu.

OAuth Overview

  1. In the OAuth Overview page, click Get Started.
  2. Enter the App Information
    1. App Name: Odoo
    2. User support email: email address of the account
  3. Click Next.
  4. In the Audience section select the User Type.
    1. Personal Gmail Accounts are only allowed to be External User Type, which means Google may require an approval, or for Scopes to be added on. However, using a Google WorkSpace account allows for Internal User Type to be used.
    2. Note, as well, that while the API connection is in the External testing mode, then no approval is necessary from Google. User limits in this testing mode is set to 100 users.
  5. Click Next.
  6. In the Contact information, enter: info@onevector.io
  7. Click Next.
  8. Agree to the User Data Policy and click Continue.
  9. Click Create.
  10. Then click Create OAuth Client.

Create OAuth client ID

  1. In the Application type, choose Web application.
  2. Add Odoo or Odoo Mailer in the Name field.
  3. Leave Authorized Javascript origins empty.
  4. In the Authorized redirect URIs: https://yourdbname.odoo.com/google_gmail/confirm. Remember to replace "yourdbname.odoo" to your database name.
  5. Click Create.
  6. Copy the Client ID and save it.
  7. Download the JSON file.

Odoo > Use a Gmail Server

  1. On Google Cloud, get the Client ID and Client Secret from the Client ID for Web Application
    1. Click on the App's name
    2. Copy the Client ID and Secret
  2. In your Odoo settings, paste the Client ID and Secret in the Emails > Use a Gmail Server section.
  3. Click Save.
  4. Leave these blank: App logo, App Domain
  5. Add Authorized Domain: https://www.odoo.com

Setup Custom Email Servers

Now that you have created credentials, it is time to set up your Outgoing Email Server, which will enable you to send mass mailing from Odoo using a Google Workspace account.

  1. In the Odoo Settings, go to Emails > Use Custom Email Servers > Outgoing Email Servers. You can also access this through the settings of the Email Marketing app > Configuration > Settings > Configure Outgoing Mail Servers
  2. Once there, click New and enter the following:
    1. Name: Google Workspace / Gmail or anything that is descriptive of Gmail.
    2. FROM Filtering: the email address you want to send from
    3. Authenticate with: choose Gmail OAuth Authentication
    4. Priority: 10
    5. Convert attachments...: leave as is
  3. In the Connection section, setup the following:
    1. Connection Encryption: TLS (STARTTLS) encryption only
    2. Debugging:  unchecked
    3. SMTP Server:  smtp.gmail.com
    4. SMTP Port:  587
    5. Username: the email address you want to send from
  4. Click Save at the top.
  5. Click Connect your Gmail account.
    1. Make sure you are logged in with the same account you want to send from.
  6. In the Gmail popup
    1. select which account you want to use (if you have multiple logged in)
    2. Click Allow
    3. If the connection is valid, you will be redirected back to Odoo. If not, the error message will be displayed by Gmail for you to change in the App's credential settings.
  7. Finally in the Outgoing MailServer setup page, click Test Connection at the top-left.
    1. When a pop-up shows up saying Connection is Successful, you are all set.

Reference at Odoo.Com (outdated) https://www.odoo.com/documentation/18.0/applications/general/email_communication/google_oauth.html