I'll soon be checking in enough to get it working, but I encountered
an issue I hadn't given thought before.
If (core) send_mail fails (with, for example, a socket exception), I'm
logging the exception using the MessageLog model and the message stays
on the queue for next time.
The problem is that "next time" is immediate as the send_all()
function loops until the queue is empty. After running on my local dev
machine without postfix running, I chalked up some 300 message logs in
5 seconds :-)
What I'm thinking as the fix is the following:
- add a new priority "defer"
- when a (core) send_mail fails, change the priority to "defer"
- consider the queue empty if all that remain are "defer" messages
- have a separate function for promoting the defers back to normal
priority
- run that separate function at whatever interval you'd like to
retry deferrals.
What do people think?
James
Yep, already implemented (although I'm only catching socket.error at
the moment. Need to expand the scope of the exceptions caught)
James