XAMPP configuration for sending mail using PHP

Nowadays, mail communication is common over mail in web applications. Those emails can be any type like notifications, OTP emails, password reset links, or just alert emails.

Sometimes, mail configuration can be harder than sending mail as a beginner. In this blog, we will set up mail and enable XAMPP to send mail using the PHP mail function.

In this configuration, we will allow the built-in XAMPP sendmail.exe binary to deliver emails using the given credentials. We will achieve this objective in two steps. First, set up send mail in PHP configuration and provide credentials to the sendmail application.

Setting php.ini For Sendmail

First of all, we will set up PHP to use Sendmail to handle mail functionality. Go to XAMPP’s php directory and open php.ini (configuration file) for php. If you have the default installation of XAMPP then the location of the php.ini file is below :


If you have customized or changed the default location of XAMPP then open that directory and edit the php.ini file.

Now, Open php.ini file into edit mode and search for sendmail_path. Replace or remove a comment on that line and provide a Sendmail location like the below example.

sendmail_path = \"C:\xampp\sendmail\sendmail.exe\" -t"

It will set up a sendmail application to our PHP. This location can be different as per your installation so please check and update it.

Edit the sendmail.ini file

In this step, we will set up our email configuration in our Sendmail application. Before performing this step please confirm mail configuration values like server address, port, username, and password for your email.

Go to your XAMPP directory again and find the Sendmail directory. Open the sendmail.ini file inside and find the sendmail portion.


Those values can be different if you are using another email service like Yahoo, Hotmail, or any other.

Now our setup is complete. we just need to restart the Apache server. After that, we can use the mail() function in our PHP web application.


In this tutorial, we have configured XAMPP to send mail using the Sendmail application in two simple steps. Feel free to place a comment if you have any queries or suggestions.