I believe I have found the problem. I use 1.3.7 and so this fix I am about to submit is for that version. Other versions that have this problem can adapt accordingly. I noticed that there were many empty emails in the gv_mail.php form (Admin->Mail Gift Certificate page).
After looking at the HTML source for the Admin->Mail Gift Certificate page I noticed those empty email values were set as selected automatically. When the form is submitted all the empty emails are used as values to insert into the cc_coupon_email_track database. When I had the problem of many gift certificates being sent, when I looked in the database, there was one emailed user and the rest of the emailed_to fields were blank. I had about forty or so gift card codes generated as a result.
I found a problem in admin/includes/functions/html_output.php with function zen_draw_pull_down_menu.
There is a for loop inside this function and in 1.3.7 the for loop reads:
for ($i=0, $n=sizeof($values); $i<$n; $i++) {
$field .= '<option value="' . zen_output_string($values[$i]['id']) . '"';
if ($default == $values[$i]['id']) {
$field .= ' SELECTED';
}
$field .= '>' . zen_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')) . '</option>' . "\n";
}
The for loop needs to change to this instead. It checks for null values:
for ($i=0, $n=sizeof($values); $i<$n; $i++) {
if($values[$i]['id'] != '') {
$field .= '<option value="' . zen_output_string($values[$i]['id']) . '"';
if ($default != '' && $default == $values[$i]['id']) {
$field .= ' SELECTED';
}
$field .= '>' . zen_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')) . '</option>' . "\n";
}
}