前言:这篇博客以163邮箱为例,介绍怎么将html表单发送到163邮箱!这里先给大家展示实现结果:
接下来,我们就来讲实现啦!
文章目录
(一)配置:
1. flask_mail包安装配置
pip install flask_mail
2. 163邮箱配置
(1)选择并开启 POP3/IMAP/SMTP/Exchange/CardDAV/CalDAV服务
(2)设置客户端授权密码
注:这里大家要记起来,这是用于登录第三方邮件客户端的专用密码,后面程序也会用到
⭐接下来我们就要来写前后端啦,我的文件结构是这样子的:
|- templates
|- mail.html
|- config.py
|- runserver.py
(二)前端页面
1.mail.html
(1)代码
<!DOCTYPE html>
<head>
<title>mail</title>
<style>
.mail {
width: 100%;
height: 580px;
background-color: rgba(57, 179, 255, 0.8);
font-family: 'Arial', Courier, monospace;
font-size: 28px;
color: white;
text-align: center;
overflow: hidden;
}
.mail-item {
margin-top: 50px;
}
.info {
display: flex;
flex-direction: row;
margin-top: 20px;
}
.info_left {
width: 500px;
height: 300px;
margin-left: 120px;
}
.info_right {
text-align: left;
width: 670