Test send PHP emails locally (xampp) Windows
If 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 server
Test 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.ini
Open your PHP.ini file, scroll down to [mail function] and make changes as shown in picture below.Step 3. Mail Header
When you write PHP mail script, include mail header with "From: [email protected]", otherwise, you might end up with bizarre error like so:- 1
Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing in ___ on line 123
PHP
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
[email protected]' . "\r\n"
.'Reply-To: [email protected]';
// send email
mail("[email protected]", "My subject", $body, $headers);
?>
<?php
$body = "This is the \nbody of my email.";
$headers = 'From: