From 6320915053bbd22bee2240b80df08ed4e25235f8 Mon Sep 17 00:00:00 2001 From: Mike Edmunds Date: Wed, 16 Jul 2025 15:41:57 -0700 Subject: [PATCH] Refs #36163 -- Reordered EmailMessage options in docs/topics/email.txt. Reordered the keyword-only EmailMessage parameters in the documentation to group similar options together and move rarely used options later. Used keywords for *all* parameters in EmailMessage examples to improve clarity. --- docs/topics/email.txt | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/docs/topics/email.txt b/docs/topics/email.txt index ec87f0337b..3dce2ec38d 100644 --- a/docs/topics/email.txt +++ b/docs/topics/email.txt @@ -50,10 +50,10 @@ specific template and custom headers, you can use the following approach:: # Then, create a multipart email instance. msg = EmailMultiAlternatives( - "Subject here", - text_content, - "from@example.com", - ["to@example.com"], + subject="Subject here", + body=text_content, + from_email="from@example.com", + to=["to@example.com"], headers={"List-Unsubscribe": ""}, ) @@ -337,14 +337,14 @@ but must be in the given order if positional arguments are used: The following parameters must be given as keyword arguments if used: +* ``cc``: A list or tuple of recipient addresses used in the "Cc" header + when sending the email. + * ``bcc``: A list or tuple of addresses used in the "Bcc" header when sending the email. -* ``connection``: An :ref:`email backend ` instance. Use - this parameter if you are sending the ``EmailMessage`` via ``send()`` and you - want to use the same connection for multiple messages. If omitted, a new - connection is created when ``send()`` is called. This parameter is ignored - when using :ref:`send_messages() `. +* ``reply_to``: A list or tuple of recipient addresses used in the "Reply-To" + header when sending the email. * ``attachments``: A list of attachments to put on the message. These can be instances of :class:`~email.mime.base.MIMEBase` or @@ -361,11 +361,11 @@ The following parameters must be given as keyword arguments if used: caller to ensure header names and values are in the correct format for an email message. The corresponding attribute is ``extra_headers``. -* ``cc``: A list or tuple of recipient addresses used in the "Cc" header - when sending the email. - -* ``reply_to``: A list or tuple of recipient addresses used in the "Reply-To" - header when sending the email. +* ``connection``: An :ref:`email backend ` instance. Use + this parameter if you are sending the ``EmailMessage`` via ``send()`` and you + want to use the same connection for multiple messages. If omitted, a new + connection is created when ``send()`` is called. This parameter is ignored + when using :ref:`send_messages() `. .. deprecated:: 6.0 @@ -377,10 +377,10 @@ For example:: from django.core.mail import EmailMessage email = EmailMessage( - "Hello", - "Body goes here", - "from@example.com", - ["to1@example.com", "to2@example.com"], + subject="Hello", + body="Body goes here", + from_email="from@example.com", + to=["to1@example.com", "to2@example.com"], bcc=["bcc@example.com"], reply_to=["another@example.com"], headers={"Message-ID": "foo"},