How to Configure Gmail to Become an SMTP Server in WordPress

HomeWordPressHow to Configure Gmail to Become an SMTP Server in WordPress

How to Configure Gmail to Become an SMTP Server in WordPress

If you use a form creator plugin such as Contact Form 7 or Elementor‘s form builder to create a form on your WordPress site, chances are you will get an error message like “There was an error trying to send your message” or “Server error. Form not sent”. If you see these errors, the problem is not on your form. Instead, these problems are probably caused by the PHP configuration on the web hosting service you use.

There is a function in WordPress called wp_mail. Most form creator plugins use this function to send emails. In order to make WordPress’ wp_mail function work, you need to enable the send_mail function on your PHP configuration. Unfortunately, some web hosting providers don’t enable PHP’s send_mail function. If you use a VPS or even a dedicated server, you can simply enable PHP’s send_mail function since you have full control over your server configuration, including the PHP configuration.

If you use a shared hosting service, you can use an SMTP server to fix the problem you experience with your form. No, you don’t need to install an actual SMTP server. Instead, you can configure Gmail to work as an SMTP server for your WordPress site.

How to configure Gmail as an SMTP server in WordPress

To turn Gmail into an SMTP server in WordPress, you need help from the Post SMTP plugin. This plugin (available for free) allows you to use Gmail as an SMTP server.

First off, login to your WordPress dashboard and go to Plugins -> Add New. Search for Post SMTP on the search box and click the Install Now button once you found it. Activate the plugin right away once installed.

Once the plugin is installed and activated, go to Post SMTP -> Post SMTP to start the configuration. Start by clicking the Start the Wizard button.

Enter the Gmail account you want to use as an SMTP server and click the Next button. Also enter your name on the Name field and click the Next button.

On the next step, simply click the Next button.

Next, select the SMTP – gmail.com:587 option on the Socket section and select 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 as well as the client secret. You can get the client ID and the client secret by creating a Google app from Google API Console. Before creating one, copy the URLs on the Authorized JavaScript origins and the Authorized redirect URI fields. You will need these URLs on the app configuration on Google API Console.

To start creating a Google app, go to Google API Console and login with your Google account. To ease your job, we suggest you use the same Google account as the one you use on Google Search Console (formerly Google Webmaster). On the Google API Console main dashboard, create a new project by clicking the dropdown menu on the top side, followed by NEW PROJECT on the top-right corner of the appearing window.

Give your project a name and click the CREATE button.

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

Once done adding the domain, click OAuth consent screen on the left panel, select the External option and click the CREATE button.

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

To get the client ID and the client secret, click Credentials on the left panel. Click the Create credentials button and select OAuth client ID.

On the next step, select Web application. Give your OAuth client ID a name and paste the URLs you copied from the WordPress dashboard above (on the Post SMTP configuration page) to the available fields and click the Create button.

You should see a popup after clicking the Create button. Copy the client ID as well as the client secret provided by this popup.

Switch back to your WordPress dashboard and paste the client ID as well as the client secret you have just copied 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 the Email option.

Click the Finish button. Until here, the configuration process is complete, but you need to grant access to the Google app you have just created to read, compose, and send emails using your Google account. To do so, click the Grant permission with Google link.

After clicking the link, you will be asked to select your Google account. Make sure to select the Google account you use on the Google app you have just created. You will probably get the following alert after selecting your Google account. Click the Advanced link followed by Go to yourdomain.com (unsafe).

Confirm that you are ok to grant access to your app to read, compose, and read your emails by clicking the Allow button.

To make sure everything has gone well, you can run a test by clicking the Send a Test Email link.

If you see the following result after clicking the Next button, then everything is ok and you can start using Gmail as an SMTP server on your WordPress site.

Now please try to create a new form with Contact Form 7 or your favorite form creator plugin. When creating a form, just make sure to use the same Gmail account as the one you use on the steps above.

hand-picked weekly content in your inbox

.

related posts

LEAVE A REPLY

Please enter your comment!
Please enter your name here