While discussing the implementation details of the email backends, Russel came up with a nice view on this topic: "If you have highly specialized mail requirements, then it makes sense that you should have a highly specialized mail server handling." [1] If I recall it correctly the consenus was that Django doesn't aim to provide a full-blown email service, but an easy to use default method for sending mails. According to your initial post it sound like your application has a special email feature to send out mass mails using a queue. And high-volume mail processing doesn't sound like a default case to me.
IMO the best solution for your use-case is to have two email backends. One for the newsletter and one for any other mails generated by your application. You can easily pass a connection parameter to the send_mail() or send_mass_mail() function. Andi [1] http://groups.google.de/group/django-developers/msg/a86c5bf950e43d57 On Tue, Feb 23, 2010 at 1:08 AM, Mat Clayton <[email protected]> wrote: > Sorry I probably didn't explain this properly. A composite backend is half > the solution, the other part of the problem is deciding which backend to > use. This decision in our case needs to be made where mail.send() is called. > Either I could load in a custom backend here and replace the default one, or > alternative pass some kwargs through send() to the send_messages() function > in the backend, allowing the composite backend to choose > the appropriate backend to use. > > Does this make more sense? As in this case I cant throw an Exception > easily, as the backends wont fail, they just delay a lot, and ideally any > backends used by a composite backend should be independent of each other. > > Mat > > > On Mon, Feb 22, 2010 at 11:49 PM, Jacob Kaplan-Moss <[email protected]>wrote: > >> On Mon, Feb 22, 2010 at 12:48 PM, Mat Clayton <[email protected]> wrote: >> > Any thoughts on this as a change to the Email Backend system in django? >> >> I'm not sure why you'd need any changes to the backend system: >> couldn't you easily create a composite backend class that tried to >> send email through multiple backends? Here's my completely untested >> stab at the problem:: >> >> class IDontWanna(Exception): >> pass >> >> def composite_backends(*backends): >> class CompositeEmailBackend(object): >> def send_messages(self, messages): >> for backend in backends: >> try: >> backend.send_messages(messages) >> except IDontWanna: >> continue >> >> MyMultipleBackends = composite_backends(BackendOne(), >> BackendTwo(), BackendThree()) >> >> Jacob >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django developers" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]<django-developers%[email protected]> >> . >> For more options, visit this group at >> http://groups.google.com/group/django-developers?hl=en. >> >> > > > -- > -- > Matthew Clayton | Founder/CEO > Wakari Limited > > twitter http://www.twitter.com/matclayton > > email [email protected] > mobile +44 7872007851 > > skype matclayton > > -- > You received this message because you are subscribed to the Google Groups > "Django developers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<django-developers%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/django-developers?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
