I can't claim best way, but the way we do it is to have a few django
models for storing the messages, and some help from the email, and
smptlib libraries.

Models:
Mailserver: model for storing connection information for connecting to
a standard smtp server, with mixin class using smtplib to provide smtp
connection.
BulkMail: Unrendered Template, and M2M relationship to users. Fk to
Mailserver.  This model generates Queued messages, in batches until
all recipients have a message queued (we trickle messages out).
QueuedMessage: Rendered message (pickled email.MimeMultipart object),
Fkeys to user, Bulkmail (if message was generated by the BulkMailer)
and Mailserver.

Every 15min a Bulk Mail cron to generate messages into the queue.
Depending on options one bulk mail object may trickle out the messages
until all are sent.
Every minute a cron runs to check for pending QueuedMessage objects,
and sends them to a real smtp server in batches [something like
mailserver_object.process_queue(priority=N,limit=100)]
Another cron using poplib to check the sending POP3 account for
unsubscribe requests, and for bounces using GNU Mailman (it's python,
and pretty simple to throw on your path and use the BouncerAPI for
bounce detection). Anything that isn't an unsub or bounce gets cloned/
forwarded to a human read pop account.
The crons do some checking using memcache okeys to make sure only one
process is doing mail at any one time, and no messages get stuck in a
loop.

All in all, it's been working great.  It takes very little time to
generate the messages and lets a real mail server handle the heavy
lifting/retries.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to