You can test PHP email functionality from your local machine before deploying to a staging or production server. In XAMPP, configure PHP’s mail settings and the bundled Sendmail utility with the SMTP server details provided by your email provider.
1. Configure php.ini
Open C:\xampp\php\php.ini and find the [mail function] section. Set the SMTP server, port, sender address, and Sendmail command. Replace the example address with an account you are authorized to send from:
SMTP=smtp.gmail.com
smtp_port=25
sendmail_from=abc@gmail.com
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"
2. Configure sendmail.ini
Open C:\xampp\sendmail\sendmail.ini and set the SMTP server and account details. These values are examples; use the hostname, port, and authentication method required by your provider:
smtp_server=smtp.gmail.com
smtp_port=25
auth_username=abc@gmail.com
auth_password=YOUR_SMTP_CREDENTIAL
force_sender=abc@gmail.com
Keep credentials private. Do not use a real mailbox password in a project or share it in source control. Use provider-approved SMTP credentials and follow its current authentication requirements.
3. Restart Apache and test
Save both files, restart Apache from the XAMPP Control Panel so the changes take effect, then test your PHP mail() call. If your SMTP provider does not accept port 25, check its documentation for the correct submission port and encryption settings; port 587 is commonly used with STARTTLS.
Note: These settings reflect a local XAMPP setup from 2018 (XAMPP 1.8.2 and PHP 5.4.16). Email providers change their security requirements. Gmail’s former “less secure apps” option has been retired, so the old basic-password setup may no longer work; use a currently supported authentication method or a development mail-testing service instead.