How to send WordPress emails on localhost with smtp

How to Send WordPress Emails on Localhost With SMTP

Editorial Note: We may earn a commission when you visit links on our website.

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

A localhosted WordPress site is unable to send emails because your site isn’t online yet. But you can enable email functionality on your WordPress site by using the right plugin, even if you don’t have a web host yet.

In this guide, we’ll show you a fairly method to set up SMTP on localhost and enable outgoing WordPress emails.

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 Brevo (formerly 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 Brevo as your mailer.

Select Brevo as your SMTP mailer

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

Enter your Brevo API key

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

Go to Brevo 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 Brevo account. Once your account is ready, move on to the next step.

3. Add a Domain to Brevo

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

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

Select the option for Senders, Domains & Dedicated IPs

On the next screen, click on the Domains option.

Select the Domains option in your Brevo settings

Then, click on the Add a Domain button.

Add a new domain in Brevo

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 “exampledomain.”

Enter your domain name in Brevo

As you press Save, a new screen will open asking you to verify and authenticate 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. You can skip that part and click on I’ll do it later at the bottom.

Skip the verification and authentication by clicking "I'll do it later."

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

4. Get the Brevo API Key

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

Click on SMTP & API in your Brevo account

On the next page, click on the Generate a new API key button.

Generate your Brevo API key

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

Name your API key in Brevo setup

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

Copy your Brevo API key

Copy the key and press OK.

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 from the API field in Brevo.

Enter your Brevo 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.

Add details for your sending domain in Brevo

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

Save and continue to the next setup step

On the next screen, choose the features that you want to enable for WP Mail SMTP and then press Save and Continue again.

Select which email features you want to enable

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 been sent, but deliverability should be improved. This is because you skipped those steps in Brevo since it’s just a test.

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. If you face any issues with emails not sending due to a host error, check out this comprehensive guide on resolving the ‘could not connect to SMTP host’ in WordPress guide.

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.

You can also set up SMTP for your localhost site using WP Mail SMTP alternatives like Easy WP SMTP following similar steps as we’ve outlined above.

Fix Your WordPress Emails Now

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.

Comments

  1. I set up apache, mariadb and php8 on Server 2022. I discovered Server 2022 no longer offers smtp server. Tried your solution and in less than 10 mins my test server is functioning with email. Thank you!

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.