(self, msg)
| 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 | """ |
nothing calls this directly
no test coverage detected