Test send PHP emails locally (xampp) WindowsIf you are required to test the functionality of PHP mail in your projects, which is without having to use external mail server, you can try these steps which will allow you to send and open emails locally.I assume you are running XAMPP server on your computer, it should work fine with WampServer too without any configuration.
Step 1 : Download email serverTest mail server is tiny mail server program for windows, which you can install on your computer and start running instantly. You can download the program here.
Step 2 : Make changes in PHP.iniOpen your PHP.ini file, scroll down to [mail function] and make changes as shown in picture below.
Step 3. Mail HeaderWhen you write PHP mail script, include mail header with "From: [email protected]", otherwise, you might end up with bizarre error like so:
Here's what my testing PHP email look like :
Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing in ___ on line 123
<?php $body = "This is the \nbody of my email."; $headers = 'From: [email protected]' . "\r\n" .'Reply-To: [email protected]'; // send email mail("[email protected]", "My subject", $body, $headers); ?>