Code

Ticket #8638: 8638.2.diff

File 8638.2.diff, 1.3 KB (added by Rob Hudson <treborhudson@…>, 5 years ago)

Some edits and additions to first patch.

Line 
1diff --git a/docs/topics/email.txt b/docs/topics/email.txt
2index b44ab35..ef914d3 100644
3--- a/docs/topics/email.txt
4+++ b/docs/topics/email.txt
5@@ -350,3 +350,27 @@ send out, you could send this with::
6     connection = SMTPConnection()   # Use default settings for connection
7     messages = get_notification_email()
8     connection.send_messages(messages)
9+
10+Preventing or testing e-mails
11+-----------------------------
12+
13+The are times when you do not want Django to send e-mails at all, i.e.
14+during development, or you would like to quickly test e-mail generation
15+and output.  The least intrusive way to do so is to use a "dumb" e-mail
16+server that receives the e-mails locally and displays them, but does not
17+actually send anything.
18+
19+Python has a built-in way to accomplish this with a single command::
20+
21+    python -m smtpd -n -c DebuggingServer localhost:1025
22+
23+This command will start a simple SMTP server listening on port 1025 of
24+localhost.  This server simply prints to standard output all email
25+headers and the email body.  You then only need to set the
26+:setting:`EMAIL_HOST` and :setting:`EMAIL_PORT` accordingly, and you are
27+set.
28+
29+For more entailed testing and processing of e-mails locally, see the
30+Python documentation on the `SMTP Server`_.
31+
32+.. _SMTP Server: http://docs.python.org/library/smtpd.html