I have created a new page contact us i'm getting trouble with this error encounters.
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 contact_me.php on line 41
My PHP file is
<?php
// check if fields passed are empty
if(empty($_POST['fname']) ||
empty($_POST['lname']) ||
empty($_POST['phone']) ||
empty($_POST['email']) ||
empty($_POST['dateTime']) ||
empty($_POST['heading']) ||
empty($_POST['companyName']) ||
empty($_POST['address']) ||
empty($_POST['postalCode']) ||
empty($_POST['city']) ||
empty($_POST['country']) ||
empty($_POST['message']) ||
!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
{
echo "No arguments Provided!";
return false;
}
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$phone = $_POST['phone'];
$dateTime = $_POST['dateTime'];
$heading = $_POST['heading'];
$companyName = $_POST['companyName'];
$address = $_POST['address'];
$postalCode = $_POST['postalCode'];
$city = $_POST['city'];
$country = $_POST['country'];
$message = $_POST['message'];
$email_address = $_POST['email'];
// create email body and send it
$to = 'ram@gmail.com'; // PUT YOUR EMAIL ADDRESS HERE
$email_subject = "Modern Business Contact Form: $fname"; // EDIT THE EMAIL SUBJECT LINE HERE
$email_body = "You have received a new message from your website's contact form.\n\n"."Here are the details:\n\nFirst Name: $fname\n\nLast Name: $lname\n\nPhone: $phone\n\nContact Date Time:\n$dateTime\n\nHeading: $heading\n\nCompany Name: $companyName\n\nAddress: $address\n\nPostal Code: $postalCode\n\nCity: $city\n\nCountry: $country\n\nMessage: $message\n\nEmail ID: $email_address";
$headers = "From: rohitnewicvs@gmail.com\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
return true;
?>
Please let me know what is problem.