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.
; http://php.net/smtp
; SMTP = localhost
SMTP = smtp.gmail.com
; http://php.net/smtp-port
; smtp_port = 25
smtp_port = 465

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = me@example.com
sendmail_from = blogshub4@gmail.com

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;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.

Change

; smtp_server=mail.mydomain.com to smtp_server=smtp.gmail.com

; smtp_port=25 TO  smtp_port=465

And set username and password

auth_username=usergmail@gmail.com
auth_password=yourpassword

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 *