MCPcopy
hub / github.com/django/django / _add_bodies

Method _add_bodies

django/core/mail/message.py:654–676  ·  view source on GitHub ↗
(self, msg)

Source from the content-addressed store, hash-verified

652 self.alternatives.append(EmailAlternative(content, mimetype))
653
654 def _add_bodies(self, msg):
655 if self.body or not self.alternatives:
656 super()._add_bodies(msg)
657 if self.alternatives:
658 if hasattr(self, "alternative_subtype"):
659 # RemovedInDjango70Warning.
660 raise AttributeError(
661 "EmailMultiAlternatives no longer supports the"
662 " undocumented `alternative_subtype` attribute"
663 )
664 msg.make_alternative()
665 encoding = self.encoding or settings.DEFAULT_CHARSET
666 for alternative in self.alternatives:
667 maintype, subtype = alternative.mimetype.split("/", 1)
668 content = alternative.content
669 if maintype == "text":
670 if isinstance(content, bytes):
671 content = content.decode()
672 msg.add_alternative(content, subtype=subtype, charset=encoding)
673 else:
674 content = force_bytes(content, encoding=encoding, strings_only=True)
675 msg.add_alternative(content, maintype=maintype, subtype=subtype)
676 return msg
677
678 def body_contains(self, text):
679 """

Callers

nothing calls this directly

Calls 4

force_bytesFunction · 0.90
_add_bodiesMethod · 0.45
splitMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected