pinax / django-mailer

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

add reply_to message field #51

Closed ajendrex closed 9 years ago

ajendrex commented 9 years ago

Hello,

After upgrading to django 1.8 I'm facing a problem when using this app, since django 1.8 introduced the option reply_to to EmailMessage class, but django-mailer is not using it. Is it possible to add it?

django/core/mail/message.py is firing the following error:

AttributeError: 'EmailMultiAlternatives' object has no attribute 'reply_to'

Thanks, H.

spookylukey commented 9 years ago

Please post a full traceback.

ajendrex commented 9 years ago
Traceback (most recent call last):
  File "/home/hurbina/src/unab/uddo/manage.py", line 19, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/lib/python3.5/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python3.5/site-packages/django/core/management/__init__.py", line 346, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python3.5/site-packages/django/core/management/base.py", line 394, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/lib/python3.5/site-packages/django/core/management/base.py", line 445, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python3.5/site-packages/django/core/management/base.py", line 661, in handle
    return self.handle_noargs(**options)
  File "/usr/lib/python3.5/site-packages/mailer/management/commands/send_mail.py", line 30, in handle_noargs
    send_all()
  File "/usr/lib/python3.5/site-packages/mailer/engine.py", line 130, in send_all
    email.send()
  File "/usr/lib/python3.5/site-packages/django/core/mail/message.py", line 303, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/usr/lib/python3.5/site-packages/django/core/mail/backends/smtp.py", line 107, in send_messages
    sent = self._send(message)
  File "/usr/lib/python3.5/site-packages/django/core/mail/backends/smtp.py", line 121, in _send
    message = email_message.message()
  File "/usr/lib/python3.5/site-packages/django/core/mail/message.py", line 273, in message
    if self.reply_to:
AttributeError: 'EmailMultiAlternatives' object has no attribute 'reply_to'
spookylukey commented 9 years ago

This sounds like an error due to unpickling - you have pickled an EmailMessage object using Django 1.7 then unpickled it using Django 1.8. unpickling doesn't run the initializer, so the EmailMessage never gets that attribute - https://github.com/django/django/blob/master/django/core/mail/message.py#L234

spookylukey commented 9 years ago

I've created a potential fix in a14f71745f50c532ed98651679983f0349ac64b7 - https://github.com/pinax/django-mailer/pull/53

Please note - this is completely untested! I did it straight from GitHub interface. Since this is a corner case that is going to be very hard to write a test for, it would be great if you could test it and see if it fixes your issue. If it works, I'll merge it.

ajendrex commented 9 years ago

You were right Luke, and your patch works!

thanks very much for your help, H.