what's wrong with my code?

<?php
error_reporting(0);
// ' Send me an email' script



if($_POST['submit'])

{
//get data from form
$name = $_POST['name'];
$message = $_POST['message'];

if($name&&$message)
{  // existance check
$namelen = 20;
$messagelen = 300;
if(strlen($name)<=$namelen&&strlen($message)<=$messagelen) // length check
{
// everything is ok!

//set SMTP in php.ini

ini_set("SMTP","localhost");
ini_set("smtp_port","465");
//set up the variables
$to = "gerbiepejo@yahoo.com\r\n";
$subject = "Email from Clarissa Jade Village Resort";
$header = "From:Jorus182@yahoo.com\r\n";


$body = "This is an email from $name\r\n$message";
mail($to, $subject, $body, $header);

die();
}

else
    die("Max length for name is $namelen, and max length for message is $messagelen!");
}
else
    die("You must enter your name <u>and</u> mesage");
}

?>

<html>

    <form action='sendemail.php' method='POST'>
        Name: <input type='text' name='name' maxlength='20'><br>
        Message:<br><textarea name='message'></textarea><p>
        <input type='submit' name='submit' value='Send'>
    </form>
</html>

Recommended Answers

All 4 Replies

1.check your smtp connection if you already connected.
2.check you have mail server installed or if you are using "xampp", check your mercury service.

are you using LAMP?

i'm using postcast server

you have:

<form action='sendemail.php' method='POST'>

try this:

<form action='' method='POST'>

it works with me

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.