How to send WordPress emails on localhost with smtp

How to Send WordPress Emails on Localhost With SMTP

Do you want to send WordPress emails on localhost with SMTP?

If you don’t set up SMTP on localhost, you may not be able to test that your site’s sending emails reliably.

Thankfully, it’s fairly simple to configure SMTP to start sending emails properly from your localhost site.

Fix Your WordPress Emails Now

How Do I Send an Email From WordPress on Localhost?

You can send emails from WordPress on localhost with WP Mail SMTP.

The plugin takes over the default email sending function in WordPress so that your emails are routed through an SMTP provider instead.

That means you’ll receive plugin messages and contact form tests from your staging site, even if it’s not live on the internet.

WP Mail SMTP makes it easy to use SMTP on localhost so you don’t get the Could not instantiate mail function error. It supports many free providers that are ideal for trying things out before you launch.

We’ll walk you through the setup steps and recommend some free providers you can use while testing your new website.

How to Get WordPress Emails on Localhost With SMTP

The following steps will work with any localhost installation, including:

  • Local WP (formerly Local by Flywheel)
  • DevKinsta
  • WAMP/ MAMP/ LAMP/ XAMPP

1. Install WP Mail SMTP

WP Mail SMTP is the plugin you’ll need in order to send emails from your WordPress localhost installation.

If you haven’t installed WP Mail SMTP yet, you’ll want to download the zip file from your WP Mail SMTP account.

You’ll find it in the Downloads tab:

Download WP Mail SMTP to fix WPForms contact form not sending email

Next, open up your WordPress dashboard.

Head to the Plugins page and browse for the zip file. Click Install Now to install it on your local site.

Install WP Mail SMTP

As soon as you activate the plugin, the WP Mail SMTP Setup Wizard will open.

2. Select an SMTP Mailer in the Setup Wizard

To start configuring an SMTP mailer for your localhost site, click on the Let’s Get Started button on the welcome screen of the WP Mail SMTP Setup Wizard.

SMTP setup wizard get started

WP Mail SMTP supports all the top mailing services. For this tutorial, we’ll choose Sendinblue because it’s free and is the easiest to set up for a localhost site.

Press Save and Continue on the bottom right after choosing Sendinblue as your mailer.

sendinblue mailer

Now, you’ll need to enter an API key for your Sendinblue account and a domain that’s configured with Sendinblue.

Sendinblue config

If you don’t already have a Sendinblue account, you can get started for free without even needing to enter any credit card info.

Go to Sendinblue on a new tab (make sure to leave the current WP Mail SMTP Setup Wizard open in another tab or window).

Just enter your contact information to create a new Sendinblue account. Once your account is ready, move on to the next step.

3. Add a Domain to Sendinblue

To add a domain to your Sendinblue account, open your Sendinblue dashboard.

Click on your profile icon on the top-right and then select Senders & IP.

Senders & IP

On the horizontal bar, click on the Domains tab.

Domains tab

Then, click on the blue Add a New Domain button.

add new domain

The domain name isn’t important for a localhost installation. You can enter anything that you’d like to be your domain name. For this tutorial, we’re just going to call our domain “example”.

Make sure to click the box next to “I would like to use this domain name to digitally sign my emails“. Then, press Save.

Enter domain name

As you press Save, a modal window will open asking you to authorize your domain by adding various different DNS records.

But since you only want to send emails from a localhost WordPress installation, you don’t need to perform any authorization steps. Press the cross (x) button to skip authorization.

Skip authorization

Great! Now we just need to grab an API key, as shown in the next step.

4. Get the Sendinblue API Key

Click on your profile icon on the top-right again and select SMTP & API from the menu.

SMTP & API

On this new page, click on the blue +Create A New API Key button.

create new api key

Enter a name for your key and then click on Generate.

Name and generate API key

As soon as you press Generate, Sendinblue will create a new API key for you.

Copy the key and press OK.

Copy API key

Now, we have everything we need to complete our SMTP configuration for a localhost WordPress site.

5. Complete WP Mail SMTP Configuration

Return to the WP Mail SMTP Setup Wizard tab.

First, we’re going to paste the API key we just created and copied in the API field.

