How to connect Contact Forms 7 to a Google Workspace Gmail

Contact Form 7 is the most popular WordPress contact form plugin by far. With “5+ million” installed, according to the Contact Form 7 entry in the WordPress plugin directory, nothing else comes close. It has its own dedicated site at https://contactform7.com with a large quantity of useful information on how to make the most of it.

Google Workspace Gmail is, of course, the email app in Google’s productivity suite. While there exist differences between Google Workspace Gmail and free Gmail, for the purpose of connecting Contact Forms 7 to Gmail we’ll take an approach that works for both.

Steps involved

These are the steps involved in setting things up:

  1. Install and configure Contact Form 7.
  2. Decide on a connection mode to Gmail.
  3. Install a mailer plugin (that supports connecting to Gmail).
  4. Configure the mailer plugin to work with Google Workspace Gmail.

1. Install and configure Contact Form 7

This is best explained at Getting started with Contact Form 7 and the rest of that site’s excellent documentation pages.

2. Decide on a connection mode to Gmail

At this stage you need to decide on one of two possible approaches to connecting to Gmail.

In fact, one of these approaches may be closed off to you by your Google Workspace administrator. They are:

  1. Tedious and more secure. This approach uses OAuth 2.0 for authentication.
  2. Quick and less secure. This approach uses SMTP for authentication. (This option won’t be available if either a.) you use two-factor authentication to sign into your account, b.) your IT department has disabled “Access for less secure apps”.)

3. Install a mailer plugin

This is where instructions start diverging, based on your choice of connection mode above. Install a mailer:

OAuth 2.0SMTP
Install Gmail SMTP, a mailer plugin focused on accessing Gmail via OAuth 2.0 authentication.Install SMTP Mailer, one of the simplest mailer plugins, but which offers some unique troubleshooting features.

4. Configure the mailer

OAuth 2.0SMTP
Follow the instructions for configuring Gmail SMTP. Try to send a test mail from within the mailer. Follow the instructions for configuring SMTP Mailer. Try to send a test mail from within the mailer.

Connection details for the Gmail SMTP server are:
SMTP Host: smtp.gmail.com
SMTP Authentication: True
SMTP Username: Your full Gmail address, e.g. seymour@mylittleshop.com
SMTP Password: Your Gmail password
Type of Encryption: TLS
SMTP Port: 587
From Email Address: The email address from which emails will appear to be sent unless overridden by your form.
From Name: The name from which emails will appear to be sent unless overridden by your form.
Disable SSL Certificate Verification: Leave unchecked

5. Make Gmail accessible to the mailer plugin and retrieve credentials

OAuth 2.0SMTP
Follow the instructions at How to get a set of OAuth 2.0 Credentials on Google.

By the end of this process you should have a set of new credentials: a Client ID and a Client Secret.
Follow the instructions at How to enable “Less secure app access” on Gmail to open up SMTP access to your Gmail account.

The credentials you’ll need for later are: your Gmail username and your Gmail password.

6. Test site-wide emails

If sending your test mail from within the mailer succeeded in step 5, your WordPress site is all set up for sending emails. You can verify this, for example, by requesting a password reset email.

7. Test Contact Form 7 emails

If sending yourself a password reset worked, Contact Form should work, too.