Hi There,
I'm a student and i've designed a form for my school site wherin we can send mails to the student through this form.In our college we are given email ids like <your registration number>@college-domain.com.If the student has added his cellnumber as forwarded address,then a sms is sent.
But the problem i'm facing is the mails are either not reachin the recipient or it goes very late varying from 6-7 hours late to 3 days.The code as below.
Can anyone correct me or give me an alternative code....?
Overview
Here the there are 3 college domain like college.com ,college.net , college.edu
Admission numbers starting from 4NI00XXXXXX to 4NI01XXXXXX are given email address in college.com domain. And 4NI02XXXXXX to 4NI03XXXXXX are given the email address in college.net domain and so on. now what i want to do is put 4NI00,4NI01,4NI02,4NI03 in a drop down menu and when they want to send a email if they select 4NI00 the mail should go to that particular domain.In between there should be a text box where they enter the remainin part of their ADMISSION NUMBER.( i.e XXXXXX)
So email should go to: 4NI00<text entered>@<particular domain name>
The FROM email ID is constant i.e its fixed to somethin like <admin@college.com>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
$this_file = $_SERVER['PHP_SELF'];
switch ($_GET['id'])
{
# Firstly we find if the person has filled in the form and wants to send
case "postmail":
switch ($_POST['admin_number'])
{
# Depending on which Admission Number they chose, select the appropriate domain
case "4ni00": $domain = "college.com"; break;
case "4ni01": $domain = "college.net"; break;
case "4ni02": $domain = "college.edu"; break;
case "4ni03": $domain = "college.edu"; break;
}
# Gather all the information into handy variables
# Send the message to the admin number @ the selected domain
$to = $_POST['admin_number'] . $_POST['admin_number_2'] . "@" . $domain;
# Set the from e-mail as the sender name, [email]sendername@college.com[/email]
$from = "From: \"" .$_POST['sender_name']. "\" <" .$_POST['sender_name']. "@college.com>";
# Store the subject in the subject variable
$subject = $_POST['subject'];
# Store the message in the message variable
$message = $_POST['message'];
# Check to see whether the message sent successfully
if (mail($to,$subject,$message,$from))
{
# If it did, tell the user it was sent and redirect them back to the form
echo "<center><font size=\"1\">";
echo "Your message has been sent to its destination<br>Please wait while you are re-directed to the main page.";
echo "<meta content=\"2; url=" .$_SERVER['PHP_SELF']. "\" http-equiv=\"refresh\">";
echo "</font></center>";
}
else
{
# If it failed, tell the user it failed and redirect them back to the form
echo "<center><font size=\"1\">";
echo "Your message has failed to send to its destination<br>Please wait while you are re-directed to the main page.";
echo "<meta content=\"2; url=" .$_SERVER['PHP_SELF']. "\" http-equiv=\"refresh\">";
echo "</font></center>";
}
break;
# If the user has not already filled in the form, present the form for them
default:
?>
<form name="form1" method="post" action="<?php echo $this_file . "?id=post" ?>">
Adminision Number:
<select name="admin_number">
<option value="4ni00">4NI00</option>
<option value="4ni01">4NI01</option>
<option value="4ni02">4NI02</option>
<option value="4ni03">4NI03</option>
</select>
<input name="admin_number_2" type="text" id="admin_no">
<br>
<br>
Sender Name:
<input name="sender_name" type="text" id="sender_name">
<br>
<br>
Subject:
<input name="subject" type="text" id="subject">
<br>
<br>
Message:<br>
<textarea name="message" cols="45" rows="7" id="message"></textarea>
<br>
<br>
<input type="submit" name="Submit" value="Send Message">
</form>
<?php break; } ?>
</body>
</html>
Any help would be appreciated.Thanks in advance
Regards,
Sriram