Giter Site home page Giter Site logo

Comments (6)

spookylukey avatar spookylukey commented on September 21, 2024 3

I'm going to re-open this, for the sake of anyone searching for the issue, although I don't intend to do anything about it in django-mailer itself.

from django-mailer.

spookylukey avatar spookylukey commented on September 21, 2024

It's not at all clear to me that this is a bug in django-mailer. It rather looks like a bug in "templated_mail" due to it creating EmailMessage objects in some non standard way that means they can't be pickled.

If you can provide a reduced test case that shows an issue in django-mailer that would be helpful.

from django-mailer.

pawanpaudel93 avatar pawanpaudel93 commented on September 21, 2024

@spookylukey thanks for replying.

This is what Djoser uses django-templated-mail and It works only when I remove the request https://github.com/pawanpaudel93/django-mailer/blob/master/src/mailer/models.py#L94 while pickling the email on django-mailer. So, there is a problem picking the request. Can you take a look at why the pickling error is occurring ?? @spookylukey

from django-mailer.

spookylukey avatar spookylukey commented on September 21, 2024

OK, it's like I thought. templated_mail is adding extra stuff to the EmailMessage instances, things that can't be pickled (like HttpRequest objects). django-mailer needs to pickle the EmailMessage object, so that is incompatible.

See https://github.com/sunscrapers/django-templated-mail/blob/65e5a34f69d50d4d1b6acdd337f9efcc44b32fae/templated_mail/mail.py#L18

You need to file a bug with templated_mail and see if there is a way for them to do it without adding that attribute. There is no reason for EmailMessage objects to have the request attached to them, that's sounds like a bad design decision to me. An email class shouldn't have access to HttpRequest objects, it's a layering violation, because sending email has got nothing to do with processing HTTP requests. You should rather separate those activities - you should have a function/class that prepares the content of the email (which may use request if you really want), and then passes it on to the EmailMessage constructor. There is no need to subclass EmailMessage in this case.

from django-mailer.

pawanpaudel93 avatar pawanpaudel93 commented on September 21, 2024

@spookylukey Thank you very much for your time and help and also thanks for the great Django app.

from django-mailer.

spookylukey avatar spookylukey commented on September 21, 2024

See sunscrapers/django-templated-mail#29 which may resolve the issue.

from django-mailer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.