BBS论坛(七)
2025年01月14日 02:16:49

LIKE.TG 成立于2020年,总部位于马来西亚,是首家汇集全球互联网产品,提供一站式软件产品解决方案的综合性品牌。唯一官方网站:www.like.tg
7.1.修改邮箱界面完成
(1)cms/cms_resetemail.html
{% extends 'cms/cms_base.html' %}
{% block title -%}
修改邮箱
{%- endblock %}
{% block head %}
{% endblock %}
{% block page_title -%}
{{ self.title() }}
{%- endblock %}
{% block main_content %}
<form action="" method="post">
<div class="form-container">
<div class="form-group">
<div class="input-group">
<input type="email" name="email" placeholder="新邮箱" class="form-control">
<span class="input-group-addon">获取验证码</span>
</div>
</div>
<div class="form-group">
<div class="input-group">
<input type="text" name="captcha" placeholder="邮箱验证码" class="form-control">
</div>
</div>
<div class="form-group">
<button class="btn btn-primary" id="submit">立即修改</button>
</div>
</div>
</form>
{% endblock %}
(2)cms.views.py
class ResetEmail(views.MethodView):
def get(self):
return render_template('cms/cms_resetemail.html')
def post(self):
pass
bp.add_url_rule('/resetemail/',view_func=ResetEmail.as_view('resetemail'))
(3)cms/cms_base.html
<li><a href="{{ url_for('cms.resetemail') }}">修改邮箱</a></li>
(3)static/cms/css/base.css
把cms_resetpwd.html中下面的样式放到base.css里面去,这样cms_resetemail和cms_resetpwd都可以用
.form-container{
width: 300px;
}
修改邮箱界面:
7.2.Flask-mail的使用以及邮箱的配置
(1)exts.py
from flask_mail import Mail
mail = Mail()
(2)Perfect_bbs.py
from exts import db,mail
mail.init_app(app)
(3)config.py
MAIL_SERVER = "SMTP.qq.com"
MAIL_PORT = "587"
MAIL_USE_TLS = True
# MAIL_USE_SSL
MAIL_USERNAME = "[email protected]"
MAIL_PASSWORD = "zusbbabvfbdyqihxag"
MAIL_DEFAULT_SENDER = "[email protected]"
(4)cms/views.py
@bp.route('/email/')
def send_email():
#1.标题,2.收件人,3.发送的正文内容
message = Message(subject='derek论坛密码修改邮件发送',recipients=['[email protected]',],body='第一次测试发送邮件')
mail.send(message) #发送邮件
return '邮件发送成功'
测试功能,访问地址就会发送邮件:http://127.0.0.1:5000/cms/email/

现在关注【LIKE.TG出海指南频道】、【LIKE.TG大客户服务频道】,即可免费领取【WhatsApp、LINE、Telegram、Twitter、ZALO云控】等获客工具试用、【住宅IP、号段筛选】等免费资源,机会难得,快来解锁更多资源,助力您的业务飞速成长!点击【联系客服】
本文由LIKE.TG编辑部转载自互联网并编辑,如有侵权影响,请联系官方客服,将为您妥善处理。
This article is republished from public internet and edited by the LIKE.TG editorial department. If there is any infringement, please contact our official customer service for proper handling.
Server deployment全球论坛人工智能论坛全球峰会发展论坛战略论坛开放论坛程序员论坛互联网峰会科技峰会