MCPcopy
hub / github.com/django/django / EmailMultiAlternatives

Class EmailMultiAlternatives

django/core/mail/message.py:594–689  ·  view source on GitHub ↗

A version of EmailMessage that makes it easy to send multipart/alternative messages. For example, including text and HTML versions of the text is made easier.

Source from the content-addressed store, hash-verified

592
593
594class EmailMultiAlternatives(EmailMessage):
595 """
596 A version of EmailMessage that makes it easy to send multipart/alternative
597 messages. For example, including text and HTML versions of the text is
598 made easier.
599 """
600
601 @deprecate_posargs(
602 RemovedInDjango70Warning,
603 [
604 "bcc",
605 "connection",
606 "attachments",
607 "headers",
608 "alternatives",
609 "cc",
610 "reply_to",
611 ],
612 )
613 def __init__(
614 self,
615 subject="",
616 body="",
617 from_email=None,
618 to=None,
619 *,
620 bcc=None,
621 connection=None,
622 attachments=None,
623 headers=None,
624 alternatives=None,
625 cc=None,
626 reply_to=None,
627 ):
628 """
629 Initialize a single email message (which can be sent to multiple
630 recipients).
631 """
632 super().__init__(
633 subject,
634 body,
635 from_email,
636 to,
637 bcc=bcc,
638 connection=connection,
639 attachments=attachments,
640 headers=headers,
641 cc=cc,
642 reply_to=reply_to,
643 )
644 self.alternatives = [
645 EmailAlternative(*alternative) for alternative in (alternatives or [])
646 ]
647
648 def attach_alternative(self, content, mimetype):
649 """Attach an alternative content representation."""
650 if content is None or mimetype is None:
651 raise ValueError("Both content and mimetype must be provided.")

Calls

no outgoing calls