This is a fun one. If I do the following code in Django: from django.core.mail import EmailMessage message = EmailMessage('blah', 'From puppies','b...@hope.com', ['b...@hope.com']) message.send()
The message that appears on the other end has this in the body: >From puppies A From at the beginning of any lines in the body gets a > prepended to it. Digging deep into Python's innards reveals that this is a somewhat esoteric protection in case you're writing out Unix mailbox files. The specific issue is here: http://docs.python.org/release/2.6.2/library/email.generator.html#email.generator.Generator and involves the mangle_from_ flag. The hugely more likely case is that if you're using Django's EmailMessage class you're sending emails rather than writing Unix mailbox files and are running into this bug that way. One proposed solution would be to override the __str()__ methods on django.core.mail.SafeMIMEText and django.core.mail.SafeMIMEMultipart. That method by default calls as_string() which in turn creates a Generator with mangle_from_ set to True - see email.message.Message. If the implementation in the Django classes looked something like this, it would work fine: def __str__(self): from email.generator import Generator fp = StringIO() g = Generator(fp, mangle_from_ = False) g.flatten(self, unixfrom=self.unixfrom) return fp.getvalue() I submitted this as a ticket - http://code.djangoproject.com/ticket/13433 - and I'm happy to do patches/test/docs as appropriate but I'd love to get some thoughts on the best approach to fix it. -- --Leo -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.