in reply to Email Thresholding
Maybe you could use a database table (SQLite or otherwise ...) to accumulate a sort of “to-do list” for this daemon. This table would contain email_type, datetime_when_last_sent, and datetime_when_last_requested. Every few minutes, the process scans to look for emails that need to be sent, and, using REPLACE INTO logic, inserts or updates them into the table with datetime_when_last_requested = NOW(). This is “the most-recent time when we determined that ‘this email needs to be sent soon.’” There is only one row for each email_type.
Separately, the daemon queries this table to find emails that have been requested in the last hour, but have not been sent during that same interval. It sends them (once ...), and updates datetime_when_last_sent = NOW(). The two activities are otherwise unrelated, although you likely will want to do both of them at the same time back-to-back.