XAMPP configuration for sending mail using PHP

In web applications, sending emails for notifications, OTPs, password resets, or alerts is essential. Proper XAMPP Configuration for Sending Mail ensures that your local development environment can send emails using PHP without errors.

Sometimes, configuring mail can be challenging for beginners, but in this blog, we will guide you step by step to 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 :

C:\xampp\php\

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.

smtp_server=smtp.gmail.com
smtp_port=465
smtp_ssl=auto
error_logfile=error.log
auth_username=YOUR_EMAIL
auth_password=YOUR_PASSWORD

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.

Conclusion

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.

For integrating email functionality in Laravel using Gmail, Send Emails in Laravel Using Google Mail explains step-by-step how to set up Google Mail to send emails directly from your application.