//~ $filepath = $tmpDir."/".$arrAttachmentInfo["file"]["name"];
 //~ $mail -> Attach($filepath,$arrAttachmentInfo["file"]["name"],$arrAttachmentInfo["file"]["type"]);
 //~ }
 //~ $mail -> Priority(1);
 //~ $mail -> Send();
 $sender = $conferenceInfo->ConferenceContact;
 $recipient = $arrPostInfo["email"];
 $headers = array('From' => $conferenceInfo->ConferenceContact, 'To' => $arrPostInfo["email"], 'Subject' => $arrContent["subject"], 'Organization' => $conferenceInfo->ConferenceCodeName, 'Reply-To' => $conferenceInfo->ConferenceContact, 'Cc' => $arrPostInfo["cc"]);
 $message = $arrContent["content"];
 $mailer =& Mail::factory('smtp');
 if (!$mailer->send($recipient, $headers, $message)) {
     $err_message = "Unable to send mail in process_accept_reject_mail.php.";
     return false;
 }
 //Call the function to log the information
 $result = updateMailLog($paperInfo->PaperID, $arrPostInfo["letterID"]);
 if ($result === true) {
     do_html_header("Successful Update");
     echo "<p>The following paper has been " . $_POST["status"];
     echo ". ";
     echo "An email has been sent to inform the user.<br><br>";
     echo "<strong>PaperID#" . $_POST["paperID"] . "</strong><br>";
     echo "<strong>PaperID:</strong> " . stripslashes($paperInfo->Title) . "<br>";
     echo "<strong>Status:</strong> " . $_POST["status"];
     if ($_POST["status"] == "Accepted") {
         echo " as " . $_POST["presType"];
     }
     echo "<br><br>";
     //echo "Go back to <a href=\"view_all_papers.php\">view all papers</a>.</p>";
     echo "Go back to <a href='view_all_papers.php?sort=" . $_SESSION["sort"] . "&showing=" . $_SESSION["showing"] . ">View All Papers</a>.</p>";
     do_html_footer();
if ($_POST["Submit"] == "Back") {
    unset($_SESSION["arrContent"]);
    $url = "Location: send_paper_info.php?lettertype=" . $arrLetterInfo["lettertype"];
    header($url);
    exit;
}
//Get two array from session to process sending
$arrEmails = $_SESSION["arrUpdateEmails"];
$arrContent = $_SESSION["arrContent"];
//get the conference info to get the contact mail
$conferenceInfo = get_conference_info();
//Get the letter info and its constant
$letterInfo = get_Letter_Info($arrLetterInfo["letterID"]);
while (list($paperID, $email) = each($arrEmails)) {
    //Update the mail log
    $result = updateMailLog($paperID, $arrLetterInfo["letterID"]);
    //If can log the email
    if ($result === true) {
        //Send Email to user
        //~ $mail = new Mail();
        //~ $mail -> Organization($conferenceInfo -> ConferenceCodeName);
        //~ $mail -> ReplyTo($conferenceInfo -> ConferenceContact);
        //~ $mail -> From($conferenceInfo -> ConferenceContact);
        //~ $mail -> To($email);
        //~ $mail -> Subject(stripslashes($arrLetterInfo["subject"]));
        //~ $mail -> Body($arrContent[$paperID]);
        //~ if ($arrLetterInfo["cc"] != "")
        //~ $mail -> Cc($arrLetterInfo["cc"]);
        //~ $mail -> Priority(1);
        //~ $mail -> Send();
        $sender = $conferenceInfo->ConferenceContact;
    unset($_SESSION["arrContent"]);
    $url = "Location: send_reviewer_invitation.php?lettertype=" . $arrLetterInfo["lettertype"];
    header($url);
    exit;
}
//Get two array from session to process sending
$arrEmails = $_SESSION["arrUpdateEmails"];
$arrContent = $_SESSION["arrContent"];
//get the conference info to get the contact mail
$conferenceInfo = get_conference_info();
//Get the letter info and its constant
$letterInfo = get_Letter_Info($arrLetterInfo["letterID"]);
//Call the function to setup reviwer account
while (list($memberName, $email) = each($arrEmails)) {
    //Update the mail log
    $result = updateMailLog($memberName, $arrLetterInfo["letterID"]);
    //If can log the email
    if ($result === true) {
        //Send Email to user
        //~ $mail = new Mail();
        //~ $mail -> Organization($conferenceInfo -> ConferenceCodeName);
        //~ $mail -> ReplyTo($conferenceInfo -> ConferenceContact);
        //~ $mail -> From($conferenceInfo -> ConferenceContact);
        //~ $mail -> To($email);
        //~ $mail -> Subject(stripslashes($arrLetterInfo["subject"]));
        //~ $mail -> Body($arrContent[$memberName]);
        //~ if ($arrLetterInfo["cc"] != "")
        //~ $mail -> Cc($arrLetterInfo["cc"]);
        //~ $mail -> Priority(1);
        //~ $mail -> Send();
        $sender = $conferenceInfo->ConferenceContact;
//get the conference info to get the contact mail
$conferenceInfo = get_conference_info();
//Get the letter info and its constant
$letterInfo = get_Letter_Info($arrLetterInfo["letterID"]);
$arrConstants = evaluate_Letter_Constants($arrLetterInfo["lettertype"]);
//Check if there is session email list to retrieve out
if (isset($_SESSION["arrUpdateEmails"])) {
    $arrEmails = $_SESSION["arrUpdateEmails"];
} else {
    $arrEmails = get_Unsended_EmailList($letterInfo->LetterID, $letterInfo->RecipientGroupName);
}
$arrContent = $_SESSION["arrContent"];
//Call the function to setup reviwer account
while (list($memberName, $email) = each($arrEmails)) {
    //Update the mail log
    $result = updateMailLog($memberName, $letterInfo->LetterID);
    if ($result === true) {
        //Successful Mail Log update
        //Now update the user password
        $result = updateUserPassword($memberName, $arrPassword[$memberName]);
        //If can log the email
        if ($result === true) {
            //Successful Password Update
            //Send Email to user
            //~ $mail = new Mail();
            //~ $mail -> Organization($conferenceInfo -> ConferenceCodeName);
            //~ $mail -> ReplyTo($conferenceInfo -> ConferenceContact);
            //~ $mail -> From($conferenceInfo -> ConferenceContact);
            //~ $mail -> To($email);
            //~ $mail -> Subject(stripslashes($arrLetterInfo["subject"]));
            //~ $mail -> Body($arrContent[$memberName]);
 //~ $mail -> Body($arrContent["content"]);
 //~ if ($arrAccountInfo["cc"] != "")
 //~ $mail -> Cc($arrAccountInfo["cc"]);
 //~ $mail -> Priority(1);
 //~ $mail -> Send();
 $sender = $conferenceInfo->ConferenceContact;
 $recipient = $arrAccountInfo["email"];
 $headers = array('From' => $conferenceInfo->ConferenceContact, 'To' => $arrAccountInfo["email"], 'Subject' => stripslashes($arrContent["subject"]), 'Organization' => $conferenceInfo->ConferenceCodeName, 'Reply-To' => $conferenceInfo->ConferenceContact, 'Cc' => $arrAccountInfo["cc"]);
 $message = $arrContent["content"];
 $mailer =& Mail::factory('smtp');
 if (!$mailer->send($recipient, $headers, $message)) {
     $err_message = "Unable to send mail in process_setup_accout_mail.php.";
     return false;
 }
 //Call the function to log the information
 $result = updateMailLog($arrAccountInfo["loginname"], $arrAccountInfo["letterID"]);
 if ($result === true) {
     do_html_header("Successful Account Setup");
     echo "<p>The following account has been successfully setup.<br><br>";
     echo "Account Type: <strong>" . $arrAccountInfo["accountType"] . "</strong><br>";
     echo "Login Name: <strong>" . $arrAccountInfo["loginname"] . "</strong><br>";
     echo "Email Address: <strong>" . $arrAccountInfo["email"] . "</strong><br><br>";
     echo "Go back to <a href=\"view_all_users.php\">View User Account</a>.</p>";
     do_html_footer();
 } else {
     $return = delete_Newly_Setup_Account($arrAccountInfo["loginname"]);
     do_html_header("Error Information");
     echo "<p>{$result}</p>";
     do_html_footer();
     exit;
 }