Enter API key

Scroll down and enter the domain that you previously added in step 3 in the Sending Domain field.

Enter a name in the From Name field. This is the name that will appear for your outgoing WordPress emails.

After that, enter a from email. This can be anything as long as you make sure your sending domain is the same as you entered above.

Sending domain

Then press Save and Continue to go to the next step.

Save and continue

Choose the features that you want to enable for WP Mail SMTP and then press Save and Continue again.

save and continue

You can either skip or save all the next steps from where. On the final step, WP Mail SMTP will check your configuration and display a success message if everything was set up properly.

Note: If you’re a Windows user, you might get an error message at this stage (cURL error 60). Unfortunately, this is a known issue on Windows and requires editing some code to get it working. Jump to this section for instructions on resolving this error.

Click on Send a Test Email to run a test yourself and make sure emails are sending from your localhost site.

send a test email

The next step covers how you can send a test email.

6. Send a Test Email From WordPress on Localhost

On the test email screen, enter an email address that you have access to, and press Send Email.

Send test email

You’ll get a message suggesting that your email might have sent.

email test done

Now, head over to your inbox, and you should see the test email. Bear in mind that it sometimes takes a few minutes for the email to arrive. You should also check your spam folder if the email doesn’t appear in your inbox after a few minutes.

Also, the images in the test email might be broken. This is because they’re loaded from your website. So if your website isn’t live on the internet, the images won’t be accessible.

Instructions for Windows Users

When setting up SMTP localhost on a Windows machine, many users get this error:

cURL error 60: SSL certificate problem: unable to get local issuer certificate

This is a known issue. But thankfully, it’s not that hard to fix. The fix involves downloading a small file and adding a single line of code to your localhost installation’s php.ini file.

To start, go to this page and download the cacert.pem file.

After the download is finished, you’ll have to locate the php.ini file for your localhost WordPress installation in your system. You should be able to find this from:

C:/Users/Local Sites/conf/php/php.ini.hbs

Open the php.ini.hbs file using a code or text editor (Notepad will work just fine too). Then, enter this line of code anywhere within the file:

curl.cainfo=”/path/to/downloaded/cacert.pem”

In the code above, just replace the “/path/to/downloaded/” part with the actual location of the cacert.pem file in your computer. When you’re done, save the php.ini file with your new changes and close it.

Now, restart your localhost WordPress server and visit your site. Go to WP Mail SMTP »  Settings »  Email Test, and run the email test again.

Send test email

If the changes you made were correctly saved, you should see this message:

email test done

Excellent! Just head over to your inbox to find the test email.

email success

Congratulations! That finishes the SMTP setup for your localhost WordPress site.

But to get even more value out of WP Mail SMTP, here’s an optional step you might want to take.

7. Disable WordPress Email Notifications on Localhost (Optional)

Now you’ve got your WordPress SMTP working on localhost, you’ll start to receive automated email notifications from WordPress for things like:

While you’re developing your site and testing things out, you might want to disable automatic update emails in WordPress.

WP Mail SMTP has a set of configuration options that let you easily turn emails on or off without diving into code. This is an awesome way to stop your localhost sites from sending tons of emails that you don’t want.

But remember, you’ll need a Pro license to access this feature.

To control your localhost emails, head to WP Mail SMTP » Settings.

WP Mail SMTP settings

And now click Email Controls from the tabs across the top.

Email Controls in WP Mail SMTP

Now you can easily disable any WordPress emails that you don’t want to receive.

Disable automatic plugin update emails

And that’s it! You can now get WordPress emails on localhost with SMTP.

Fix Your WordPress Emails Now

Next, Pick a Transactional Email Provider

Will your new website send a lot of emails? You’ll want to pick a provider that can handle high volumes of WordPress emails and deliver them without delays.

We’ve got a guide to transactional email providers that’ll help you decide which one to use when you launch.

Ready to fix your emails? Get started today with the best WordPress SMTP plugin. WP Mail SMTP Elite includes full White Glove Setup and offers a 14-day money-back guarantee.

If this article helped you out, please follow us on Facebook and Twitter for more WordPress tips and tutorials.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

This form is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.