How to Fix Email Not Sent in Contact Form 7

Editorial Staff

January 13, 2020

In the segment of free form plugin for WordPress, Contact Form 7 is the most popular one. Despite its name, you can use this form plugin to create forms other than a contact form. There are 14 field types you can add to your form, including file attachment. In Contact Form 7, form submissions are sent to an email that you can set when creating a form.

The common issue experienced by users when creating a form with Contact Form 7 is that the message is not sent. Here is the common error message got by Contact Form 7 users.

If you get an error message like the one above, the problem is not on your form. This problem is technically caused by the web hosting service you use.

Cause of the error

If you get the error message like the one above when creating a form with Contact Form 7, you should not use another plugin since you will probably get a similar issue. As we said, the problem is not on Contact Form 7.

WordPress has a function called wp_mail, which is used by most form plugins to send emails. By default, WordPress’ wp_mail function uses the send_mail function of PHP to work. Unfortunately, some web hosting providers disable PHP’s send_mail function. If this is the case, WordPress won’t be able to send the emails.

How to fix the error

The easiest way to fix the issue you can send a request to your web hosting provider to enable the PHP’s send_mail function. However, it tends to impossible if you use a shared hosting plan. Alternatively, you can use an SMTP server to send emails.

In this post, we will show how to fix the email not sent in Contact Form 7 using the second method. We will configure Gmail to become an SMTP server. We need an SMTP plugin to do so. The plugin we use in this example is Post SMTP.

First off, login to your WordPress dashboard to install Post SMTP. Go to Plugins -> Add New. Tye “post smtp” on the search box and click the Install Now button once you found it. Activate the plugin right away once installed.

Once installed and activated, go to Post SMTP -> Post SMTP and click the Start the Wizard button.

Enter the email address you use on your Contact Form 7 form, enter your name, and click the Next button.

On the next step, simply click the Next button.

Select the SMTP – gmail.com:587 option on the Socket section and the OAuth 2.0 option on the Authentication section. Click the Next button.

On the next step, you will be asked to enter the client ID and the client secret. You need to create a Google app to get the client ID and the client secret. Before creating one, copy the URLs on the Authorized JavaScript origins and Authorized redirect URI fields.

To start creating a Google app, go to Google API Console and login with your Google account. To make your job easier, we suggest you use the same Google account as you use on Google Search Console (formerly Google Webmaster). Click the dropdown menu on the top side and click NEW PROJECT to create a new project.

Give your project a name and click the CREATE button.

With your new project selected, click Domain verification on the left panel ( If you have multiple projects, you can select a project from the dropdown menu on the top side). Click the Add domain button and enter your domain name (without either “https://” or “http://”).

Once your domain is added, click OAuth consent screen on the left panel, select the External option and click the CREATE button.

Give your app a name and enter your domain once again on the Authorized domains field. Click the Save button on the bottom side.

Next, click Credentials on the left panel, followed by Create credentials. Select OAuth client ID.

On the next step, select Web application and paste the URLs you have copied above to the Authorized JavaScript origins and Authorized redirect URIs fields and click Create button.

A popup will appear after you click the Create button. Copy the client ID and client secret.

Return to your WordPress dashboard and paste the client ID and the client secret and click the Next button.

Select a notification service to notify you when an email is failed to deliver and click the Next button. We suggest you choose Email.

Click the Finish button to end the configuration process.

Next, you need to grant access to the Google app you have created above to read, compose, and send emails using your Google account. To do so, click the Grant permission with Google link.

You will be asked to select your Google account (make sure to select the account you use to create the app). After selecting an account you will probably see the following alert. Simply click the Advanced link followed by Go to yourdomain.com (unsafe).

On the appearing popup, click the Allow button.

To check your configuration, run a test by clicking the Send a Test Email link.

Click the Next button. If you see the following result, then everything has gone well. From now on, your Contact Form 7 form should work without a problem.

The bottom line

Most form plugins use WordPress’ wp_mail function to send the submissions via email. You need to enable the send_mail function on your PHP configuration in order to allow WordPress’ wp_mail function work. Unfortunately, you have no access to the PHP configuration if you the shared hosting service. You can try the solution we covered above when experiencing a problem with your Contact Form 7 form.

This page may contain affiliate links, which help support UtilizeWP.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Share This