我正在使用 Flask 开发此电子邮件确认应用程序。为此,我正在使用flask_mail(显然),但出现此错误:
TypeError:“邮件”类型的参数不可迭代
@app.route('/email', methods=['GET', 'POST'])
def send_mail():
getting = request.form.get('mail')
token = s.dumps(getting, salt='email-confirm')
msg = Message('Confirm Email', sender='vatsalayvk1434@gmail.com', recipients=[mail])
link = url_for('confirm_mail', token=token, _externel=True)
msg.body = f'Your Link is {link}'
mail.send(msg)
return render_template('confirm.html', getting=getting, token=token)
这是模板代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="{{ url_for('static',filename='dist/css/bootstrap.min.css') }}">
<title>Document</title>
</head>
<body>
<div class="col-lg-12">
<h2 class="display-4 mb-3">Flask Confirm Message App </h2>
<div class="col-md-6">
<form action="/email" method="post" class="mt-3 align-items-center justify-content-center">
<input type="text" name="mail" class="form-control form-control-sm">
<input type="submit" class="btn btn-outline-primary mt-4 ml-3">
</form>
</div>
<h2>The Mail is : {{getting}}</h2>
<h2>The token is : {{token}}</h2>
</div>
</body>
</html>