Enable Emails on Localhost installation of WordPress using XAMPP

Recently I have been developing a multisite network on a localhost installation. I am currently in the beginning stages of a site build, and currently building up the dashboard and including some functionality. One feature of the site is to allow users to create and maintain there own personal blogs. I needed to test out the creation of accounts and other sites on the network. I wanted to receive emails every time this happened, to replicate a real world production environment the best I could. I also wanted to be able to reset passwords without having to log-in to phpmyadmin every time.

I did a whole lot of research into the topic, and came across many articles all claiming that the process was extremely easy to set up. It took me two days to resolve the issue, not to mention a whole lot of reading and de-bugging. I was finally able to resolve the issue to enable emails sent from localhost. That includes emails from gravity forms, emails for password resets and update notifications.

To start make sure that you have XAMPP installed and an installation of WordPress running. If your not sure how to set up XAMPP , check back at one of my previous articles and follow the steps provided (Using XAMPP for local development).

We will be editing two separate files within the XAMPP directory to enable email being sent from localhost. The two files we will need to edit are PHP.ini and Sendmail.ini.

PHP.ini

After you have XAMPP installed, go to the root directory for the installation. If you installed it on your C:\ drive than it would be C:\XAMPP. I have mine installed to a flash drive, so mine sits on S:\Server Files\XAMPP. Once in the XAMPP root direct yourself to the PHP folder (\XAMPP\PHP). From here you can open up the PHP.ini file in your favorite text editor (I use notepad++).

Once you have the PHP.ini file opened, scroll down to line 1146 and comment out the entire line (you can comment out the line by placing a semi-colon (;) at the beginning of the line). After you have commented out line 1146, scroll up to line 1143, and un-comment that line (remove the semi-colon).

For reference this is how your PHP.ini file, line 1140-1154 should appear:

Now what we did above was tell XAMPP where the sendmail.exe file is located.

And that’s it for your PHP.ini file!

Sendmail.ini

Now lets move on to your sendmail.ini file (which is much shorter). Your Sendmail.ini file can be found inside of the sendmail directory in the XAMPP root (\XAMPP\Sendmail\Sendmail.ini). Again open the file inside of your favorite text editor.

  • *Tip*: I would recommend making a backup of the file inside of the same folder and just appending a ‘2’ to the end of the file name, just in case something goes wrong down the road.

Now you can copy the provided code below and replace the contents of Sendmail.ini file with it.

Don’t forget to swap out your credentials!
gmail-account@nullgmail.com : Your Gmail username
gmail-password : Your Gmail password

That’s it, your XAMPP is all set up to start sending emails!

Restart

Now just restart your Apache and MySQL modules in XAMPP, and go ahead and test out the newly enabled email functionality. It’s actually quite simple to set this up, but requires a little bit of knowledge of the XAMPP file structure and SMTP settings.

Hopefully someone finds this useful and I save someone a headache or some development time as I struggled for a few days with this issue. Thanks for reading!

Did this help you, or are you still having issues? Let me know in the comments and I’ll do my best to help!

About the Author

Evan Herman

Evan is a full time WordPress developer at Yikes Inc. where he makes all sorts of cool things with WordPress. When he's not there you can find him developing awesome plugins, blogging about WordPress or hanging out with his three cats and amazing girlfriend in Philadelphia, PA.