Send an email by using gmail from localhost XAMP

Send an email by using gmail from localhost XAMP

While working on a project, I was worried about how can I check a module where I have to send regular email to my site user and visitor. Luckily, I got the solution and now I am able to send the email from my localhost XAMP. I sharing this trick with all you. Hopefully, It will be useful for all PHP developers and testers. In this example, we will learn to configure our gmail id in order to send the email.
To do this task we have to modify two files in our localhost XAMP
1.    php.ini
2.    sendmail.ini

Step 1 :

Now first open your php.ini file. For me, the location of php.ini is C:\xampp\php\php.ini
And now search the term i.e extension=php_openssl.dll,
and for enabling this job we have to remove the semicolon(;) from the beginning of this line.
Now search another term in php.ini and i.e [mail function]
and change or enter the following values:
sendmail_from =
sendmail_path = “\”C:\xampp\sendmail\sendmail.exe\” -t”

And by this step, we have done with making the changes in php.ini file.

Step 2 :

Now open your sendmail.ini file and for me, the location is C:\xampp\sendmail\sendmail.ini.
Search for the same term i.e [sendmail]
and replace all code with the following code

Congratulations, You have done. Now save these two files and restart your localhost XAMP server. And test this functionality with the following PHP code.


For gmail please check to allow access from less secure apps.