How to send and test WordPress emails on localhost?
One of the initial things you can learn about WordPress and its usage is its installation on localhost. Working with WordPress and its plugins, extensions, themes and templates can be convenient if you have WordPress installed on your own computer.
It is otherwise called the setting up of localhost or local server environment for development, testing and checking purposes.
Once, you have your WordPress installed on your personal PC or Computer, you might want to try a variety of options and controls it offers you.
One of the primary features you can familiarize with is the procedure of sending and testing emails in a localhost.
You can use email sending functionality for a range of reasons, starting from emails as a notification for a new user registration, reset of a password, automatic updates to sending out emails when something happens on your website, for example, a new post is published.
While the functionality of WordPress to send emails is of primary importance for your website, in this article let’s go through the stages of how a WordPress site owner can send and test emails in a localhost.
For certain reasons, using the default method of sending WordPress emails can be a daunting task with lots of errors. Basically, PHP mail function is responsible for sending emails generates from your WP website. However, your WP hosting server is not properly configured to exercise this functionality. Another basic reason is that the major WP hosting companies use different methods to restrict email spam.
Under such conditions, one of the productive ways to send and test emails in localhost is via SMTP method.
Getting SMTP functionality and setting it up in your WordPress can be somehow laborious, but it’s worth it. Once you have the job done, you are to enjoy boundless of its advantages. It will bring you more stabilized and dependable framework to work on and send your emails freely.
Let’s start with the necessity of finding and installing the relevant plugin. You can use the plugin called WP Mail SMTP /https://wordpress.org/plugins/wp-mail-smtp/ (Alternative way is via the plugin named Easy WP SMTP /https://wordpress.org/plugins/easy-wp-smtp/).
It will let you configure wp_mail() function to use SMTP instead and send and test emails in localhost with the help of SMTP server.
After the installation and activation of the plugin, you need to go to its setting page to get started. Select Settings, then Email for certain configuration options.
At this point, you will be provided with Advanced Email Options. Let’s take a quick look at each of them and find out what they configure.
From Email: Specify the email to send your emails from
From Name : Specify the name you would like your emails to be sent from
Mailer : Choose to Send all WordPress emails via SMTP
Return Path : Choose to set the return-path to match the From Email or not
SMTP Host : The hostname of you SMTP Server
SMTP Port : The port on which your server works
Encryption: Choose between no encryption, use SLL encryption and Use TLS encryption
Username and Password: The Username and Password of your SMTP server respectively.
When you are done with those options, click Save and the basic configuration is done! However, there is an additional small task to complete to finalize the process. You need to go to your Gmail account settings and enable Access for less secure Apps.
Actually, this method will smoothly work with the majority of email providers. In case you are using your host to create emails, SMTP integration with WordPress will also work stunningly. In this case you need to go to cPanel, find Email section and configure SMTP settings from there. You don’t need to worry about unexpected issues, since you are well aware of what you are giving access to.
Once the above specified steps are taken and the required configuration is completed, it’s time to send and test emails when you are on localhost. For this we have Testing and Debugging Settings section to use. Fill the required information, like the email address of the recipient, subject of email (like test, for testing or whatever you wish), as well as the text of message (again optional). Click Send Test Email and check the results.
You can use your own email to quickly check whether everything is working properly. Enter your email in the recipient section and check whether you receive the relevant mail.
Another option is to leave a post comment and check whether you receive email notification. Naturally, this method works if you have activated Email Me Whenever Anyone Posts a Comment setting.
The next well developed and easy to digest plugin ready to enable you to send and test emails in localhost is called Postman SMTP Mailer-Email Log. (You can find it in WordPress repository of plugins: https://wordpress.org/plugins/postman-smtp/). It is an improved and updated version of other SMTP methods which is in full compliance with modern security standards.
All in all, it comes with easy installation and setup processes for the WordPress user of any background. The installation and activation processes are as usual, including finding the relevant plugin via the Plugins menu. Then you need to select “Start the Wizard” and you’ll find the needed instructions to eliminate possible errors in configuration.
With this plugin you may also manually configure password authentication and oauth 2.0 authentication. However, these will need a higher level of coding knowledge and will be convenient for advanced WP users.
As for the other pluses of Postman SMTP Mailer-Email Log, it grants you with connectivity test to reveal any setup errors catering to server, International Alphabets, HTML Mail and Multipart support, as well as SMTPS and STARTTLS security Support.
As for other compatible and highly reliable plugins to send and test emails in a localhost, you can find SMTP Mailer Plugin by Mail Bank among them (https://wordpress.org/plugins/wp-mail-bank/). This one is also preferable for its easy installation process and further configuration options providing you with a simple way of sending your emails while using PHP mailer or SMTP server.
Well there are many developers and i think almost all of them who like to work on local server in their machine and then take their work online.
Similarly WordPress developers also like to keep their work local on localhost. The only problem working on localhost is that contact forms or anything related to emails can’t be tested and hence only for this part placing the entire code online seems a bit of trouble.
Comes to the rescue: WP Mail SMTP
Download this plugin into your localhost and activate the plugin.
Inside Settings>Email you can configure the plugin.
Place From Email (can be your gmail,hotmail or any email address you want to use), From Name.
In mailer section select Send all WordPress emails via SMTP.
Return Path you can check.
For SMTP settings of gmail, yahoomail, outlook and hotmail refer to the below links and i am sure you will be able to set up using those settings.
Once settings have been saved, kindly click on test message and check if test message is working.
NOTE: It is really important to have an active internet connection to check SMTP Mails. However advantage is you can check emails using localhost now and do not need to place the site LIVE for checking emails.