deferring failed emails

5 views
Skip to first unread message

James Tauber

unread,
May 21, 2008, 1:06:28 AM5/21/08
to django...@googlegroups.com
I'm back working on django-mailer, motivated in part by Pinax [1]

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

[1] http://jtauber.com/blog/2008/05/10/introducing_pinax/

Odonian

unread,
May 21, 2008, 9:56:57 AM5/21/08
to django-mailer
Sounds like the most economic solution to the problem; only thing I
can think of in addition is to save the error or exception code, so an
admin can see the cause of deferred messages.

Shev

James Tauber

unread,
May 21, 2008, 10:14:52 AM5/21/08
to django...@googlegroups.com

On May 21, 2008, at 9:56 AM, Odonian wrote:
> Sounds like the most economic solution to the problem; only thing I
> can think of in addition is to save the error or exception code, so an
> admin can see the cause of deferred messages.

Yep, already implemented (although I'm only catching socket.error at
the moment. Need to expand the scope of the exceptions caught)

James

Reply all
Reply to author
Forward
0 new messages