views:

30

answers:

1

I am trying to use a php contact form on widows asp.net hosting package, php is enabled but still my form is not sending email it is directing to error.html page......

here is the code

<?php

$EmailFrom = "anksaltlamps.com";
$EmailTo = "[email protected]";
$Subject = "Website Query";
$Name = "Not Specified";
$Tel= "Not Specified";
$City= "Not Specified";
$Country= "Not Specified";
$Other= "Not Specified";
$Address= "Not Specified";
$Message= "Not Specified";
$State= "Not Specified";


$Name = Trim(stripslashes($_POST['Name'])); 
$Tel = Trim(stripslashes($_POST['Tel'])); 
$Email = Trim(stripslashes($_POST['Email'])); 
$City = Trim(stripslashes($_POST['City']));
$State = Trim(stripslashes($_POST['State']));
$Country = Trim(stripslashes($_POST['Country']));
$Other = Trim(stripslashes($_POST['Other']));
$Address = Trim(stripslashes($_POST['Address'])); 
$Message = Trim(stripslashes($_POST['Message'])); 

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";

$Body .= "Tel: ";
$Body .= $Tel;
$Body .= "\n";

$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";

$Body .= "Address: ";
$Body .= $Address;
$Body .= "\n";

$Body .= "City: ";
$Body .= $City;
$Body .= "\n";

$Body .= "State/Province: ";
$Body .= $State;
$Body .= "\n";

$Body .= "Country: ";
$Body .= $Country;
$Body .= "\n";

$Body .= "Other Country: ";
$Body .= $Other;
$Body .= "\n";

$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";

ini_set('sendmail_from', '[email protected]');
// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=thanks.html\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
}
?>

or you check it online by this link

link text

A: 

Read this. This is probably due to your mail settings in php.ini.

youssef azari
How can i get to php.ini file on my hosting area.....
Muhammad Ahsan
if your using Wamp then look in 'C:\wamp' otherwise do a disk search for 'php.ini'.if you're in a shared hosting, then contact your hosting providers but it doesn't make sense because most hosts have already mail() enabled.
youssef azari
the hosting provider says that they are using NET_smtp ..i dont know how i should cater this....cgi bin is not enabled on the server but php latest version is enabled....On my one other hosting company, there is no problem in working with this form on windows environment
Muhammad Ahsan
I think you should speak again to your hosting company, tell them you want to use php's native mail().. with no external libraries.
youssef azari