WordPress SMTP with Localhost

How to Send WordPress Emails on Localhost With SMTP

Do you want to get 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. In this guide, we’ll show you how to:

  1. Choose an SMTP provider for localhost
  2. Set up WordPress SMTP on localhost
  3. Send test emails from WordPress on localhost
  4. Disable WordPress email notifications on localhost

Fix Your WordPress Emails Now

First, let’s learn how to send emails easily on a local site.

How Do I Send an Email From WordPress on Localhost?

You can send email 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 by Flywheel
  • DevKinsta
  • WAMP/ MAMP/ LAMP/ XAMPP

1. Choose an SMTP Provider for Localhost

Before installing WP Mail SMTP, you’ll want to consider which email provider you want to use on WordPress localhost.

If you don’t pick a mailer, you’ll still be using the default, PHPmailer. This isn’t reliable, and some features won’t work.

For example, you’ll see the error The mailer you've selected (Mail) is not currently supported by our Domain Checker in WP Mail SMTP. This means you can’t use WP Mail SMTP’s built-in DNS verification once you publish your website.

WP Mail SMTP supports tons of email providers with free and paid plans. At this stage, you might want a free provider while you’re testing things out, with the option to upgrade once your site is live.

Email Providers With Free Plans For Testing

Here’s a quick summary of email providers along with their free trials or free plan tiers.

Provider Free email sending limit
SMTP.com 30 days free trial
Sendinblue 300 emails per day
Mailgun 3-month free trial
SendGrid 100 emails per day
Amazon SES 200 emails per day in Sandbox
Zoho Mail Varies
Gmail (supports Gmail aliases) 500 emails per day (across entire Google account)
Microsoft Outlook/ Office 365 10,000 emails per day
Other SMTP server Varies depending on provider

The Other SMTP server is the most basic configuration. While it will usually work fine, most SMTP servers have fairly low sending limits, and emails may still wind up in your Junk folder.

We recommend that you use a service like Sendinblue or SMTP.com instead of an SMTP server, because:

  • Using an API is more secure than SMTP
  • All emails will be delivered reliably because they’ll have the correct authentication
  • You can scale up your limits later if you need to, without any interruption to your site.

If you’ve decided on a provider, let’s go ahead and get set up.

2. Set Up WordPress SMTP on Localhost

WP Mail SMTP is the best SMTP plugin for WordPress. It lets you easily send emails from localhost without writing any code.

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.

Configure an Email Provider or SMTP Server

Now we’re ready to select the email provider or SMTP service you want to use.

Click the icon here to select the mailer first:

Choose an email service provider for WordPress SMTP

Each provider has a slightly different procedure for completing set-up, so you can click below to jump to our documentation for each one:

Mailers available in all versions Mailers in WP Mail SMTP Pro
SMTP.com Microsoft Outlook
Sendinblue Amazon SES
Mailgun Zoho Mail
SendGrid
Gmail / Google Workspace
Other SMTP

Go ahead and complete the additional configuration details now. When you’re set up and your account is connected, come back to this article so that we can continue with the Setup Wizard.

Enable Email Logging on Localhost

On the next screen in the Wizard, email deliverability and error tracking will be enabled automatically.

If you’re using our Pro version (or above), you can also turn on email logging and weekly summaries here as well.

Enable WordPress email logs and weekly summary

While you’re testing out your site, you’ll find our email logging tools especially helpful. You can view your log files in WordPress to see if emails were Failed or Sent. If your email provider supports it, it’ll also tell you if the emails were Delivered.

Check out how this works in our article on how to log your WordPress emails.

When email logging is enabled, WP Mail SMTP will also show your log data in a dashboard widget. That will mean any issues are easy to spot at a glance:

WP Mail SMTP Pro dashboard widget

So enabling email logs is a smart move, and it means there’s much less risk of emails failing without you noticing.

Back to the Wizard!

On the final screen, you can set your preferred email address as the From Email across your entire site. If you set up your account with Gmail, you can pick your default alias here too.

Select alias in WP Mail SMTP setup wizard dropdown

After that, WP Mail SMTP will automatically send you a test email to confirm that outgoing messages are working with your new email configuration.

Automatic test email from WP Mail SMTP

3. Send Test Emails from WordPress on Localhost

Do you want to send more test emails from WordPress on localhost? Some plugins have email test tools, but they’re usually super basic and don’t give you a lot of information.

The Email Test in WP Mail SMTP will check your email sending and your DNS records at the same time. So we’ll show you how it works in preparation for your site launch.

To send an email and check your domain’s DNS settings, head to WP Mail SMTP » Tools and click the Email Test tab.

Test localhost email in WordPress

From here, you can send an email test whenever you want to. Just fill in the Send To address and hit the Send Email button.

Send test email from WP Mail SMTP

If WP Mail SMTP detects any problems with your DMARC, DKIM, or SPF records, you’ll see a warning with more tips on how to solve it.

Why Do Localhost Emails Have Broken Images?

Did your WordPress test email have broken images?

That’s completely normal when you’re testing WP Mail SMTP on localhost. The HTML test email you received likely looked like this:

Localhost test email with broken images

The images appear to be broken because they’re loaded from your website. So if your website isn’t live on the internet, the images won’t be accessible.

Everything’s still working fine, and this doesn’t mean that your localhost emails aren’t working.

Note: if this happens when you’re sending from a live site, it might be because the email went to spam. In that case, you’ll want to check your DNS settings.

Now let’s look at 1 more feature in WP Mail SMTP that’ll help when developing WordPress sites on localhost.

4. Disable WordPress Email Notifications on Localhost

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.

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! Now you have WordPress SMTP set up on localhost.

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.

Comments

  1. Actually this is mission imposible whithout credit card or or or .

    Something missing in this article,these awesome free email services needs credit cards.

    When this is “easily” on localhost why you dont aprove comments 😛

    1. Hi Goran,

      Some mailers such as the Microsoft Outlook mailer, Gmail mailer, Other SMTP mailer should not require a credit card.

      In case it helps to know, comments are approved only once we send out a reply to the comment.

      I hope this helps, thanks! 🙂

      1. Actually not,i tried all plugins and cant test email in xampp,simply doesnt work in local environment.Thanks for reply.

      2. Hi Goran,

        In that case, it sounds like you are experiencing a technical issue with your setup. For us to best help you with this, you can send a message to our support. When sending a message, you should share the details of what you are experiencing when you try to send a test email including the full error log as shown in this screenshot.

        If you have a WP Mail SMTP license, you have access to our email support so please feel welcome to submit a support ticket.

        Otherwise, we also provide limited complimentary support in the WP Mail SMTP WordPress.org support forum.

        Thanks!

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.