How to configure SMTP on WordPress with and without a plugin?

Are you trying to send emails using the WordPress dashboard and none of the emails are delivered? You might wonder why all this is happening, is any problem with your WordPress website? Here the actual problem is that WordPress is not configured to send emails. First, we will discuss how to configure SMTP on WordPress without a Plugin and then with a plugin. Before this, we have to understand why we need SMTP for our WordPress website.

Why do we need SMTP for WordPress Emails?

WordPress, by default, is configured to use PHP functions to handle email service. But this PHP mail function is not configured in VPS and Cloud hosting, and some shared hosting providers disable this function to reduce load and spam. These could be why you may face problems while sending or receiving emails using your WordPress website.

Configure SMTP WordPress

SMTP, on the other hand, is a more reliable and secure way of sending emails. SMTP servers are designed to handle large volumes of email traffic and provide authentication and encryption to ensure emails are delivered securely. SMTP can also provide additional features like email tracking and delivery status notifications.

Configure SMTP on WordPress without using a plugin.

In this method, you can manually configure SMTP on WordPress by editing the wp-config.php and function.php files. If you’ve some technical skills, this can be the best method for configuring SMTP.

WordPress configuration File (wp-config.php file): You can locate this file under the root directory of the WordPress website. Edit this using a file manager, FTP server, or SSH terminal.

Theme Function File (function.php): You can locate this file in the Theme of the WordPress website. You can edit this file from the WordPress dashboard through Appearance > Theme Editor.

Email SMTP settings in wp-config.php.

Paste the following files into the wp-config.php file of your WordPress website. We place all the SMTP server settings in the wp-config file for security.

// SMTP email settings
define( 'SMTP_username', '[email protected]' );  // username of host like Gmail
define( 'SMTP_password', 'gmail-app-password' );   // password for login into the App
define( 'SMTP_server', 'smtp.gmail.com' );     // SMTP server address
define( 'SMTP_FROM', '[email protected]' );   // Your Business Email Address
define( 'SMTP_NAME', 'SEO Neurons' );   //  Business From Name
define( 'SMTP_PORT', '587' );     // Server Port Number
define( 'SMTP_SECURE', 'tls' );   // Encryption - ssl or tls
define( 'SMTP_AUTH', true );  // Use SMTP authentication (true|false)
define( 'SMTP_DEBUG',   0 );  // for debugging purposes only

In the above files, change the red color values with your values. If you don’t know where to find all these SMTP server settings, read this article until the end.

Theme functions file (functions.php)

You’ve to add the following lines to the theme functions file. Access the Theme functions file through the WordPress dashboard > Appearance > Theme Editor.

add_action( 'phpmailer_init', 'my_phpmailer_smtp' );
function my_phpmailer_smtp( $phpmailer ) {
    $phpmailer->Host = SMTP_server;  
    $phpmailer->SMTPAuth = SMTP_AUTH;
    $phpmailer->Port = SMTP_PORT;
    $phpmailer->Username = SMTP_username;
    $phpmailer->Password = SMTP_password;
    $phpmailer->SMTPSecure = SMTP_SECURE;
    $phpmailer->From = SMTP_FROM;
    $phpmailer->FromName = SMTP_NAME;

You don’t need to make any changes in the above file, copy the code, and paste it into the function.php file. Save the settings. We advise you to use a child theme; else, these changes will be removed on the theme update.

After making the above changes, you can try sending an email using the contact us form.

Configure SMTP with the help of a plugin.

You need to install the SMTP plugin to send emails using the SMTP service. Many plugins are available in the WordPress plugin store, like Easy WP SMTP, Post SMTP Mailer with Email Log, and many more. You can install any from the list, but Post SMTP Mailer with Email log provides a more user-friendly experience with email log service.

Install Post SMTP Mail with email log to your WordPress website; follow this guide to install a WordPress plugin. A setup wizard will open up or access it from the WordPress dashboard and library.

Configure the Plugin for WordPress Emails.

To configure the SMTP plugin for WordPress, scroll through the WordPress dashboard>Post SMTP and click “Show All Settings”.


When you click on show all settings> it will display the current email mailer configuration used by the WordPress website.

Account setup SMTP configuration

In account settings, you’ll be asked to fill up server settings. Read this complete article to know where you can find all these settings.

  1. Choose the type SMTP
  2. Select mailer type: Post SMTP
  3. Outgoing mail server hostname: You can find this value from your email service provider. Here, we’re using Gmail as an SMTP server; hence the values will be smtp.gmail.com.
  4. Outgoing service mail port: 587;
  5. Envelop from email: The email address you want to use to send emails from the WordPress website,
  6. Security: STARTTLS,
  7. Authentification: Login;
  8. User Name: Your Email Address
  9. Password: Password of the email address (for Gmail, you must generate an app password, the guide provided below).
  10. Save the changes.

WordPress is now configured to send emails. You can now reset or change email addresses or authors and admin and receive email notifications when someone comments on the blog posts.

If you can’t find the server details, follow this guide further.

Find SMTP servers for Emails.

You can use the SMTP server to send emails using WordPress. This SMTP server can be set up using the following:

  • cPanel of the hosting provider,
  • using Gmail(free SMTP but can’t use for heavy mails),
  • Other SMTP service providers.

Set up SMTP using cPanel.

You can use this service if your hosting provider provides cPanel to manage the WordPress website. You have to log in to the hosting provider and visit the cPanel section. And create a Business email address to send emails to WordPress.

cPanel SMTP server setting

You can check the SMTP settings of your email in cPanel, by scrolling to email accounts>connected devices>and outgoing server settings. These are outgoing SMTP server settings.

Use the SMTP server of Gmail.

You can use the SMTP server of Gmail to send emails using your WordPress website.

  • SMTP server: smtp.gmail.com
  • Port for TLS/STARTTLS: 587
  • SMTP username: Gmail Email Address,
  • Password: You can generate an App password. Using this Google App Password Link. Or go to Google Account Settings>Security>App Password.

You can check Gmail SMTP server settings in this article. But you can’t use the SMTP server of Gmail for heavy uses. You can also create a Business email for free using Gmail.

Final Words

This is how we can configure SMTP in WordPress to send emails. I hope this article helped you or resolved the email issue. In case of any doubt, query or feedback, feel free to ask in the comment section below.

Ashok Sihmar

Ashok Kumar working in the Search Engine Optimization field since 2015. And worked on many successful projects since then. He shares the real-life experience of best SEO practices with his followers on seoneurons.com. You also can learn Advance level SEO for WordPress, Blogger, or any other blogging platform. Stay tuned.


  1. Thanks for these instructions.
    Obviously here (https://seoneurons.com/wordpress/configure-wordpress-to-send-emails-using-smtp/#email-smtp-settings-in-wp-configphp) we would add a _unique_ email address dedicated to use by the WordPress site, not a personal or important Workspace address, correct? ;)

  2. Using the Google App Password Link, it says “The setting you are looking for is not available for your account.” So what do I do?

    1. Figured out I needed to enable 2-factor authentication before the App Password function would be available.

  3. I was not using any plugin for Email SMTP from a decade. This is what exactly I want for my website. Thanks a lot Mr.Ashok Kumar!

Leave a Reply

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

Back to top button