Store messages mainly in a database with such a categorical scheme (this is pseudocode):
TABLE message {
id,
created_timestamp,
user_id,
sent,
type (sms, email, etc),
content
}
Then, every day, say, at midnight, SELECT all messages where = 0 and user_id = were sent, and aggregate them into one message, send it using the specified type method and mark everything as sent = 1.
You can find the historical message specified only with SELECTing out messages, where = 1 was sent.
source
share