maxelcat
Technical User
- Oct 19, 2006
- 79
Dear All
I have a script that I have used on several websites that processes a simple form and then sends an email. It works fine.
However, on my latest site I get this error
PHP Warning: 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 C:\webspace\reseller\web27000\lvhs.org.uk\ on line 91
Conversations with the provider assure me that I need to put a line(s) of code to "pass the form to a mail relay" and the have given me this inbound1.equinoxit.net
trouble is, even after some googling I don't know how to do this!
Can anybody help please
Thanks in advance
Edward
Here's the code
"I love deadlines - I love the noise they make as they go wishing past" (not mine of course, but very ture...0
I have a script that I have used on several websites that processes a simple form and then sends an email. It works fine.
However, on my latest site I get this error
PHP Warning: 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 C:\webspace\reseller\web27000\lvhs.org.uk\ on line 91
Conversations with the provider assure me that I need to put a line(s) of code to "pass the form to a mail relay" and the have given me this inbound1.equinoxit.net
trouble is, even after some googling I don't know how to do this!
Can anybody help please
Thanks in advance
Edward
Here's the code
Code:
<?php
if (isset($_POST['submitted'])) { // if we get in this first part of the if clause the form has been submitted. next job then is to check the fields.
$errors = array();// declare the array that will hold all the error messages
//check first_name
if (empty($_POST['first_name'])) {
$errors[]= 'you forgot to enter your first name<br />';
} else {
$first_name = stripslashes(trim($_POST['first_name']));
}
//check lastname
if (empty($_POST['last_name'])) {
$errors[]= 'you forgot to enter your last name<br />';
} else {
$last_name = stripslashes(trim($_POST['last_name']));
}
//check for phone_number
if (empty($_POST['phone_number'])) {
$phone = 'No number given';
}else{
$phone = trim($_POST['phone_number']);
}
//check email_1 is not empty
if (empty($_POST['email_one'])) {
$errors[] = 'you forgot to enter an email address.<br />';
} else { //check the two emails agree
if ($_POST['email_one'] != $_POST['email_two']) {
$errors[] = 'your email and confirmation email address do not match.<br />';
} else {
$email_one = trim($_POST['email_one']);
}
}
//check the enquiry field has something in it!
if (empty($_POST['comment'])) {
$errors[] = 'you forgot to write a comment!';
} else {
$comment = stripslashes(trim($_POST['comment']));
}
//use $errors array. If its empty we can create and send the email message. If its not
//empty then something must be wrong so print out the error messages
if (empty($errors)) {
//echo "<tr><td colspan=\"3\">";
//create the message:
$message = 'email message from '.$first_name.' '.$last_name."\n";
$message .='contact phone (if left) '.$phone."\n";
$message .='email address = '.$email_one."\n\n\n";
$message .='Enquiry = '.$comment;"\n";
$to = "edward@eldon.gotadsl.co.uk";
$subject = "Enquiry from lea Valley High School Website";
$headers = "From: ".$email_one;
//$headers .= "Reply-to: ".$email_one;
//send email
mail ($to, $subject, $message, $headers);
echo "<h3>Success!</h3><p>Your comment has been sent to Lea Valley High School.</p>\n";
echo "</td></tr>";
include ('lvhs_form_footer.html');
exit(); //everythings all ok, so just finsih here
} else {
//echo "<tr><td colspan=\"3\">";
echo "<h3>You haven't quite done the form correctly...</h3><p />\n";
foreach ($errors as $msg) {
echo "<p class=\"form_error_message\">$msg</p>\n";
}
//echo "</td></tr>";
echo "<hr />";
} //end of checking the errors array if conditional
}//end of main submit conditional
?>
"I love deadlines - I love the noise they make as they go wishing past" (not mine of course, but very ture...0