Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

form and mail relay

Status
Not open for further replies.

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
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
 
You'll need to set the SMTP server to use for the mail function. is what they are telling you.

From what i'm seeing this is a Windows Machine, and as such does not a have default mail server installed like a Unix machine would, for the mail() function to use in localhost.

You'll have to use ini_set to set the SMTP server to the string they gave you.


Code:
ini_set("SMTP","inbound1.equinoxit.net");

the PHP onlne is your friend fir this type of thing.
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Thanks for that - added the line as you suggested and got htis...

PHP Warning: mail(): SMTP server response: 550 Relaying not permitted (3.7): edward@eldon.gotadsl.co.uk in C:\webspace\reseller\web27000\lvhs.org.uk\ on line 94

... does htis mean that when they say I need to relay they are wrong?

Thanks again

Edward

"I love deadlines - I love the noise they make as they go wishing past" (not mine of course, but very ture...0
 
It means the smtp server they provided does not allow relaying.

Did they give you a value for the sendmail_from directive.

I can't understand why they would tell you to relay and then give you an address of an smtp server that wont allow relaying.
I'm puzzled...


----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Thaks - you confiremed what I thought - I don't know a huge amount, but I am not convinced they do either!


I will call them and let you know!


"I love deadlines - I love the noise they make as they go wishing past" (not mine of course, but very ture...0
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top