Send Email in WordPress with Gmail SMTP: Quick Guide

Sending emails from your WordPress site can be critical to maintaining communication with your users and customers. In this guide, you will learn how to set up email sending using Gmail SMTP, which ensures that your emails reach their destination effectively and without being marked as spam.

Why use SMTP instead of PHP's mail() function?

WordPress, by default, uses the mail() PHP to send e-mails. However, this method can be unreliable, as many email providers consider emails sent this way to be potentially spam. Using an SMTP server, such as Gmail, offers several advantages:

  • Higher delivery rate: Emails sent via SMTP are less likely to be marked as spam.
  • Secure authentication: SMTP provides a more secure method of authenticating your identity when sending email.
  • Follow-up and analysis: You can keep track of sent emails and their status.

Gmail SMTP configuration in WordPress

To set up Gmail SMTP on your WordPress site, you will need to follow a few simple steps. First, make sure you have an active Gmail account. Then, do the following:

1. Enable access to less secure applications

You will need to allow less secure applications to access your Gmail account. To do so, follow these steps:

  1. Log in to your Gmail account.
  2. Go to My account.
  3. Select Security in the menu.
  4. Scroll down to find Access by less secure applications and activate it.

2. Install an SMTP plugin

There are several plugins that allow you to configure SMTP in WordPress. One of the most popular is WP Mail SMTP. To install it:

  1. Log in to your WordPress administration panel.
  2. Go to Plugins > Add new.
    Send Email in WordPress with Gmail SMTP: Quick Guide
    Download our web maintenance guide Free of charge!
    Free guide for freelancers and small businesses that want to avoid surprises and improve their web performance.
  3. Search WP Mail SMTP.
  4. Install and activate the plugin.

3. Plugin configuration

Once the plugin is activated, you will need to configure it:

  • Go to WP Mail SMTP in the administration menu.
  • In the field From EmailEnter your Gmail email address.
  • At From NameIf you do not enter the name you want to appear, type the name you want to appear.
  • Select Gmail as the method of shipment.

Next, you will need to enter your Gmail account credentials. This includes:

  • Client ID
  • Client Secret

Obtaining Client ID and Client Secret

To get the Client ID and Client Secret, you will need to create a project in the Google Developer Console:

  1. Visit the Google Developer Console.
  2. Create a new project.
  3. Enable the Gmail API.
  4. Go to Credentials and creates a new credential of type OAuth 2.0 Client ID.
  5. Configure the consent screen and add the redirect URL provided by the plugin.

Test your configuration

Once you have entered your Client ID and Client Secret in the plugin, it is time to test if everything is working correctly. In the plugin settings section, you will find an option to send a test email. Be sure to check it out:

  • Click on Send Test Email.
  • Enter a destination e-mail address.
  • Check if the mail has been received correctly.

Troubleshooting common problems

If you don't receive the test email, here are some things you can check:

  • Check that access to less secure applications is enabled.
  • Make sure you have entered the Client ID and Client Secret correctly.
  • Check your spam folder just in case.

Conclusion

Configuring Gmail SMTP in WordPress is a simple process that can significantly improve the delivery of your emails. By following these steps, you can ensure that your messages reach their destination and maintain effective communication with your users and customers.