Do you need to send emails from a WordPress installation on localhost?
Running WordPress from localhost on your own computer is convenient when developing or testing a new site, plugin, or theme. However, setting up WordPress email on localhost is tricky because your site is offline and so email is not enabled by default.
In this article, we’ll show you how to receive WordPress emails from localhost.
Why Run WordPress on Localhost?
Before you make major changes to your WordPress website, it’s a good idea to first test those changes on a different site that’s not visible to your users.
A staging site is a clone of your live website that is used for testing changes before making them live. Staging sites help you catch errors, so you don’t end up breaking your live website.
However, setting up email on a localhost WordPress install can be tricky, and you may see the error message ‘Could not instantiate mail function’ when WordPress tries to send an email. That’s because email is not enabled on the WAMP and MAMP server stacks by default.
With that being said, let’s take a look at how to receive WordPress emails from localhost.
How to Receive WordPress Emails from Localhost
The first thing you need to do is install and activate WP Mail SMTP plugin on the WordPress installation on your local server. For more details, see our step by step guide on how to install a WordPress plugin.
WP Mail SMTP will take over the default email sending function in WordPress so that your emails are routed through an SMTP provider instead. This means you’ll receive email notifications from your staging site even if it’s not live on the internet.
Setting Up WP Mail SMTP
Once the plugin is activated, the WP Mail SMTP Setup Wizard will start automatically.
The first thing you need to do is choose an SMTP service provider.
You can see our guide on the best SMTP service providers with high email deliverability for help choosing a provider. If you’re unsure, Sendinblue is a good choice for most WordPress sites.
Note: If you wish to use Amazon SES, Microsoft Outlook, or Soho Mail as your SMTP mailer service, then you will need to purchase a WP Mail SMTP Pro license.
During the setup, email deliverability and error tracking will be enabled automatically. Users of the Pro version can also turn on email logging and managing default notifications.
Sending a Test Email
Once you have finished setting up WP Mail SMTP, you can send a test email to make sure that the plugin is configured correctly.
To do that, you need to head over to WP Mail SMTP » Tools in your admin menu, where you’ll see the ‘Email Test’ page. By default, the test email will be sent to your site’s admin email address, but you can change this by typing a different email address into the ‘Send To’ field.
We recommend you keep the ‘HTML’ setting in the ‘On’ position, and then simply click the ‘Send Email’ button. WordPress will try to send a test email to the address you entered.
If there are problems with your email configuration, then you’ll see a message describing the problem, along with some steps you can take to resolve it.
After following the steps to fix the issues, you should send another test email to confirm that your WordPress email is now working.
If your WP SMTP Mail configuration is correct, then you should find an email in your inbox.
You will notice that the test email has broken images, and this is completely normal when sending emails from localhost. That’s because the images are normally loaded from the internet, but your localhost website is not online.
Even if the test email was successful, WP Mail SMTP may have detected a problem with your DMARC, DKIM, or SPF records that can result in deliverability problems. You’ll see links to step by step guides that will help you configure your DNS records correctly.
You can learn more from in guide on how to send a test email from WordPress.
Once you’ve finished fixing the issues, you should send another test email to make sure that everything is working properly now.
Disabling WordPress Email Notifications – Pro Users
Now you’ll start receiving WordPress emails from localhost. This will include notification emails about plugin updates, theme updates, and core updates. You’ll also receive emails about site admin changes, password resets, new user registrations, and more.
You may feel like you’re receiving too many emails. Or you might like to disable certain email notifications while you’re developing and testing your website.
WP SMTP Mail Pro users can control which emails are sent by localhost. You need to head to WP Mail SMTP » Settings. Once there, you should click the ‘Email Controls’ tab at the top of the page. Here you can disable any emails you don’t want to receive.
For example, if you don’t want to receive emails about comments awaiting moderation, then you would simply toggle the setting to the off position.
We hope this tutorial helped you learn how to receive WordPress emails from localhost. You may also want to learn how to get a free email domain, or check out our list of common WordPress errors and how to fix them.