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 Article
- 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
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 WP (formerly Local by Flywheel)
- 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|
|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:
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.
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:
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|
|Gmail / Google Workspace|
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.
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:
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.
After that, WP Mail SMTP will automatically send you a test email to confirm that outgoing messages are working with your new email configuration.
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.
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.
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:
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:
- Plugin updates
- Theme updates
- Core updates
- Site admin email changes
- Password resets
- New user registrations
- And more.
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.
And now click Email Controls from the tabs across the top.
Now you can easily disable any WordPress emails that you don’t want to receive.
And that’s it! Now you have WordPress SMTP set up on localhost.
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.