Django在控制台显示发送邮件内容
一 配置mysite/mysite/settings.py
# 邮件发送到控制台,而不发送到实际的邮箱
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
二 测试
1 输入要发送的电子邮件
2 点击发送电子邮件
3 控制台显示
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[23/Dec/2018 15:03:39] "GET /account/password-reset/ HTTP/1.1" 200 2081
[23/Dec/2018 15:03:40] "GET /blog/ HTTP/1.1" 200 2014
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: =?utf-8?b?6K+36YeN572u5L2g55qE5a+G56CB77yB?=
From: [email protected]
To: [email protected]
Date: Sun, 23 Dec 2018 07:03:47 -0000
Message-ID: <[email protected]>
<p>因为你在 <a href="https://blog.****.net/chengqiuming/">****</a>重置了密码,所以你收到了这封邮件!</p>
<p>请转到以下页面,选择一个新密码:</p>
http://localhost:8000/account/password-reset-confirm/NQ/52d-cd55925d659f35856c1b/
<p>你的用户名是:test</p>
<p>感谢您使用我们的网站!</p>
<p>https://blog.****.net/chengqiuming/</p>
-------------------------------------------------------------------------------
[23/Dec/2018 15:03:47] "POST /account/password-reset/ HTTP/1.1" 302 0
[23/Dec/2018 15:03:47] "GET /account/password-reset-done HTTP/1.1" 301 0
[23/Dec/2018 15:03:48] "GET /account/password-reset-done/ HTTP/1.1" 200 1757