繁体   English   中英

bootstrap 4 css 不适用于 flask 中的邮件 html 模板

[英]bootstrap 4 css is not working with mail html template in flask

所以我有这个 html 模板,我用它作为邮件模板来发送我的用户以重置他们的密码。 我想在模板中使用bootstrap 4 classes ,但它不起作用。 我如何使这项工作? 我已经尝试过inline css并且它工作正常,但我想使用bootstrap 4 css 任何帮助,将不胜感激。

HTML 模板

<!DOCTYPE html>
<html lang="en" dir="ltr">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{title}}</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Poppins&family=Rubik:wght@300&display=swap" rel="stylesheet">
</head>

<body>


    <div class="container">
        <div class="text-center">
            <h2>Have you just requested for the password reset !</h2>
            <a href="#" class="btn btn-outline-success">Reset Password</a>
        </div>
    </div>

    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" charset="utf-8"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.bundle.min.js" charset="utf-8"></script>
</body>

</html>

Flask 代码

@app.route('/forget', methods=['GET', 'POST'])
def forget_password():
    form = ForgetPassword()
    if request.method == 'GET':
        return render_template("forget.html", title="Forget Password", form=form)
    email = request.form['email']
    session['email'] = email
    token = s.dumps(email, salt='reset-password')
    msg = Message("Password Reset", sender="bookverm1999@gmail.com", recipients=[email])
    link = url_for("reset_pass", token=token, _external=True)
    msg.body = "Password Reset Link"
    msg.html = render_template("mail.html", link=link, title="Password Reset")
    mail.send(msg)
    return render_template("sent.html", title="Email Sent")

您只能使用内联 css,email 不支持 css 链接,仅浏览器支持。 我已经尝试使用我前一段时间创建的旧 css 来做到这一点,但我必须将其嵌入 html 中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM