Think I posted this in the wrong section, as i assume this is a quick fix - I am definately a newbie. Any help would be greatly appreciated!
What am I doing wrong with this contact form?
After pusing submit, the following error comes up: Warning: mail() [function.mail]: SMTP server response: 503 Bad sequence of commands in c:\domains\xxxxxxx.com\wwwroot\general_contact.php on line 46
Is this an error in my code or something I need to fix with my host?? Here's the code:
<?php
$to = $REQUEST['xxxxx@xxxxx.com'] ;
$from = $REQUEST['Email'] ;
$name = $_REQUEST['Name'] ;
$headers = "From: $from";
$subject = "Request form";
$fields = array();
$fields{"height"} = "Height";
$fields{"weight"} = "Weight";
$fields{"goal_weight"} = "Goal Weight";
$fields{"list"} = "Mailing List";
$fields{"sex"} = "Male or Female";
$fields{"currently_dieting"} = "Currently dieting:";
$fields{"current_diet"} = "If yes, what is your current diet";
$fields{"nutrition_coaching"} = "Requested Nutrition Coaching";
$fields{"services"} = "Requested Services";
$fields{"medical_conditions"} = "Current Conditions, Illnesses";
$fields{"diet_history"} = "Diet history";
$fields{"Name"} = "Full name";
$fields{"location"} = "Location";
$fields{"Phone"} = "Phone";
$fields{"Email"} = "Email";
$fields{"notes"} = "Comments";
$body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }
$headers2 = "From: xxxx@xxxxxxx.com";
$subject2 = "Thank you for contacting us";
$autoreply = "Thank you for contacting us.
We will get back to you as soon as possible";
if($from == '') {print "You have not entered an email, please go back and try again";}
else {
$send = mail($to, $subject, $body, $headers);
$send2 = mail($from, $subject2, $autoreply, $headers2);
if($send)
{header( "Location: http://www.xxxxxxxxx.com/thankyou.html" );}
else
{print "We encountered an error sending your mail, please notify webmaster@xxxxxxxx.com"; }
}
?>