def create_message(self, ctx: T, from_email=None, to=None, bcc=None,
connection=None, attachments=None, headers=None,
alternatives=None, cc=None,
reply_to=None) -> EmailMessage:
'''
Creates and returns a :py:class:`django.core.mail.EmailMessage`
which contains the plaintext and HTML versions of the email,
using the context specified by ``ctx``.
Aside from ``ctx``, arguments to this method are the
same as those for :py:class:`~django.core.mail.EmailMessage`.
'''
msg = EmailMultiAlternatives(
subject=self.render_subject(ctx),
body=self.render_body_as_plaintext(ctx),
from_email=from_email,
to=to,
bcc=bcc,
connection=connection,
attachments=attachments,
headers=headers,
alternatives=alternatives,
cc=cc,
reply_to=reply_to,
)
msg.attach_alternative(self.render_body_as_html(ctx), 'text/html')
return msg
评论列表
文章目录