[4.0.x] Refs #32074 -- Recommended aiosmtpd for minimal SMTP server.
Follow up to569a33579c
. Backport of5d13cc540e
from main
This commit is contained in:
parent
f2d3e1fc8c
commit
11881ad69f
|
@ -672,15 +672,19 @@ 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
|
||||||
anything. Python has a built-in way to accomplish this with a single command::
|
anything. The `aiosmtpd`_ package provides a way to accomplish this::
|
||||||
|
|
||||||
python -m smtpd -n -c DebuggingServer localhost:1025
|
python -m pip install aiosmtpd
|
||||||
|
|
||||||
This command will start a minimal SMTP server listening on port 1025 of
|
python -m aiosmtpd -n -l localhost:8025
|
||||||
|
|
||||||
|
This command will start a minimal SMTP server listening on port 8025 of
|
||||||
localhost. This server prints to standard output all email headers and the
|
localhost. This server prints to standard output all email headers and the
|
||||||
email body. You then only need to set the :setting:`EMAIL_HOST` and
|
email body. You then only need to set the :setting:`EMAIL_HOST` and
|
||||||
:setting:`EMAIL_PORT` accordingly. For a more detailed discussion of SMTP
|
:setting:`EMAIL_PORT` accordingly. For a more detailed discussion of SMTP
|
||||||
server options, see the Python documentation for the :mod:`smtpd` module.
|
server options, see the documentation of the `aiosmtpd`_ module.
|
||||||
|
|
||||||
|
.. _aiosmtpd: https://aiosmtpd.readthedocs.io/en/latest/
|
||||||
|
|
||||||
For information about unit-testing the sending of emails in your application,
|
For information about unit-testing the sending of emails in your application,
|
||||||
see the :ref:`topics-testing-email` section of the testing documentation.
|
see the :ref:`topics-testing-email` section of the testing documentation.
|
||||||
|
|
Loading…
Reference in New Issue