How to Make PHP mail() Function Work in Localhost Server
There are several ways that could make PHP mail() function work in localhost. I haven’t tried them except for the solution below:
- Download sendmail and extract it on your desired location.
- Open sendmail.ini and enter the credentials needed:
- Open php.ini and uncomment sendmail path and enter the path
sendmail_path = “\”C:\sendmail\sendmail.exe\” -t”
Use the ff. codes to test if it’s working:
Note: $headers is essential for the function to work.