Secure WordPress SMTP Configuration for Google Workspace Emails

It sometimes get annoying to maintain the SMTP Gateways like Sendgrid and Mailgun for their configurations, authentications and their blacklisted IP Addresses.

In this article we will see how to setup a WordPress SMTP Configuration in Safe way and enable Google Workspace Emails for such activity.

1. Google Workspace Permissions

Let's start with enabling Less Secure Apps for Organization on https://admin.google.com/ac/security/lsa

Once it is done, we will have to enable same for that individual account from https://myaccount.google.com/lesssecureapps.

Our Account is now ready for sending the mails. Let's start with WordPress SMTP Setup.

2. WordPress SMTP Setup

We will be creating SMTP Setting in functions.php file of child theme (prefereble).

// Google Workspace SMTP Setup
add_action( 'phpmailer_init', 'setup_phpmailer_init' );
function setup_phpmailer_init( $phpmailer ) {
    $phpmailer->Host = 'smtp.gmail.com';
    $phpmailer->Port = 465;
    $phpmailer->Username = 'user@example.com';
    $phpmailer->Password = 'Password';
    $phpmailer->SMTPAuth = true;
    $phpmailer->SMTPSecure = 'ssl';
    $phpmailer->IsSMTP();
}

Our setup is now ready to send mails from Any WordPress Plugin like Contact Form 7.

Leave a Reply

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


The reCAPTCHA verification period has expired. Please reload the page.