Xampp has sendmail included in its package. You can download the whole XAMPP package from this link. After You have installed the XAMPP into your windows. Sendmail itself cannot send emails. It needs some mail servers like gmail. Follow following steps :
Go to the XAMPP folder (wherever you have installed it). In my case, it is “C:/Xampp”. Inside that folder there must be a folder called “sendmail” if you have selected it to be installed while installing xampp. Go inside that folder and open the file “sendmail.ini” in a text editor.
Find the phrase “smtp_server” on the file. It must be around the line number 14. Set its value to “smtp.gmail.com” without quotes.
Find the phrase “smtp_port”. It must be right below “smtp_server” (if you discount all the comments). Set its value to “465” without quotes. For gmail, the port number is 465.
Find “default_domain” and set its value to “localhost” without quotes.
Find “auth_username” and set its value to you gmail address. Find “auth_password” and set its value to your gmail password.
Find “hostname” and set its value to “localhost” without quotes.
Now there’s an additional step
You have do a very slight modification in another file.
Go back to root xampp folder. Go to folder “php”. Open “php.ini” file on a text editor.
Find the phrase “sendmail_path”. It should be around line number 1137 under “mail function” section.
There, you will see a line that says sendmail_path=”C:\xampp\mailtodisk\mailtodisk.exe”. You have to comment that line. Just put “;” at the beginning of the line.
Just above/below that line, you will see another line that says sendmail_path = “\”C:\xampp\sendmail\sendmail.exe\” -t”. You will have to make that line active. You can do it by removing “;” from the beginning of that line.
Remember the path I have on my php.ini file and your might be different depending on the location where you installed you xampp. I trust you can handle that.
It should look like this
Now you can just use the native php mail function to send the mail
mail($to, $subject, $body, $headers);
$to is the email address you want to send the email to
$subject is the subject of the email
$body is the actual message
$header is the email header like “from : …….”, etc.
$headers = “MIME-Version: 1.0\r\n”;
$headers .= ‘From: email@example.com’.”\r\n” . ‘X-Mailer: PHP/’ . phpversion();
if(mail(‘firstname.lastname@example.org’, ‘Demo’, ‘hey this is demo email message’, $headers))
echo ‘Email sent’;
echo ‘Email not sent’;