1
0
mirror of https://github.com/django/django.git synced 2025-08-21 17:29:13 +00:00

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.
This commit is contained in:
Mike Edmunds 2025-07-16 15:41:57 -07:00 committed by nessita
parent fc793fc303
commit 6320915053

View File

@ -50,10 +50,10 @@ specific template and custom headers, you can use the following approach::
# Then, create a multipart email instance. # Then, create a multipart email instance.
msg = EmailMultiAlternatives( msg = EmailMultiAlternatives(
"Subject here", subject="Subject here",
text_content, body=text_content,
"from@example.com", from_email="from@example.com",
["to@example.com"], to=["to@example.com"],
headers={"List-Unsubscribe": "<mailto:unsub@example.com>"}, headers={"List-Unsubscribe": "<mailto:unsub@example.com>"},
) )
@ -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: 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 * ``bcc``: A list or tuple of addresses used in the "Bcc" header when
sending the email. sending the email.
* ``connection``: An :ref:`email backend <topic-email-backends>` instance. Use * ``reply_to``: A list or tuple of recipient addresses used in the "Reply-To"
this parameter if you are sending the ``EmailMessage`` via ``send()`` and you header when sending the email.
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() <topics-sending-multiple-emails>`.
* ``attachments``: A list of attachments to put on the message. These can * ``attachments``: A list of attachments to put on the message. These can
be instances of :class:`~email.mime.base.MIMEBase` or 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 caller to ensure header names and values are in the correct format for
an email message. The corresponding attribute is ``extra_headers``. an email message. The corresponding attribute is ``extra_headers``.
* ``cc``: A list or tuple of recipient addresses used in the "Cc" header * ``connection``: An :ref:`email backend <topic-email-backends>` instance. Use
when sending the email. 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
* ``reply_to``: A list or tuple of recipient addresses used in the "Reply-To" connection is created when ``send()`` is called. This parameter is ignored
header when sending the email. when using :ref:`send_messages() <topics-sending-multiple-emails>`.
.. deprecated:: 6.0 .. deprecated:: 6.0
@ -377,10 +377,10 @@ For example::
from django.core.mail import EmailMessage from django.core.mail import EmailMessage
email = EmailMessage( email = EmailMessage(
"Hello", subject="Hello",
"Body goes here", body="Body goes here",
"from@example.com", from_email="from@example.com",
["to1@example.com", "to2@example.com"], to=["to1@example.com", "to2@example.com"],
bcc=["bcc@example.com"], bcc=["bcc@example.com"],
reply_to=["another@example.com"], reply_to=["another@example.com"],
headers={"Message-ID": "foo"}, headers={"Message-ID": "foo"},