populate_pending_emails
function copies entries
from the pending_emails
table into the sent_emails
table
and then deletes them from the pending_emails
table.
Modify the behavior of your script so that instead it only deletes
entries from the pending_emails
table.
pending_emails
table. When the trigger
function is activated it will perform the insertion (of entries being
deleted) into the sent_emails
table.
The result is that the logging of sent emails is handled by a trigger rather than embedded in the script.