Code to send an E-mail utilizing html form and php. Save this code in a file named login.php, change the email to your own email and test it on your server.
<?php
$msg="";
$sent="";
if (isset($_POST['submit']))
{
$name=$_POST['name'];
$email=$_POST['email'];
$message=$_POST['message'];
$message=wordwrap($message, 70);
if (trim($name)=="" | trim($email)=="" | trim($message)=="")
{
$msg= "<b><font color=red size=3>Required field is missing information. Please provide valid name, email and type your message. Inforamtion was not sent.</b></font><br>";
}
else
{
$fro=$email;
$to = "your_email@your_host.com";
$subject = "Message From Your Site";
$body = "Name: $name \nEmail: $email\n Message: $message";
}
if (mail($to,$subject,$body,"From:$fro\r"))
{
$sent="Message was successfully delivery. You will be contacted at the email $email.";
}
else
{
$msg=$msg."Message was NOT successfully delivery. Error: Delivery failed";
}
}
else
{
$name="";
$email="";
$message="";
}
?>
<html>
<body>
<?php print "$msg <br> $sent"; ?>
<form name="form" method="post" enctype="multipart/form-data" action="login.php">
<table width="100%" border="1">
<caption>Contact Form</font>
<tr>
<td><font size="1" face="Verdana"><b>Name</b>:</font></td>
<td>
<?php
echo "<input type='text' name='name' value='$name' size='35' MaxLength='45'>";
?>
</td>
</tr>
<tr>
<td><font size="1" face="Verdana"><b>E-mail address</b>:</font></td>
<td>
<?php
echo "<input type='text' name='email' value='$email' size='35' MaxLength='45'>";
?>
</td>
</tr>
<tr>
<td><font face="Verdana"><b><font size="1">Message</font></b><font size="1">::</font></font></td>
<td>
<?php
echo "<textarea name='message' cols='45' rows='8'>$message</textarea>";
?>
</td>
</tr>
<tr>
<td colspan="2">
<p align="center"><font size="1" face="Verdana">
<input type="submit" name="submit" value=" Send ">
</td>
</tr>
</table>
</form>
</body>
</html>