Using SMTP authentication to send mail in WordPress

When sending email, it is usually a good idea to send using SMTP authentication. Authenticating with the server will prevent issues such as your message being marked as outgoing spam when being sent. In this article, we will show you how to configure SMTP authentication within WordPress. This guide uses the WP Mail SMTP plugin, we also have a guide on how to use the Easy WP SMTP plugin in WordPress.

In this tutorial:

Installation Configuration

Install the WP Mail SMTP WordPress plugin

  1. First, log into your WordPress admin dashboard.

  2. Once logged in, hover over Plugins and click on Add New. On this page, enter WP Mail SMTP into the search field and press the Enter key.

  3. You should now see a list of your search results. As you have searched for the exact file name, the WP Mail SMTP plugin should be the first result. To install it, click Install Now.

  4. WordPress will now handle the download and installation of the WP Mail SMTP plugin for you. Once complete, be sure to click Activate Plugin to activate it.

Configuring WordPress to send using SMTP authentication

Now that you have installed the WP Mail SMTP plugin, you will just now need to configure it. In the following steps, we will be configuring the SMTP settings for the WP Mail SMTP plugin.

  1. On the left side navigation menu of your WordPress admin dashboard, hover over Settings and click on Email.

  2. Next, scroll down to the SMTP Options section.

  3. Within the SMTP Options section, set Authentication to Yes.

  4. Next up is the Username and Password fields. In these fields, enter the email address that you will be sending from within the Username field, as well as the password for that account within the Password field.

  5. Now that you have entered the proper authentication information, click the Save Changes button.

  6. If you want to test your settings, you may go to the Send a Test Email section and enter an email address that you want to send to, then click the Send Test button.

Congratulations! You have now configured WordPress to use SMTP authentication when sending mail on the server.

Thoughts on “Using SMTP authentication to send mail in WordPress

  • I created my own custom form with php/html (I did so because I wanted the form to insert data into a custom mysql table and I couldn’t do that with WP Forms). However, I want to use the WP Mail SMTP plugin to send mail from that form. I downloaded and configured phpMailer5.2 to do this, but I want to use Google Auth as opposed to my username and PW, and I already have WP Mail SMTP configured for this. How can I make my custom form use WP Mail SMTP?

  • Just as a note, this may or may not work depending the version of PHP you have active. I tested this plugin with two identical WordPress installs on the same server, one running PHP5.4 and one running PHP7.

    PHP5.4: Works as shown up above in the tutorial.

    PHP7: You need to change the “localhost” portion to your server mail address (e.g. biz###.inmotionhosting.com ), port to 465, and check “Use SSL”. It should work after that. If you use the localhost/25/noSSL as the tutorial says, you’ll get an SMTP Authentication error.

    From the research I’ve done, the suspected reason is that PHP7 changed how it handles SSL connections and the plugin hasn’t been updated to reflect that.

  • Thank you for posting the solution.  I created a new account in Cpanel and plugged in the info as suggested and now Wordpres sending out emails via SMTP.  SOLVED!

  • My test didn’t work either. Are “localhost” and port 25 correct? This is just the first part of the test response:

    The result was:

    bool(false)
    

    The full debugging output is shown below:

    object(PHPMailer)#14110 (76) {
      ["Version"]=>
      string(6) "5.2.22"
      ["Priority"]=>
      NULL
      ["CharSet"]=>
      string(5) "UTF-8"
      ["ContentType"]=>
      string(10) "text/plain"
      ["Encoding"]=>
      string(4) "7bit"
      ["ErrorInfo"]=>
      string(43) "SMTP Error: Could not connect to SMTP host."
      ["From"]=>
      string(18) "jane@smallbones.ca"
      ["FromName"]=>
      string(4) "Jane"
      ["Sender"]=>
      string(0) ""
      ["ReturnPath"]=>
      string(0) ""
      ["Subject"]=>
      string(41) "WP Mail SMTP: Test mail to jane@airnet.ca"
      ["Body"]=>
      string(68) "This is a test email generated by the WP Mail SMTP WordPress plugin."
      ["AltBody"]=>
    • After following these setup instructions I am getting the error below. I have confirmed that the host is localhost and port is 25. I have also confirmed the login credentials work via webmail for the account being used. What do you suggest?

      Test Message Sent
      The result was:
      bool(false)
      The full debugging output is shown below:
      object(PHPMailer)#1566 (76) {
      [“Version”]=>
      string(6) “5.2.22”
      [“Priority”]=>
      NULL
      [“CharSet”]=>
      string(5) “UTF-8”
      [“ContentType”]=>
      string(10) “text/plain”
      [“Encoding”]=>
      string(4) “7bit”
      [“ErrorInfo”]=>
      string(43) “SMTP Error: Could not connect to SMTP host.”
      [“From”]=>
      string(19) “Info@aohmassage.com”
      [“FromName”]=>
      string(10) “AOHMassage”
      [“Sender”]=>
      string(19) “Info@aohmassage.com”
      [“ReturnPath”]=>
      string(0) “”
      [“Subject”]=>
      string(47) “WP Mail SMTP: Test mail to red.garuda@gmail.com
      [“Body”]=>
      string(68) “This is a test email generated by the WP Mail SMTP WordPress plugin.”

    • I should add that even if I turn off authentication I get the same error message. Domain is aohmassage.com

  • Repeating my post (since it wasn’t posted) and revising my question:

    Is there a way to reconfigure the SMTP settings (username and password) through the php files. If yes, which specific files holds the assignment of the values for the contants, specifically the host, username and password?

    Thank you!!

    • This is a third party plugin and it likely stores the data in the database. You would need to have the plugin installed before this tutorial would be applicable.

  • I am trying to send E-Mails with WP SMTP. I have configured this way:

    Mailer: Send All mails by SMPT

    Return Path: Unchecked

    SMTP Host: smtp.gmail.com

    SMTP PORT: 25

    Encryption: No

    Authentication: Yes

    Username and password are valid, I have double checked

     

    I am trying to send a test email and it is giving 405 Not Found error after loading for somewhere 30 seconds.

    Please guide what could be the problem and effective solution.

    Thanks in advance

    • Hello Rushi,

      Since you’re using a third party server to deliver the email you will need to look at their information in regards to how it should be set up. The guide provided here does a good job showing you both ways that Gmail’s SMTP server can be used to deliver email.

      If you have any further questions or comments, please let us know.

      Regards,
      Arnel C.

  • I have enabled WP Mail SMTP on our site.  But, clicking the SEND button takes 25+ seconds to send the email.  Is there a setting or a way to change this so it is a faster process?  Thanks!

  • Not working. I get the following message after the Test Mail:

     

    est Message Sent

    The result was:

    bool(false)
    

    The full debugging output is shown below:

    • Hello Teo,

      Sorry for the problems with sending emails from WordPress. We would need more information about your installation to investigate the issue. Please provide domain name, email address used, WordPress version, plugin version, and steps you’ve used to duplicate the problem. If you want the issue handled privately, then please submit a verified support ticket to our live support team.

      If you have any further questions or comments, please let us know.

      Regards,
      Arnel C.

    • Are you saying you have to log into WordPress as the admin user? Yes, since you are installing a third party plugin you have to log into WordPress as the admin user. Otherwise, you will not have the correct privileges.

Leave a Reply