Skip to content

Commit 5a0c099

Browse files
medmundsnessita
authored andcommitted
Refs #35514 -- Added "Configuring email" section to email docs.
1 parent 8bb01b1 commit 5a0c099

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

docs/topics/email.txt

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,38 @@ specific template and custom headers, you can use the following approach::
6060
msg.attach_alternative(html_content, "text/html")
6161
msg.send()
6262

63-
Mail is sent using the SMTP host and port specified in the
63+
.. _topic-email-configuration:
64+
65+
Configuring email
66+
=================
67+
68+
By default, Django tries to send email by connecting to an `SMTP`_ server
69+
running on localhost, with no authentication. If that doesn't match your
70+
production environment, trying to send email will raise an error like
71+
``connection refused`` or ``authentication failed``, or cause a connection
72+
timeout. You will need to adjust Django's email settings to reflect your
73+
environment.
74+
75+
Django abstracts the email sending process into an :ref:`email backend
76+
<topic-email-backends>` class. The :setting:`EMAIL_BACKEND` setting controls
77+
which backend Django uses.
78+
79+
The default email backend is Django's :ref:`topic-email-smtp-backend`, which
80+
connects to an SMTP server using the host and port specified in the
6481
:setting:`EMAIL_HOST` and :setting:`EMAIL_PORT` settings. The
6582
:setting:`EMAIL_HOST_USER` and :setting:`EMAIL_HOST_PASSWORD` settings, if
6683
set, are used to authenticate to the SMTP server, and the
6784
:setting:`EMAIL_USE_TLS` and :setting:`EMAIL_USE_SSL` settings control whether
6885
a secure connection is used.
6986

87+
SMTP is supported by nearly all email service providers (ESPs) and many hosting
88+
environments. But there are other options: many commercial ESPs offer HTTP APIs
89+
with additional sending features, and during development or testing you might
90+
not want to send email at all. :ref:`topic-email-backends` lists several
91+
possibilities.
92+
93+
.. _SMTP: https://en.wikipedia.org/wiki/Simple_Mail_Transfer_Protocol
94+
7095
.. _topic-email-sending:
7196

7297
Sending messages

0 commit comments

Comments
 (0)