Skip to content

[00] Subset Mail, User guide

Gmail and Microsoft 365

Send email from a Google Workspace, Gmail or Microsoft 365 mailbox, with your own Google Cloud or Microsoft Entra app.

Subset Mail Pro 0.6.0 can send your site’s email from a Google Workspace, Gmail or Microsoft 365 mailbox. You register your own app with Google or Microsoft, enter its client ID and secret, and sign in to the mailbox once. No mailbox password is stored. This page covers both providers’ setup, connecting and what to do when a mailbox stops sending.

Microsoft has switched off username and password sign-in for SMTP in Exchange Online, so this is the way to send from a Microsoft 365 mailbox. For Gmail, an app password with the SMTP mailer still works if your Workspace admin allows it.

Before you start

You need:

  • Subset Mail Pro 0.6.0 or later, with the free Subset Mail plugin active;
  • an administrator account on the site, or a network administrator on multisite;
  • admin access to Google Cloud for your Workspace, or to Microsoft Entra for your Microsoft 365 tenant.

Open Subset → Mail → Gmail & Microsoft 365. Each provider’s section shows a Redirect URI, the site’s own wp-admin/admin-post.php?action=subset_mail_pro_oauth_callback address. Copy it from there. The app registration must list it exactly, so set the app up on the live site’s address.

Set up Gmail and Google Workspace

These steps make an Internal app, which any user in your Workspace organisation can connect and Google doesn’t have to review.

  1. Go to Google Cloud console (opens in a new tab), signed in as a Workspace admin, and create a project, for example “Website email”.
  2. Open APIs & Services → Library, search for Gmail API and click Enable.
  3. Open Google Auth Platform and click Get started. Enter an app name and a support email. Under Audience, choose Internal. Add a contact email and click Create.
  4. Open Data Access, click Add or remove scopes and add https://www.googleapis.com/auth/gmail.send. Also tick openid and .../auth/userinfo.email, which tell the plugin which mailbox you connected. Click Update, then Save.
  5. Open Clients and click Create client. Choose Web application and give it a name.
  6. Under Authorized redirect URIs, click Add URI and paste the redirect URI from the plugin’s screen. Click Create.
  7. Copy the Client ID and Client secret from the dialog. Google shows the secret only once.
  8. In WordPress, paste them into Client ID and Client secret under Gmail and Google Workspace, and click Save.

Personal Gmail accounts

A personal Gmail account can’t make an Internal app. Choose External under Audience instead, leave the app in Testing, and add your own address under Audience → Test users.

Google ends a Testing app’s sign-in after 7 days, so you’d have to connect again every week. Publishing the app means a Google review for the gmail.send scope, which a single site won’t pass. For a personal account, a transactional email service such as Postmark or Brevo is a better fit.

Set up Microsoft 365

These steps make a single-tenant app registration with the delegated Mail.Send permission. It can only send as the mailbox that signs in, and only people in your organisation can use it.

  1. Go to the Microsoft Entra admin center (opens in a new tab) and open Entra ID → App registrations. Click New registration.
  2. Enter a name, for example “Website email”. Under Supported account types, choose Accounts in this organizational directory only (Single tenant).
  3. Under Redirect URI, choose Web and paste the redirect URI from the plugin’s screen. Click Register.
  4. On the app’s Overview, copy the Application (client) ID and the Directory (tenant) ID.
  5. Open Certificates & secrets → Client secrets and click New client secret. Pick an expiry and click Add. Copy the secret’s Value, not its Secret ID. Entra shows it only once.
  6. Open API permissions and click Add a permission → Microsoft Graph → Delegated permissions. Tick Mail.Send and click Add permissions. User.Read is already there; keep it. If your tenant doesn’t let users consent to apps, click Grant admin consent.
  7. In WordPress, paste the three values into Directory (tenant) ID, Application (client) ID and Client secret under Microsoft 365, and click Save.

The tenant must be your own tenant ID or domain. Multitenant endpoints such as common aren’t accepted. The mailbox needs an Exchange Online licence.

Client secrets in Entra expire after the time you picked, 24 months at most. Before yours does, add a new one, enter it in WordPress and remove the old one in Entra.

Connect the mailbox

  1. On Subset → Mail → Gmail & Microsoft 365, click Connect with Google or Connect with Microsoft.
  2. Sign in as the mailbox the site should send from, and allow the app to send email.
  3. You’re back on the same screen, which says Connected and shows the address.

Then choose where the mailbox is used:

  • as the main mailer: choose Gmail or Microsoft 365 under Mailer on the Settings tab;
  • as the backup connection, on the Backup tab;
  • for some email only, with a rule on the Routing tab.

Send a test email from the Settings tab, or with wp subset mail test you@example.com.

Choosing a connected mailbox as the main mailer needs Subset Mail 0.8.0 or later. With an older version, the Gmail & Microsoft 365 tab says so, and the backup connection and routing rules still work.

The From address

Email sent through Gmail or Microsoft 365 always comes from the connected mailbox, whatever From address a plugin or the Settings tab sets. Gmail keeps the From name. Microsoft 365 uses the mailbox’s own display name.

To send from a second address, connect a second provider, or use routing rules to send that email through another mailer.

Keep it connected

The plugin renews the mailbox’s sign-in as it sends, and checks it once a day. If Google or Microsoft no longer accepts it, Tools → Site Health shows A connected mailbox can’t send email, and the tab says why. A sign-in stops working when:

  • someone removes the app’s access from the Google or Microsoft account;
  • the account’s password changes or an admin signs it out everywhere;
  • a Google Testing app’s 7 days run out;
  • the Entra client secret expires.

Click Connect again with Google or Connect again with Microsoft to fix the first three. For an expired secret, enter a new one first.

When a send fails, the log and the test email say what went wrong in a sentence, with the provider’s own message under Technical details. If a provider says the mailbox is sending too much, the retry queue tries again later and the backup connection takes over when you have one. Google allows about 2,000 emails a day from a Workspace mailbox and 500 from a personal Gmail account. Microsoft 365 allows about 10,000 recipients a day.

Staging copies

A connection belongs to the site address it was made on. On a copy of the site at another address, such as a staging site made with Subset Sync, the mailbox isn’t used, so the copy can’t send from your mailbox. Email there goes out through PHP’s mail(), and the tab says why. To stop all email from a copy, also set SUBSET_MAIL_DISABLE (see Getting started).

If the live site moves to a new address, add the new redirect URI to the app and connect again. Moving from http to https keeps the connection.

Keep secrets in wp-config.php

The client secrets can be set in wp-config.php instead of on the screen:

define( 'SUBSET_MAIL_PRO_GMAIL_CLIENT_SECRET', 'your-client-secret' );
define( 'SUBSET_MAIL_PRO_MICROSOFT365_CLIENT_SECRET', 'your-client-secret' );

The client IDs and tenant have constants too: SUBSET_MAIL_PRO_GMAIL_CLIENT_ID, SUBSET_MAIL_PRO_MICROSOFT365_CLIENT_ID and SUBSET_MAIL_PRO_MICROSOFT365_TENANT. Secrets and sign-ins saved on the screen are encrypted with a key derived from your site’s auth salt. If you change your salts, connect again.

Disconnect

Click Disconnect under the mailbox, or run:

wp subset mail oauth status
wp subset mail oauth disconnect --mailer=gmail

Disconnecting deletes the sign-in from the site. For Gmail, Google is also asked to revoke it. For Microsoft 365, remove the app’s access in the account’s settings if you want it gone there too. Deleting Subset Mail Pro deletes the sign-ins and secrets.