Skip to content

Instantly share code, notes, and snippets.

@pcustic
Created January 16, 2024 12:00
Show Gist options
  • Save pcustic/13a16d530cd47a14f016c84a11990ba7 to your computer and use it in GitHub Desktop.
Save pcustic/13a16d530cd47a14f016c84a11990ba7 to your computer and use it in GitHub Desktop.
add to app/auth/routes.py
from flask import render_template_string
from flask_mailman import EmailMessage
from app.templates.auth.reset_password_email_content import (
reset_password_email_html_content
)
def send_reset_password_email(user):
reset_password_url = url_for(
"auth.reset_password",
token=user.generate_reset_password_token(),
user_id=user.id,
_external=True,
)
email_body = render_template_string(
reset_password_email_html_content, reset_password_url=reset_password_url
)
message = EmailMessage(
subject="Reset your password",
body=email_body,
to=[user.email],
)
message.content_subtype = "html"
message.send()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment