[1.6.x] Fixed #21614 -- improved docs on configuring email for development.

Backport of d599b590eb from master
This commit is contained in:
Chris Jerdonek 2013-12-13 13:19:48 -08:00 committed by Tim Graham
parent f39579e09f
commit ad8a7819f2
1 changed files with 13 additions and 11 deletions

View File

@ -559,8 +559,8 @@ manually open the connection, you can control when it is closed. For example::
connection.close() connection.close()
Testing email sending Configuring email for development
===================== =================================
There are times when you do not want Django to send emails at There are times when you do not want Django to send emails at
all. For example, while developing a Web site, you probably don't want all. For example, while developing a Web site, you probably don't want
@ -568,13 +568,13 @@ to send out thousands of emails -- but you may want to validate that
emails will be sent to the right people under the right conditions, emails will be sent to the right people under the right conditions,
and that those emails will contain the correct content. and that those emails will contain the correct content.
The easiest way to test your project's use of email is to use the ``console`` The easiest way to configure email for local development is to use the
email backend. This backend redirects all email to stdout, allowing you to :ref:`console <topic-email-console-backend>` email backend. This backend
inspect the content of mail. redirects all email to stdout, allowing you to inspect the content of mail.
The ``file`` email backend can also be useful during development -- this backend The :ref:`file <topic-email-file-backend>` email backend can also be useful
dumps the contents of every SMTP connection to a file that can be inspected during development -- this backend dumps the contents of every SMTP connection
at your leisure. to a file that can be inspected at your leisure.
Another approach is to use a "dumb" SMTP server that receives the emails Another approach is to use a "dumb" SMTP server that receives the emails
locally and displays them to the terminal, but does not actually send locally and displays them to the terminal, but does not actually send
@ -585,7 +585,9 @@ anything. Python has a built-in way to accomplish this with a single command::
This command will start a simple SMTP server listening on port 1025 of This command will start a simple SMTP server listening on port 1025 of
localhost. This server simply prints to standard output all email headers and localhost. This server simply prints to standard output all email headers and
the email body. You then only need to set the :setting:`EMAIL_HOST` and the email body. You then only need to set the :setting:`EMAIL_HOST` and
:setting:`EMAIL_PORT` accordingly, and you are set. :setting:`EMAIL_PORT` accordingly. For a more detailed discussion of SMTP
server options, see the Python documentation for the :mod:`smtpd` module.
For a more detailed discussion of testing and processing of emails locally, For information about unit-testing the sending of emails in your
see the Python documentation for the :mod:`smtpd` module. application, see the :ref:`topics-testing-email` section of :doc:`Testing
Django applications </topics/testing/overview>`.