my $now = time();
+ my $tid = int(rand(0x0fffffff));
+
foreach my $r (@$targets) {
my $pmail = get_primary_mail ($ldap, $r);
my $receiver;
$pmail = $dbh->quote ($pmail);
$insert_cmds .= "INSERT INTO CMSReceivers " .
- "(CMailStore_CID, CMailStore_RID, PMail, Receiver, Status, MTime) " .
- "VALUES ($lcid, currval ('cmailstore_id_seq'), $pmail, $receiver, 'N', $now); ";
+ "(CMailStore_CID, CMailStore_RID, PMail, Receiver, TicketID, Status, MTime) " .
+ "VALUES ($lcid, currval ('cmailstore_id_seq'), $pmail, $receiver, $tid, 'N', $now); ";
+
+ # Note: Tuple (CID, RID, TicketID) must be unique
+ $tid = ($tid + 1) & 0x0fffffff;
}
$dbh->do ($insert_cmds);