pinax / django-mailer

mail queuing and management for the Django web framework
MIT License
810 stars 335 forks source link

connection should be allowed to specify different backends other than default #45

Closed subramanyamVemu closed 9 years ago

subramanyamVemu commented 9 years ago

Hi

It will be good to have the "connection" as a run argument so that we can use multiple email backends

Thanks Bala

spookylukey commented 9 years ago

I'm not sure what you have in mind. If you can describe in more detail how this might fit with the existing way that django-mailer works, please do so.

subramanyamVemu commented 9 years ago

Hi

Sorry for my description earlier

I want to use django-mailer along with django-ses for sending emails

It works if django-ses is configured as the default email backend , but I actually want to send it run time so that the email host can be 1.) self hosted mail server or 2.) amazon ses

To do the above we need the an additional parameter like in the django API which is the "connection"

def send_mail(subject, message, from_email, recipient_list, fail_silently=False, auth_user=None, auth_password=None, connection=None, html_message=None):

so that we can pass it as an argument

Hope I could explain it clearly

spookylukey commented 9 years ago

That isn't going to work, because django-mailer's send_mail serializes messages and saves them for sending later, and it can't serialize a connection.

An alternative would be to added a backend parameter, which would be a string. This would have to be stored on the Message model, and then used by send_all().

I'm not sure this would be worth the additional complexity. Also, it wouldn't work especially well with the normal way of sending messages with django_mailer, which is to configure EMAIL_BACKEND and then use django.core.mail.send_mail. A lot of code uses that function, including 3rd party libraries that you won't be able to change to specify a different backend.

Basically, it seems that the django functionality we are extending isn't suitable for the feature you need, which is multiple backends.

subramanyamVemu commented 9 years ago

I am not sure , can you please review the following pull request It worked for me and I tested it with django ses and self hosted mail server

https://github.com/pinax/django-mailer/pull/46

Sorry didnt run the tests though

spookylukey commented 9 years ago

This method is only going to work if the connection is pickle-able, which is often not guaranteed. We need something more robust than that. Plus, lots of tests fail.

subramanyamVemu commented 9 years ago

Got it

Thanks

spookylukey commented 9 years ago

I'm going to close this as I think this idea adds complexity that django-mailer isn't suited for, and it's a very niche requirement. I don't want you to put a lot of work into this when a PR is probably going to be rejected. Thanks!