Yes, it is possible to configure Gmail SMTP via wp-config so that all emails sent from your website go through Gmail. Here are the steps:
- Log in to your Gmail account and navigate to the “Less secure apps” settings page.
- Turn on the “Allow less secure apps” option.
- Generate an App password for your WordPress website by following the instructions on this page: https://support.google.com/accounts/answer/185833
- Open your wp-config.php file and add the following lines:
define( 'WP_MAIL_SMTP_AUTH', true );
define( 'WP_MAIL_SMTP_SECURE', 'tls' );
define( 'WP_MAIL_SMTP_PORT', 587 );
define( 'WP_MAIL_SMTP_HOST', 'smtp.gmail.com' );
define( 'WP_MAIL_SMTP_USERNAME', 'your-gmail-address@gmail.com' );
define( 'WP_MAIL_SMTP_PASSWORD', 'your-gmail-app-password' );
Replace “your-gmail-address” with your actual Gmail address and “your-gmail-app-password” with the app password you generated in step 3.
Save the changes to your wp-config.php file.
After completing these steps, all emails sent from your WordPress website will be sent through Gmail SMTP.
All Done!