Table of Contents
Why use the Gmail API on Cloudways?
Most SMTP providers (SendGrid, Mailgun, Elastic Email) require DNS verification on a real domain. Cloudways staging URLs
(e.g., https://wordpress-123456-9999999.cloudwaysapps.com
) aren’t your production domain, so
verification is awkward or impossible. The Gmail API authenticates via OAuth—no DNS records needed—making it perfect
for staging or low-volume transactional email.
Prerequisites
- WordPress running on Cloudways (staging or production).
- Ability to install plugins.
- Access to a Google or Google Workspace account that will send mail.
- Tip: Use one browser session from start to finish—Google will redirect back during OAuth.
Part 1 — Install & start WP Mail SMTP
- Install and activate WP Mail SMTP (by WPForms).
- Go to WP Mail SMTP → Settings and run the Setup Wizard.
- Choose the Google / Gmail mailer. Leave the screen open when it asks for Client ID/Secret.
Part 2 — Create Gmail API credentials
-
Enable the Gmail API
- Open the Google Cloud Console.
- Go to APIs & Services → Library → search “Gmail API” → click Enable.
-
Configure OAuth consent
- APIs & Services → OAuth consent screen.
- Choose External, provide an app name and support email (generic is fine for staging).
-
Create OAuth Client ID
- Credentials → Create credentials → OAuth client ID → type: Web application.
- Authorized JavaScript origins — your Cloudways app URL, e.g.:
Origin
https://wordpress-563276-2954319.cloudwaysapps.com
- Authorized redirect URIs — WP Mail SMTP connect URL:
Redirect
https://connect.wpmailsmtp.com/google/
-
Production status
- On the OAuth consent screen, set the app to In production.
- If you skip this, authorization may fail or be limited.
-
Get your Client ID & Secret
- Credentials → under OAuth 2.0 Client IDs, click your app name.
- Copy the Client ID and Client Secret into WP Mail SMTP.
Connect WP Mail SMTP to Google
- Return to the WP Mail SMTP wizard tab and paste your Client ID and Client Secret.
- Click Allow plugin to send emails using your Google account to start OAuth.
- Approve the consent prompts in Google → you’ll be redirected back to WordPress.
- Save settings.
Send a test email
- Go to WP Mail SMTP → Tools → Email Test.
- Send a test to a mailbox you can check. Confirm delivery and “From” address.
- If it fails, see Common issues below.
Notes for staging vs. production
- Staging: Use a dedicated Google mailbox (e.g.,
staging-notify@yourdomain.com
if you’re on Google Workspace) to keep logs and rate-limits separate. - Production: For higher volume or domain-branded mail, consider a provider with domain authentication (SPF, DKIM, DMARC). Gmail API is great for low-volume transactional and staging.
- From address: Keep it consistent with the connected Google account for best deliverability.
- Cloudways cron: If you rely on scheduled emails, ensure WordPress cron runs (either real cron or visitors). Cloudways lets you add system cron jobs if needed.
Common issues & fixes
- OAuth redirect mismatch: Ensure the exact site origin is in Google’s “Authorized JavaScript origins” and the redirect is
https://connect.wpmailsmtp.com/google/
. - Still using another mailer plugin: Deactivate other SMTP/mail plugins to avoid conflicts.
- App not in production: Switch the OAuth app to In production on the consent screen.
- Changed Cloudways domain: If you bind a new primary domain, add its origin in your OAuth client and re-authorize WP Mail SMTP.
- Gmail send limits: Personal Gmail and Google Workspace have daily send limits. For newsletters or bulk notifications, use a dedicated email service with domain authentication.
Alternatives (when to use a traditional SMTP)
If you need higher throughput, shared inboxes, or fine-grained bounce/complaint handling, consider a traditional SMTP provider: SendGrid, Mailgun, Amazon SES, or an email host offered by your DNS provider. You’ll authenticate your root domain with SPF/DKIM (and configure DMARC) for consistent delivery at scale.