How to Send Mail from Localhost in WordPress (XAMPP, WAMP, ALL)
Do you know you can send emails from your localhost WordPress site? In this post, we’re learning how to send mail from localhost in WordPress.
In this article, we’re going to learn how to send mail from localhost in WordPress. Sometimes when you create your WordPress site on localhost you need to check if the contact form is working. It is possible to conduct this test on the localhost. Many of you have requested this tutorial, so here it is!
We’ll use a plugin to setup our localhost email functionalities. We’re going to send emails using Gmail (for free!). Don’t worry, the plugin is free and it won’t take you that long to send an email from WordPress localhost. Let’s start.
Why send emails from WordPress localhost
When developing a website, many WordPress professionals first build it in a localhost environment. Even if you have a running project and want to make some changes to that website, it is best to download the WordPress files and run that site on your localhost. Once you’ve updated your site, you can put your WordPress site on a live server. So here’s why you need to send emails from WordPress localhost
- To test if your contact forms are working
- To test if WooCommerce work order is being mailed
If you have an eCommerce site, when a customer makes a purchase order, an email is usually sent to the site admin. Using this method you can test if that email is really being sent.
How to send mail from localhost in WordPress: What we need
Before getting started we need a couple of things. Make sure you have the following things ready in order to send emails from WordPress localhost:
- A localhost WordPress site
- A Gmail account with 2 Factor Authentication
- A contact form on your frontend (optional)
In order to run your WordPress site on localhost, you can use applications like XAMPP. MAMP, Local, etc. Also, if you have a Gmail account, make sure that you’ve enabled the Two Factor Authentication feature. On May 30, 2022 Google stopped supporting 3rd part apps and devices that ask you to sign in to your Google account using only your username and password.
We will be using one of our Google accounts to send the email from our WordPress localhost. We will also show you how to enable your Google 2FA (Two Factor Authentication) in case you’re having difficulty. The plugin that we will be using has the feature to test if your email is working. But you can also use any WordPress form-building plugin (Contact Form 7, WPForms, etc.) to check whether the form is working or not.
How to send email from localhost in WordPress
Now we’re going to see how to send emails from WordPress localhost. So create your WordPress on localhost, and login to your WordPress dashboard. If you already have a localhost WordPress site, then that’s great. Follow the steps given belo:
Step 1: Install and activate Fluent SMTP
First, let’s log into our WordPress dashboard and install a plugin called Fluent SMTP. From your WordPress dashboard go to Plugins > Add New. Now on the search bar, search for Fluent SMTP.
Step 2: Configure Fluent SMTP
After you’ve activated the plugin, you can click on ‘Settings’ under the plugin’s name, or you can go to Settings > Fluent SMTP from your WordPress dashboard. Now you might see an option to import settings from WP Mail SMTP, but we’re going to click on the ‘Skip’ button. First, we’re going to choose a connection provider. We will select ‘Other SMTP’ from the given choices.
Next in the sender settings, provide the email address you want to send the email from. After that, you can give the name of the sender or whose email is from.
Next, you need to put in SMTP Host and SMTP port number. Since we’re planning to use Gmail, you can look at the Google support documentation to get that information. But for simplicity, we’re pasting in the details here:
- SMTP Host – smtp.gmail.com
- SMTP Port – 465
Put in these details and for Encryption, select SSL. There are two more options ‘Use Auto TLS’ and ‘Authentication’, which are enabled by default. You can leave these enabled.
👉 Learn More: How to Fix WordPress Not Sending Email Issue (Free Methods)
Step 3: Turning on Google Two-Factor Authentication
In order to get the key for the SMTP password, you need to first make sure your Google Two-Factor Authentication is switched on. If you already have the Google 2FA turned on, then skip this step and move on to Step 4.
However, if you’re not sure that your Google 2FA is turned on or off, or if you haven’t turned it on, then follow this step. First log into your Gmail account, then from the top right corner, click on your profile image, and then click on the “Manage your Google Account” button.
This will open up a new window. Now from the left side menu, select the ‘Security’ tab. From here, you can turn on your Google 2-Step Verification. Just click on that option and you can easily turn on your 2FA.
For the SMTP username, you can use the same Gmail address you provided in the Sender settings earlier. For the password, go to your manage Google Account section (Shown in step 3). From here, click on 2-Step Verification.
Next, scroll down and select ‘App Password’. It will take you to another screen, here, put in the following options:
Select App – Mail
Select Device – Windows or the device you’re working on (Select the device you’re working on in our case we selected Windows)
After that click on the Generate button to create the App Password.
Now your App Password is created, copy the password and go back to your WordPress dashboard.
Now paste this key into the SMTP Password field. After you’ve placed in your SMTP username and password, click on the ‘Save Connection Settings button. Then your settings will be validated and your Fluent SMTP configuration will be complete.
Step 5: Test email
After you complete your Fluent SMTP configuration, you can now test if your email on WordPress is working or not. Luckily Fluent SMTP has a feature that lets you perform this test. From your WordPress dashboard, go to Settings > Fluent SMTP, then select the Email Test tab.
Next, you can write where the email is from in the first box, and in the next one, you have to type the email address where you want to send the email to. After that, click on the “Send Test Email” button to start the test. If everything is ok, you should see the following message:
If the test result is unsuccessful, then you might have missed something. Go through the steps one more time and try to check if everything is ok.
We can also check if the email test was successful from the inbox of the email account to which we sent the test mail. We sent the email to another one of our Gmail accounts, so let’s check our inbox and see if we’ve received any email from our WordPress localhost.
It seems we’ve received the test email in our inbox as well. That means our localhost WP site can now send emails! If you have a contact form on your website, try sending a mail from that to check if it’s working. The same goes for the eCommerce site. If you have an eCommerce site, confirm a purchase order and see if the mail is being sent to the right destination. So that is How to Send Mail from Localhost in WordPress using XAMPP.
So before you move your site to a live server, make sure you update your Fluent SMTP configuration. You can also delete your configuration and add a new connection afterward.
In many WordPress websites, emails are sent even if the SMTP plugin isn’t installed. But in case you’re having difficulty, you can use Fluent SMTP to send emails smoothly.
👉 Learn More: XAMPP vs WAMP – What to Use for WordPress Local Installation?
👉 Video: How to Send Email from Localhost WordPress Sites
Conclusion
That brings our tutorial to an end. We used Fluent SMTP to send emails from our localhost WordPress site to another email address. You can also use other SMTP plugins if you want. When creating a WordPress site for your client or for yourself, it is important to check if the email functionality is working or not. Although many times the email works even if you don’t test it with any SMTP tools, it’s best to first test it.
So that is how to send mail from localhost in WordPress. If you have any questions regarding this post, feel free to ask us in the comments below. Check out our YouTube channel for more informative videos on WordPress.
Disclaimer: This post may contain affiliate links and we may receive a small commission if you purchase something by following them. However, we recommend services/products that we believe good to serve your purpose.
Great post! It’s a comprehensive guide on sending mail from localhost in WordPress. However, I would have loved to see a mention of the popular Postman SMTP plugin as an alternative solution. Thanks for sharing this valuable information!