<?php


//email(to,subject,message,headers,parameters)

$to="swissknife@gmail.com>";
$subject="Hi";
$message="Hello my friend";
$from="swissknife007@gmail.com";
$headers="from:".$from;
mail($to,$subject,$message,$headers);
echo" mail sent";

?>

This is a very simple php script to send an email.
However ,it is not working for me and I am getting the error.

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in F:\xampp\htdocs\email1.php on line 10

mail sent

I am using XAMPP for php.
What values should I set the in php.ini ?
Please explain in detail

Recommended Answers

All 2 Replies

You cannot send email with XAMPP using mail(), unless you have a mail server installed. Please search this forum for solutions using PHPMailer.

Yes first you have to install a SMTP server.There are several free SMTP servers.Do a google search on SMTP servers and you can find further details about this by searching Daniweb previous threads about this.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.