问题
so i have this html template that i am using as mail template to send my users for reset their password's. i want to use bootstrap 4 classes
in the template but it's not working. How do i make this work ? I've tried inline css
and it works fine but i want to use bootstrap 4 css
. Any help would be appreciated.
HTML template
<!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 Code
@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")
回答1:
You can only use inline css, email doesen't support css linking, it is only supported by browsers. I already tried to do that with an old css i created some time ago but i had to embed it in the html.
来源:https://stackoverflow.com/questions/61500245/bootstrap-4-css-is-not-working-with-mail-html-template-in-flask