Another solution i've been searching for days now is for sending mail to actually existing accounts, but haven't quite found it yet. I have this functionality in my code where i can search and select professors individually for setting question papers. The search and select pages are working fine, so is the page where i assign them login credentials for setting papers. Now, since i(as admin) am assigning them the login credentials, i need to communicate that information to the selected professors. For this, i figured i'd mail them. I've set up a valid gmail account from where i want this mail to be sent. But my sendmailselected.php file is not working and is erroneous. I will take care to prevent sql injection so that is no issue. Also note that i have made changes in my php.ini file as required, and also have sendmail.zip and sendmail-SSL.zip folders extracted in the bin folder of wamp. Can you please point out errors and help me out. Here's the code:
<?php
include('connectionfile.php');
session_start();
if (!isset($_SESSION["useradmin"])) {
header("Location: index.html");
}
echo "<br><p>";
$prof_id = $_POST['prof_id'];
$temp_id = $_POST['temp_id'];
$temp_usname=$_POST['temp_uname'];
$temp_pswd = $_POST['temp_pwd'];
$temp_status = $_POST['status_paper'];
$sname= $_POST['sname'];
$my= $_POST['my'];
$insert_temp = "INSERT INTO temporary (prof_id, temp_id, temp_uname, temp_pwd, subject_name, monthandyear, status) VALUES ( '".$prof_id."', '".$temp_id."', '".$temp_usname."', '".$temp_pswd."', '".$sname."', '".$my."', '".$temp_status."')";
mysql_query($insert_temp) OR die (mysql_error());
$profmail= "select prof_email_id from professor where prof_id= $prof_id ";
$gotid = mysql_query($profmail) OR die (mysql_error());
$message= "You have been selected for question paper setting for the examination to be held in $my for the subject $subj and your temporary login credentials are as follows: <br> Temporary Username: $temp_usname <br> Temporary ID: $temp_id <br> Temporary Password: $temp_pswd . Please see to it that you sign in and submit the question paper before 10 days. After this period, your temporary account will expire."
$messagelong = wordwrap($message, 3, "\n", true);
$messagelong = wordwrap($message);
ini_set(sendmail_from, ' my gmail account id here ');
mail($profmail, "Selected for paper setting", $message);
ini_restore("sendmail_from");
echo("<p><br> Entry for $temp_id successfully inserted and mail sent.");
mysql_close($id_link);
?>
There is this link i referred to for changes to be made in the php.ini and sendmail.php files. If you need to see that, tell me, i'll post the link. Thanks! :)