# Django认证系统使用的模型类
AUTH_USER_MODEL = 'user.User'
# 发送邮件配置
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
# SMTP服务地址,使用其他服务器需更换
EMAIL_HOST = 'smtp.163.com'
EMAIL_PORT = 25
# 发送邮件的邮箱,换成自己的
EMAIL_HOST_USER = '17*****8446@163.com'
# 在邮箱中设置的客户端授权密码,换成自己的
EMAIL_HOST_PASSWORD = 'mi*****eji'
# 收件人看到的发件人,<>中地址必须与上方保持一致
EMAIL_FROM = 'c0c<17*****8446@163.com>'
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('mail/', include(('apps.mail.urls', 'apps.mail'), namespace='mail')), # 邮件验证模块
]
from django.urls import path, re_path
from apps.mail.views import VerifyMail, UserActivate
urlpatterns = [
path('verify/', VerifyMail.as_view(), name='verify'), # 邮件验证
re_path(r'^activate/(?P<token>.*)$', UserActivate.as_view(), name='activate'), # 用户激活
]
<!doctype html>
<html>
{% load staticfiles %}
<head>
<meta charset="utf-8">
<title>celery异步发送验证邮件</title>
<link href="{% static 'css/inc.css' %}" rel="stylesheet" type="text/css">
<link href="{% static 'css/main.css' %}" rel="stylesheet" type="text/css">
<script src="{% static 'js/jquery.min.js' %}"></script>
</head>
<body>
<div id="register_main">
<form method="post" action="/mail/verify/" id="register" name="register">
{% csrf_token %}
<ul>
<li><span>账号</span><input type="text" name="user_name" id="user_name"></li>
<li><span>创建密码</span><input type="password" name="pwd" id="pwd"></li>
<li><span>联系电话</span><input type="text" name="phone" id="phone"></li>
<li><span>邮箱</span><input type="text" name="email" id="email"></li>
</ul>
</form>
<button class="agree_btn">同意以下协议并注册</button>
<script language="javascript" type="text/javascript">
$(".agree_btn").click(function(){
$("#register").submit();
});
</script>
</div>
<footer>
<div class="foot_nav">
</div>
<div class="copy_ri">
<p>吉林省明日科技有限公司Copyright ©2007-2018, All Rights Reserved 吉ICP备10002740号-2 </p>
<img src=""></div>
</div>
</footer>
</body>
</html>