On Tue, Feb 23, 2010 at 8:01 AM, Russell Keith-Magee <[email protected] > wrote:
> On Tue, Feb 23, 2010 at 8: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. > > I not sure I even understand why a composite backend is required. Just > use two backends. > Its not really needed, we can easily have two backend's with one inheriting from the one. > > It's always been possible to have multiple SMTP connections; with the > introduction of email backends, this concept extends to multiple mail > sending connections. > > By default, mail.send_mail() just makes a call to get an instance of > the default connection, using the configuration values in the settings > file. However, you can manually instantiate a connection with whatever > settings you want, and provide connection to send_mail() or > EmailMessage.send():: > > conn = mail.get_connection( > 'django.core.mail.backends.smtp.EmailBackend', > host='mailhost', > username='me', > password='s3krit') > > mail.send_mail( > subject='hello', > message='hello world', > from_email='[email protected]', > recipient_list=['[email protected]'], > connection=conn) > > So - set up two connections - one simple EmailBackend, and one > django-mailer style queue (or two EmailBackends using different > ports). Store these connections somewhere helpful, and use them as > appropriate. > This is exactly what we are doing just thought it would be cleaner to do something more like mail.send_mail( subject='hello', message='hello world', from_email='[email protected]', recipient_list=['[email protected]'], queue_bypass=True, log_bounce=True, log_open_rate=True) then we could detect the queue_bypass/log_bounce/log_openrate etc in send_messages() and change the email handling and distribution as appropriate. No worries though, this is definitely a fringe case with a few other ways of doing it, the connection property certainly allows us to achieve what we want. Just seemed a little strange that the additional kwargs in mail.send() arn't passed to the function sending the mail, Thanks for the help, Mat P.S I wrote that patch for multicolumn indexes, just didn't have time to Document/write tests prior to the 1.2 feature freeze, will finish it off for 1.3 > > Yours, > Russ Magee %-) > > -- > 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]. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.
