To configure XAMPP server to send mail from localhost we have to make changes to two files sendmail.ini and php.ini. Open the xampp folder. By the name of “sendmail.ini” is present in sendmail file and “php.ini” is present in php file in the xampp folder.
- Go to C:\xampp\sendmail: open sendmail.ini file in notepad or any text editor and make the changes as follows.
change smtp_server=mail.yourdomain.com to smtp_server=smtp.gmail.com change smtp_port to smtp_port=587 change smtp_ssl=auto to smtp_ssl=tls
uncomment ;error_logfile=error.log to error_logfile=error.log uncomment ;debug_logfile=debug.log to debug_logfile=debug.log write your gmail id in auth_username: email@example.com write your gmail assword in auth_password: auth_password=*****
write your gmail id in force_sender: *****@gmail.com change hostname to hostname=localhost
- Go to C:\xampp\php: open php.ini file in notepad or any text editor goto [mail function] part and make the changes as follows.
comment SMTP=localhost by putting semicolon infront=>;SMTP=localhost comment smtp_port=25 by putting semicolon infront=>;smtp_port=25 comment sendmail_from= by putting semicolon infront=>;sendmail_from=specify path of file in sendmail_path to sendmail_path=C:\xampp\sendmail\sendmail.exe check if extension=php_openssl.dll is enabled=>If there is semicolon in front then un-comment it by removing that semicolon
After following the given steps if the mail is not sent by calling the mail function, then goto C:\xampp\sendmail open error.log to see thee error occurred.
Note: Here the procedure is shown for gmail, but it can be extended to other mails by changing the smtp server, port number. When using gmail take care to enable the option to allow access to less secure webapp.
- PHP program to fetch data from localhost server database using XAMPP
- Creating custom domain name instead of localhost in Ubuntu
- How to allow access outside localhost in AngularJS ?
- How to install XAMPP on Windows ?
- PHP | Sending mails using mail() function
- How to configure modal width in Bootstrap?
- How to configure node.js console font ?
- How to Install and Configure MongoDB in Ubuntu?
- How to Configure Socket.IO with Demo-Chat App in Node.js ?
- How to send button value to PHP backend via POST using ajax ?
- PHP | Send Attachment With Email
- PHP | Spreadsheet_Excel_Writer | send() Function
- How to send HTTP response code in PHP?
- How to send a GET request from PHP?
- Sending Emails Using API in Flask-Mail
- How to send an email using PHPMailer ?
- How to send email with Nodemailer using Gmail account in Node.js ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.