How to send email from xampp localhost

Open php.ini file and find mail configuration by searching in it “[mail function]” then made the following configurations.

[mail function]
; For Win32 only.
; SMTP = localhost
; smtp_port = 25
smtp_port = 465

; For Win32 only.
;sendmail_from =
sendmail_from =

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =
sendmail_path = "E:\xampp\sendmail\sendmail.exe -t"

Now, setup the sendmail configuration in XAMPP . Open the sendmail.ini file . Then, made the following configurations.


; to

; smtp_port=25 TO  smtp_port=465

And set username and password

Allowing Less Secure App

Now, allow your gmail to less secure apps so you can send mail to local machine.

Restart your machine

Now you can use PHP email function for sending email locally.

Keep Learning 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *