diff -Naur /home/chad/modules/quiz/quiz.install modules/quiz/quiz.install
--- /home/chad/modules/quiz/quiz.install	2007-04-13 15:33:38.000000000 -0500
+++ modules/quiz/quiz.install	2007-07-12 14:41:06.000000000 -0500
@@ -24,6 +24,11 @@
         takes TINYINT UNSIGNED NOT NULL,
         time_limit INTEGER UNSIGNED DEFAULT 0 NOT NULL,
         quiz_always TINYINT NOT NULL default 0,
+        email_body longtext default null,
+        email_subject varchar(50) default null,
+        email_option integer not null default 0,
+        email_specified_name varchar(30) default null,
+        email_specified_address varchar(50) default null,
         PRIMARY KEY(nid)
       ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
  
@@ -93,6 +98,7 @@
         takes SMALLINT_UNSIGNED NOT NULL,
         time_limit INT_UNSIGNED DEFAULT 0 NOT NULL,
         quiz_always SMALLINT NOT NULL default 0,
+        email_subject varchar(50) default null,
         PRIMARY KEY(nid)
       );");
  
diff -Naur /home/chad/modules/quiz/quiz.module modules/quiz/quiz.module
--- /home/chad/modules/quiz/quiz.module	2007-07-12 16:57:50.689583544 -0500
+++ modules/quiz/quiz.module	2007-07-12 16:58:02.276822016 -0500
@@ -17,6 +17,17 @@
 define('QUESTION_ALWAYS', 1);
 define('QUESTION_NEVER', 2);
 
+/*
+ * Define email options
+ */
+define('EMAIL_OPTION_NONE', 0);
+define('EMAIL_OPTION_QUIZ_TAKER', 1);
+define('EMAIL_OPTION_ADMIN', 2);
+define('EMAIL_OPTION_SPECIFIED', 3);
+
+define('EMAIL_FORMAT_HTML', 0);
+define('EMAIL_FORMAT_PLAINTEXT', 1);
+
 /**
  * Quiz name
  */
@@ -124,6 +135,7 @@
             'path' => 'node/'. arg(1) .'/quiz/start',
             'title' => t('Take @quiz', array('@quiz' => QUIZ_NAME)),
             'callback' => 'quiz_take_quiz',
+            'callback arguments' => array($node),
             'access' => user_access('access quiz'),
             'type' => MENU_LOCAL_TASK,
           );
@@ -276,6 +288,64 @@
     '#description' => t("Default summary. Leave blank if you don't want to give a summary."),
   );
 
+  $form['email'] = array(
+    '#title' => t('Email Options'),
+    '#tree' => false,
+    '#type' => 'fieldset',
+    '#collapsible' => true,
+    '#collapsed' => false,
+    '#tree' => true
+  );
+  
+  if (empty($node->email_option))
+      $node->email_option = EMAIL_OPTION_NONE;
+  
+  $form['email']['email_option'] = array(
+    '#type' => 'radios',
+    '#tree' => false,
+    '#title' => t('If the user has passed the @quiz', array('@quiz' => QUIZ_NAME)),
+    '#options' => array(EMAIL_OPTION_NONE => 'Do not send an email', EMAIL_OPTION_QUIZ_TAKER => 'Email the quiz taker', EMAIL_OPTION_ADMIN => 'Email the site administrator (e-mail address must be set on the Site Information page)', EMAIL_OPTION_SPECIFIED => 'Email a specified recipient (specify below)'),
+    '#default_value' => $node->email_option
+  );
+  $form['email']['email_subject'] = array(
+    '#type' => 'textfield',
+    '#tree' => false,
+    '#title' => t('Email Subject'),
+    '#size' => 50,
+    '#maxlength' => 50,
+    '#default_value' => $node->email_subject
+  );
+  $form['email']['email_specified_name'] = array(
+    '#type' => 'textfield',
+    '#tree' => false,
+    '#title' => t('E-mail Recipient name (if "Email a specified address" is selected above)'),
+    '#size' => 30,
+    '#maxlength' => 30,
+    '#default_value' => $node->email_specified_name
+  );
+  $form['email']['email_specified_address'] = array(
+    '#type' => 'textfield',
+    '#tree' => false,
+    '#title' => t('E-mail recipient address (if "Email a specified address" is selected above)'),
+    '#size' => 50,
+    '#maxlength' => 50,
+    '#default_value' => $node->email_specified_address
+  );
+  $form['email']['email_body'] = array(
+    '#type' => 'textarea',
+    '#tree' => false,
+    '#title' => t('Email body'),
+    '#rows' => 17,
+    '#description' => t('The body of the email to send if the user passes the @quiz.', array('@quiz' => QUIZ_NAME)),
+    '#default_value' => $node->email_body
+  );
+
+  if (!variable_get('quiz_email_from_name', ''))
+    drupal_set_message(t('The quiz email "From" name is not set! Please update your @quiz settings, or no emails can be sent!', array('@quiz' => QUIZ_NAME)), 'error');
+
+  if (!variable_get('quiz_email_from_address', ''))
+    drupal_set_message(t('The quiz email "From" address is not set! Please update your @quiz settings, or no emails can be sent!', array('@quiz' => QUIZ_NANE)), 'error');
+
   return $form;
 }
 
@@ -391,6 +461,15 @@
   if ($node->pass_rate < 0) {
     form_set_error('pass_rate', t('The pass rate value must not be less than 0%.'));
   }
+
+  if ($node->email_option == EMAIL_OPTION_ADMIN && !variable_get('site_mail', ''))
+    form_set_error('email_option', t('E-mail address is not set on the Site Information page.'));
+
+  if ($node->email_option == EMAIL_OPTION_SPECIFIED && empty($node->email_specified_name))
+    form_set_error('email_specified_name', t('Email recipient name is not specified.'));
+
+  if ($node->email_option == EMAIL_OPTION_SPECIFIED && empty($node->email_specified_address))
+    form_set_error('email_specified_address', t('Email recipient address is not specified.'));
 }
 
 /**
@@ -399,9 +478,9 @@
 function quiz_insert($node) {
   quiz_translate_form_date($node, 'quiz_open');
   quiz_translate_form_date($node, 'quiz_close');
-  $sql = "INSERT INTO {quiz} (nid, number_of_questions, shuffle, quiz_open, quiz_close, takes, pass_rate, summary_pass, summary_default, quiz_always)";
-  $sql .= " VALUES(%d, %d, %d, %d, %d, %d, %d, '%s', '%s', %d)";
-  db_query($sql, $node->nid, $node->number_of_questions, $node->shuffle, $node->quiz_open, $node->quiz_close, $node->takes, $node->pass_rate, $node->summary_pass, $node->summary_default, $node->quiz_always);
+  $sql = "INSERT INTO {quiz} (nid, number_of_questions, shuffle, quiz_open, quiz_close, takes, pass_rate, summary_pass, summary_default, quiz_always, email_body, email_subject, email_option, email_specified_name, email_specified_address)";
+  $sql .= " VALUES(%d, %d, %d, %d, %d, %d, %d, '%s', '%s', %d, '%s', '%s', %d, '%s', '%s')";
+  db_query($sql, $node->nid, $node->number_of_questions, $node->shuffle, $node->quiz_open, $node->quiz_close, $node->takes, $node->pass_rate, $node->summary_pass, $node->summary_default, $node->quiz_always, $node->email_body, $node->email_subject, $node->email_option, $node->email_specified_name, $node->email_specified_address);
 }
 
 /**
@@ -410,7 +489,7 @@
 function quiz_update($node) {
   quiz_translate_form_date($node, 'quiz_open');
   quiz_translate_form_date($node, 'quiz_close');
-  db_query("UPDATE {quiz} SET number_of_questions = %d, shuffle = %d, quiz_open = %d, quiz_close = %d, takes = %d, pass_rate = %d, summary_pass = '%s', summary_default ='%s', quiz_always = %d WHERE nid = %d", $node->number_of_questions, $node->shuffle, $node->quiz_open, $node->quiz_close, $node->takes, $node->pass_rate, $node->summary_pass, $node->summary_default, $node->quiz_always, $node->nid);
+  db_query("UPDATE {quiz} SET number_of_questions = %d, shuffle = %d, quiz_open = %d, quiz_close = %d, takes = %d, pass_rate = %d, summary_pass = '%s', summary_default ='%s', quiz_always = %d, email_body = '%s', email_subject = '%s', email_option = %d, email_specified_name = '%s', email_specified_address = '%s' WHERE nid = %d", $node->number_of_questions, $node->shuffle, $node->quiz_open, $node->quiz_close, $node->takes, $node->pass_rate, $node->summary_pass, $node->summary_default, $node->quiz_always, $node->email_body, $node->email_subject, $node->email_option, $node->email_specified_name, $node->email_specified_address, $node->nid);
 }
 
 /**
@@ -601,7 +680,7 @@
  * @return
  *  HTML output for page
  */
-function quiz_take_quiz() {
+function quiz_take_quiz($node) {
   global $user;
   if (arg(0) == 'node' && is_numeric(arg(1)) && user_access('access quiz')) {
      if ($quiz = node_load(arg(1))) {
@@ -652,6 +731,9 @@
         $now = time();
         db_query("UPDATE {quiz_result} SET time_end = %d WHERE rid = %d", $now, $_SESSION['quiz_'. $quiz->nid]['rid']);
 
+        // Send the email.
+        quiz_send_email($node);
+
         //Get the results and summary text for this quiz
         $questions = _quiz_get_answers($_SESSION['quiz_'. $quiz->nid]['rid']);
         $score = quiz_calculate_score($_SESSION['quiz_'. $quiz->nid]['rid']);
@@ -1309,6 +1391,39 @@
     '#description' => t('How do you want to refer to quizzes across the site (for example: quiz, test, assessment).  This will affect display text but will not affect menu paths.'), 
     '#required' => TRUE,
   );
+
+  $form['email'] = array(
+    '#title' => t('Email Options'),
+    '#type' => 'fieldset',
+    '#collapsible' => true,
+    '#collapsed' => true,
+    '#tree' => true
+  );
+  $form['email']['quiz_email_from_name'] = array(
+    '#type' => 'textfield',
+    '#tree' => false,
+    '#title' => t('Email "From" Name'),
+    '#size' => 30,
+    '#maxlength' => 30,
+    '#default_value' => variable_get('quiz_email_from_name', '')
+  );
+  $form['email']['quiz_email_from_address'] = array(
+    '#type' => 'textfield',
+    '#tree' => false,
+    '#title' => t('Email "From" Address'),
+    '#size' => 50,
+    '#maxlength' => 50,
+    '#required' => TRUE, 
+    '#default_value' => variable_get('quiz_email_from_address', '')
+  );
+  $form['email']['quiz_email_format'] = array(
+    '#type' => 'radios',
+    '#tree' => false,
+    '#title' => t('Email format'),
+    '#options' => array(EMAIL_FORMAT_HTML => 'HTML', EMAIL_FORMAT_PLAINTEXT => 'Plain text'),
+    '#required' => TRUE, 
+    '#default_value' => variable_get('quiz_email_format', EMAIL_FORMAT_HTML)
+  );
   return system_settings_form($form);
 }
 
@@ -1850,3 +1965,90 @@
   $output .= drupal_render($form);
   return $output;
 }
+
+function quiz_send_email($node) {
+  if (!variable_get('quiz_email_from_name', '')) {
+    watchdog('error', 'Quiz email from name not set.');
+    return;
+  }
+
+  if (!variable_get('quiz_email_from_address', '')) {
+    watchdog('error', 'Quiz email from address not set.');
+    return;
+  }
+
+  $to = quiz_get_email_to($node);
+
+  // Check if email should be sent out.
+  if (empty($to) || @empty($to['address']))
+    return;
+
+  $from = array(
+    'name' => variable_get('quiz_email_from_name', ''),
+    'address' => variable_get('quiz_email_from_address', '')
+  );
+
+  $node->email_subject;
+  $node->email_body;
+  
+  switch (variable_get('quiz_email_format', EMAIL_FORMAT_PLAINTEXT)) {
+    case EMAIL_FORMAT_HTML:
+      $headers =
+        "To: ".$to['name']." <".$to['address'].">\n" .
+        "From: ".$from['name']." <".$from['address'].">\n" .
+        "MIME-Version: 1.0\n" .
+        "Content-Type: text/html\n";
+
+      $message =
+        "<html>\n" .
+        "<body>".$node->email_body."</body>\n" .
+        "</html>\n";
+
+        break;
+    
+    case EMAIL_FORMAT_PLAINTEXT:
+      $headers  =
+        "To: ".$to['name']." <".$to['address'].">\n" .
+        "From: ".$from['name']." <".$from['address'].">\n" .
+        "MIME-Version: 1.0\n" .
+        "Content-Type: text/plain; charset=UTF-8\n";
+
+      $message = $node->email_body;
+  }
+
+  // Send the message. No subject is specified - just a message.
+  mail('', $node->email_subject, $message, $headers);
+}
+
+function quiz_get_email_to($node) {
+  global $user;
+	
+  $to = null;
+
+  switch ($node->email_option) {
+    case EMAIL_OPTION_NONE:
+    default:
+      break;
+      
+    case EMAIL_OPTION_QUIZ_TAKER:
+      // Quiz-taker = current user at the time this function is called.
+      $to['name'] = $user->name;
+      $to['address'] = $user->mail;
+
+      break;
+
+    case EMAIL_OPTION_ADMIN:
+      $to['name'] = "Administrator";
+      $to['address'] = variable_get('site_mail', '');
+      
+      break;
+
+    case EMAIL_OPTION_SPECIFIED:
+      $to['name'] = $node->email_specified_name;
+      $to['address'] = $node->email_specified_address;
+      
+      break;
+  }
+  
+  return $to;
+}
