<?
$subject_array = array();
$recipient_array = array();
///////////////////////////////////
$this_script = "ONLYTEST.php"; // The name of THIS file, if you change it.
$subject_array[] = "Subject Choice 1";
$subject_array[] = "Subject Choice 2";
$subject_array[] = "Subject Choice 3";
$subject_array[] = "Subject Choice 4";
$subject_array[] = "Subject Choice 5";
$recipient_array["Your Email"] = "[email protected]";
$recipient_array["Creator of this Script"] = "[email protected]";
////////////////////////////////////////////////////////////////////////////////////
// Saman_sweden
////////////////////////////////////////////////////////////////////////////////////
if ($_POST["send"] == "true") {
echo"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">" ;
$to = $_POST["to"];
$name = $_POST["name"];
$email = $_POST["email"];
$the_subject = $_POST["subject"];
$message = $_POST["message"];
if (($name == "") OR ($email == "") OR ($message == "")) {
print ("<div id=\"sectionContent\">");
print ("<font color=\"red\">One of the fields was left blank. Please put something in all fields.</font><br><br>");
print ("</div><br>");
email_form();
} elseif (ereg("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $email)) {
$recipient = $to;
$subject = $the_subject;
$additional_headers = ("From: $email\n");
$body = ("Name: $name\nEmail: $email\n\nMessage:\n\n" . $message);
if (mail($recipient, $subject, $body, $additional_headers)) {
print ("<div id=\"sectionContent\">");
print ("The Mail was sent successfully to $recipient.<br><br>");
print ("</div><br>");
} else {
print ("<div id=\"sectionContent\">");
print ("<font color=\"red\">Uh-Oh! Something went wrong with the script! Please try again.</font><br><br>");
print ("</div><br>");
$send = "false";
email_form();
}
} else {
print ("<div id=\"sectionContent\">");
print ("<font color=\"red\">That email address does not appear to be valid. Please try again.</font><br><br>");
print ("</div><br>");
$send = "false";
email_form();
}
} else {
print ("<div id=\"sectionContent\">");
print ("Select who you want to mail from the box below and fill out the form.<br><br>");
print ("</div><br>");
email_form();
}
function email_form()
{
global $subject_array, $recipient_array, $this_script, $PHP_SELF;
print ("<div id=\"sectionContent\">");
print ("<form METHOD=POST action=\"$PHP_SELF\">\n");
print ("<input type=\"hidden\" name=\"send\" value=\"true\">\n");
print ("<select name=\"to\">\n");
foreach ($recipient_array as $key => $value) {
print ("<option value=\"" . $value . "\">" . $key . "</option>\n");
}
print ("</select><br><br>\n");
print ("Name:<br><input type=\"text\" name=\"name\"><br><br>\n");
print ("Your Email Address:<br>\n");
print ("<input type=\"text\" name=\"email\" size=\"40\"><br><br>\n");
print ("<select name=\"subject\">\n");
foreach ($subject_array as $value2) {
print ("<option value=\"" . $value2 . "\">" . $value2 . "</option>\n");
}
print ("</select><br><br>\n");
print ("Your Message:<br>\n");
print ("<textarea cols=\"50\" rows=\"5\" name=\"message\"></textarea><br><br>\n");
print ("<input type=\"submit\" value=\"Submit\">&nbsp;&nbsp;\n");
print ("<input type=\"reset\" value=\"Reset Fields\">\n");
print ("</form>\n");
print ("</div>");
}
?>