I don’t know what’s your level of frustration when you have to test emails from local hosts, but there is no suitable way to test it on the local sites, and you don’t want to check it on the live sites due to a lot of unknown facts, my level of frustration always remains high. I tried several methods, but none of them are satisfactory. After investing a vast amount of time, I finally figure out something handy and easy peasy solution to test the email setup on local hosts. In this article, I will share my learnings with you.
To manage the work, you need only three things.
- WordPress on your Local Host
- SMTP plugin
- An account on Mailtrap
What is Mailtrap?
Mailtrap is a fake SMTP server tool that allows you to test your local hosts’ emails decently. It grabs emails from the Local Host, Stage, QA, etc., and help you to test, preview, and debug your HTML emails.
In my words, Mailtrap will give an email box with a dedicated email id with extensive functionality to test emails from local hosts or staging sites.
The best part is, they have a free version to test up to 50 emails in your dedicated email box. Even when your email box will be full, you can remove emails and test new emails too.
Creating an Account on Mailtrap
Creating an account on Mailtrap is so easy. You can signup with your Google account/Github account, or create a new account through your email address, a new account.
Here is a video demonstration👇
Setting Up the SMTP with WordPress Plugin And Connet with Mailtrap
I don’t take your time to go with the basics of the SMTP plugin. You can find the details of those plugins on their websites. Among all of the SMTP plugins, there are a few are supported by Mailtrap. Here are those,
Setting up Mailtrap with WP Mail SMTP by WPForms to Test Local Hosts Emails
WP Mail SMTP is a free plugin to set up the mail SMTP in the WordPress system. The setup process is so easy. Follow the below steps,
Search on WordPress Repository, Install and activate it.
Or you can download the zipped file and extract it on your WP Content Folder to save your time 😉
Now navigate to settings option of the WP SMTP.
If you find the From email field filled with your admin email, please remove it and keep it blank. The WP SMTP plugin will set the default email address for you, which will help you to send emails to your Mailtrap mailbox. In my case, it causes difficulties in testing emails.
Now select the Other SMTP option and set the below-mentioned options and login to your Mailtrap account & open your demo email box to get the necessary Infos.
Steps to follow 👇
Note that in this case, your password will be stored in the website database in plain text. This why for extra security it is recommended to set up the password in your
wp-config.php file by adding these two lines of code:
All setup is done. It’s time for testing. To test your whole work navigate to Email Test tab of the WP SMTP Plugin.
Now copy email address from Email Address Tab of the Demo Inbox of your Mailtrap
Paste the email address to Send To email field and click send button.
Hola your test email is in your mail box…
Mailtrap collects all emails from your localhost and will display in your Miltrap’s Inbox. So you can use any kind of email address to test.
How to Configure Mail SMTP Without Any Plugins
If you are a tech nerd and don’t want to bloat your database with unnecessary plugins, then here is a code snippet. Jump into your
functions.php file and configure the WordPress SMTP settings with the following code:
The interesting fact is, Mailtrap Already create a readymade snippet for you. Go to the Demo inbox of your Mailtrap Account and from the integration Dropdown menu select WordPress and copy code and finally paste it on
functions.php file and save it.
Special Care for Lazy Bees like me 😉
If you don’t want to do all that to test an email body, it is only interesting to know the system status, is it functional or not. Then, you can check this free tool. This plugin will help you to track the state of the emails. It will help you to understand, does the email shoot from your environment or not.
Video Tutorial on How to Test Emails from Localhosts
If you are interested in watching the tutorial video of the whole process, then jump into it.
I I have tried to cover all the areas to make a foolproof guideline on how to test your emails in your localhost setup. If you find any other suitable and easy solution, please let me know in the comment section. I’ll add it to the next update of my content.