Why is my email form not working (php)?

Jim

New member
Here is the error message I get:

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 E:\Users\DartStudents\kleinj2\jfk430\catering.php on line 10
We encountered an error sending your mail

Here is my html form file:

<form method="post" action="catering.php">
Email: <input name="email" type="text"><br>
Message:<br>
<textarea name="message" rows="15" cols="40"></textarea><br>
<input type="submit">
</form>

Here is my php file:

<?php
$to = "[email protected]";
$subject = "Contact Us";
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
$headers = "From: $email";
$sent = mail($to, $subject, $message, $headers) ;
if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail"; }
?>

What's wrong?
I'm not sure where I add this "# telnet locahost 25"
I am new to php.

All of the websites I look at give basically the same code, tell you to copy and paste it, change a few things and then post it to your server and try it out. I am posting it to an ftp server that runs cold fusion just fine? Don't understand what is wrong.
 
Your script is trying to connect to a mail server on your local computer (localhost) on the SMTP port 25. You probably don't have one running.

Try this:
# telnet locahost 25

You should see something like:
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

If you don't you need a mailserver somewhere where you can deliver this email.
 
Your script is trying to connect to a mail server on your local computer (localhost) on the SMTP port 25. You probably don't have one running.

Try this:
# telnet locahost 25

You should see something like:
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

If you don't you need a mailserver somewhere where you can deliver this email.
 
Back
Top